Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a config source manager #2857

Merged

Conversation

pjanotti
Copy link
Contributor

Adds a config source manager that wraps the interaction with config sources. This should be the part visible outside the configuration-related implementation, ie.: for the code setting up the service and watching for updates.

The syntax for config source references is provisional.

@pjanotti pjanotti requested a review from a team March 30, 2021 17:41
@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #2857 (e560941) into main (c5ddd09) will decrease coverage by 0.07%.
The diff coverage is 82.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2857      +/-   ##
==========================================
- Coverage   91.74%   91.66%   -0.08%     
==========================================
  Files         286      287       +1     
  Lines       15086    15221     +135     
==========================================
+ Hits        13841    13953     +112     
- Misses        851      865      +14     
- Partials      394      403       +9     
Impacted Files Coverage Δ
config/internal/configsource/manager.go 82.96% <82.96%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5ddd09...e560941. Read the comment docs.

m.sessions[cfgSrcName] = session
}

retrieved, err := session.Retrieve(ctx, selector, params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a blocking call? So we will not indicate in any way that there is an ongoing retrieval from a remote source, which potentially can take a lot of time. If so perhaps in the future we should add some sort of logging or something to show this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is potentially a blocking call as is the NewSession. I will add a parameter to create the manager to include the logger as we typically flow it to components.

config/internal/configsource/manager.go Show resolved Hide resolved
return nil, fmt.Errorf("config source %q not found", cfgSrcName)
}

session, err = cfgSrc.NewSession(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ConfigSource.NewSession docs say:

// The code managing the returned Session object must guarantee that the object is not used
// concurrently and that a single ConfigSource only have one Session open at any time.

Are we violating the second requirement here? If the same cfgSourceName is referenced from multiple places then we are creating multiple sessions, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm treating the config sources as named entities. Let me try to clarify with a hypothetical example:

config_sources:
  vault/db:
    path: secret/db
  vault/users:
    path: secret/users

Then on usage, there should be one session for vault/db and another for vault/users when they are referenced on the config:

exporter:
  db_exporter:
    token: $vault/db:data.token
  some_exporter:
    username: $vault/users:data.traceruser
    password: $vault/users:data.tracerpwd

@pjanotti pjanotti force-pushed the add-config-source-manager branch from 82c4d1c to e560941 Compare April 6, 2021 20:05
@pjanotti
Copy link
Contributor Author

pjanotti commented Apr 6, 2021

Changed the single-line format to have the parameters like URL query part and add multi-line support.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just to be clear, we are not breaking $env or ${env} existing syntax, do we?

@pjanotti
Copy link
Contributor Author

pjanotti commented Apr 7, 2021

LGTM. Just to be clear, we are not breaking $env or ${env} existing syntax, do we?

Currently, it is. I will fix it before hooking it up for actual usage.

@tigrannajaryan tigrannajaryan merged commit 8cac172 into open-telemetry:main Apr 7, 2021
@pjanotti pjanotti deleted the add-config-source-manager branch April 7, 2021 19:32
tigrannajaryan pushed a commit that referenced this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants