Cleanup context handling#758
Merged
Merged
Conversation
ensonic
commented
Jun 26, 2026
Contributor
- Modernized Graceful Shutdown: Updated all entry-point main.go files to use os/signal.NotifyContext. This provides a base context that is automatically cancelled upon receiving termination signals (SIGINT/SIGTERM), allowing for graceful cleanup of all downstream components.
- Updated: setup-dev, setup-robot, token-vendor, cr-syncer, http-relay-client, metadata-server, and gcr-credential-refresher.
- Context Propagation in Controllers: Refactored the Kubernetes controllers (chart-assignment-controller and app-rollout-controller) to use signals.SetupSignalHandler() for their base context, which is then passed down to reconcilers and background release managers.
- Refactored Library Functions: Updated configutil.ReadConfig and Synk.Init to accept a context.Context as their first parameter. This ensures that these long-running or network-dependent operations can be cancelled by their callers.
- Eliminated Deprecated Contexts: Replaced the obsolete golang.org/x/net/context with the standard library's context package in cr-syncer.
- Audit of context.TODO() and context.Background():
- Confirmed that context.TODO() is not used (only in generated code).
- Reduced the usage of context.Background() in production code, replacing it with passed-down contexts to ensure proper cancellation propagation.
- Cleanup of tests to use t.Context()
Contributor
Author
|
Sorry for the large PR, the majority is using t.Context() in tests though. |
csieber
approved these changes
Jun 26, 2026
1. Modernized Graceful Shutdown: Updated all entry-point main.go files to use os/signal.NotifyContext. This provides a base context that is automatically cancelled upon receiving termination signals (SIGINT/SIGTERM), allowing for graceful cleanup of all downstream components. - Updated: setup-dev, setup-robot, token-vendor, cr-syncer, http-relay-client, metadata-server, and gcr-credential-refresher. 2. Context Propagation in Controllers: Refactored the Kubernetes controllers (chart-assignment-controller and app-rollout-controller) to use signals.SetupSignalHandler() for their base context, which is then passed down to reconcilers and background release managers. 3. Refactored Library Functions: Updated configutil.ReadConfig and Synk.Init to accept a context.Context as their first parameter. This ensures that these long-running or network-dependent operations can be cancelled by their callers. 4. Eliminated Deprecated Contexts: Replaced the obsolete golang.org/x/net/context with the standard library's context package in cr-syncer. 5. Audit of context.TODO() and context.Background(): - Confirmed that context.TODO() is not used (only in generated code). - Reduced the usage of context.Background() in production code, replacing it with passed-down contexts to ensure proper cancellation propagation. 6. Cleanup of tests to use t.Context()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.