chore: improve addon controller job management to prevent blocking updates #9806
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.
Problem Description
The addon controller had issues with stuck jobs that could prevent addon updates from being applied:
activeDeadlineSeconds
could run indefinitely if pods failed to start (e.g., due to image pull errors)Root Cause
When addon updates occur (e.g., configuration changes), the addon's generation increases. However, if there are existing jobs that are stuck (due to
ImagePullBackOff
or other pod startup issues), the controller would wait for these jobs indefinitely, preventing new updates from being applied.Solution
1. Job Timeout Configuration
activeDeadlineSeconds
to all helm jobs (default: 5 minutes)KUBEBLOCKS_ADDON_JOB_TIMEOUT
2. Generation Tracking
addon.kubeblocks.io/generation
to jobs3. Outdated Job Detection and Cleanup
isJobOutdated()
function to check if job belongs to older generationChanges Made
controllers/extensions/addon_controller_stages.go:
isJobOutdated()
helper functioncontrollers/extensions/const.go:
AddonGeneration
constant for annotation keycontrollers/extensions/addon_controller_test.go:
Configuration files:
KUBEBLOCKS_ADDON_JOB_TIMEOUT
environment variableTesting
Benefits
This change ensures that addon updates are more reliable and responsive, especially in environments where image pull issues or other pod startup problems might occur.