-
Notifications
You must be signed in to change notification settings - Fork 317
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
chore: pass context #3326
chore: pass context #3326
Conversation
…re.disintegrate-warehouse-integration-tests
…re.disintegrate-warehouse-integration-tests
092e563
to
1149333
Compare
101dc9a
to
abec13e
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3326 +/- ##
==========================================
+ Coverage 68.12% 68.48% +0.36%
==========================================
Files 329 329
Lines 53492 52710 -782
==========================================
- Hits 36443 36101 -342
+ Misses 14719 14270 -449
- Partials 2330 2339 +9
☔ View full report in Codecov by Sentry. |
456a04d
to
2519e14
Compare
2519e14
to
b6bcf57
Compare
b6bcf57
to
2bbc859
Compare
…re.warehouse-pass-context
f389b14
to
942f2d3
Compare
19b232e
to
c8cb345
Compare
warehouse/api.go
Outdated
return settings | ||
} | ||
|
||
// overrideWithEnv overrides the config keys in the fileManager settings | ||
// with fallback values pulled from env. Only supported for S3 for now. | ||
func overrideWithEnv(settings *filemanager.SettingsT) { | ||
envConfig := filemanager.GetProviderConfigFromEnv(context.TODO(), settings.Provider) | ||
func overrideWithEnv(ctx context.Context, settings *filemanager.SettingsT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context seems to be passed to backendConfig.WaitForConfig()
only. What if it gets canceled or it times out though? Do we want GetProviderConfigFromEnv
to return an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need a context propagated to this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we do, in case of cancelation it would stop waiting for the backend config which is a blocking call, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah true but that part of code kinda feels weird to me and probably something which no one would ever use.
Because from the UI he won't even be able to create a S3 destination without filling the required fields but we are waiting for config to get the workspaceID for a destination which isn't there. Not sure if I put it out here properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cisse21 I think this is about proper context propagation thus implicitly honouring such contexts. As far as I understand these calls would be part of the gRPC server. So what if the client disconnects during a gRPC request? I would expect the context to get canceled. In such scenarios, with proper ctx propagation, the backendConfig.WaitForConfig
would correctly return immediately instead of blocking and creating a (temporary) leak:
pkgLogger.Info("Waiting for backend config")
select {
case <-ctx.Done():
return
So all considered, I think context propagation does make sense. What I'm not sure of is whether it makes sense to have the function return an error too so that it would properly be logged and handled upstream i.e.:
func overrideWithEnv(ctx context.Context, settings *filemanager.SettingsT) error {
// ...
return ctx.Err()
}
If yes then getFileManagerSettings
can return an error as well which can be used by validateObjectStorage
which already returns an error that is handled upstream.
@achettyiitr any thoughts as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fracasula I am also aligned with passing the context.
…rudder-server into chore.warehouse-pass-context
Description
Notion Ticket
https://www.notion.so/rudderstacks/make-sure-context-works-as-intended-1d128f7c18fa49acaf007ab82b20394b?pvs=4
Security