Fix TaskSpawner Deployment not updated when secret type changes#440
Merged
Fix TaskSpawner Deployment not updated when secret type changes#440
Conversation
Collaborator
|
/reset-worker |
1 similar comment
Collaborator
|
/reset-worker |
gjkim42
requested changes
Feb 26, 2026
Collaborator
gjkim42
left a comment
There was a problem hiding this comment.
p0: add tests. you don't have to add extra commit but just commit ammend
Collaborator
|
/reset-worker |
2a14935 to
2e9c32b
Compare
gjkim42
requested changes
Feb 26, 2026
Collaborator
gjkim42
left a comment
There was a problem hiding this comment.
Add integration tests as well
/reset-worker
e146741 to
773736f
Compare
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.
Summary
WatchesforSecretandWorkspaceresources inSetupWithManagerusinghandler.EnqueueRequestsFromMapFunc, so that the TaskSpawner controller is reconciled when the underlying secret data or workspace spec changes (e.g. switching from PAT to GitHub App credentials or vice versa).updateDeployment(): Extended the drift detection to also compare and syncInitContainers,Volumes, andVolumeMountson the main container. Previously onlyImage,Args, andEnvwere checked, so switching auth modes left the Deployment stale.+kubebuilder:rbacannotation forworkspaceson the TaskSpawner controller, which was missing despite the controller already fetching Workspace resources.Test plan
Unit tests (
internal/controller/taskspawner_deployment_builder_test.go)TestUpdateDeployment_PATToGitHubApp: Verifies switching from PAT to GitHub App adds the token-refresher init container, volumes, and volume mountsTestUpdateDeployment_GitHubAppToPAT: Verifies switching back removes init containers, volumes, and volume mountsTestFindTaskSpawnersForSecret: Verifies the Secret mapper correctly maps Secret → Workspace → TaskSpawnerTestFindTaskSpawnersForWorkspace: Verifies the Workspace mapper correctly maps Workspace → TaskSpawnerIntegration tests (
test/integration/taskspawner_test.go)PAT → GitHub App: Updating secret data from PAT to GitHub App credentials triggers reconciliation via the Secret watch, and the Deployment gains a token-refresher init container, volumes, and volume mounts
GitHub App → PAT: The reverse path removes the sidecar configuration
Workspace secretRef change: Updating the workspace to point to a different secret triggers reconciliation via the Workspace watch and updates the Deployment accordingly
All existing tests pass (
make test)All verification checks pass (
make verify)All integration tests pass (
make test-integration)Fixes #439
🤖 Generated with Claude Code