chore: improve addon controller job management to prevent blocking updates#9806
Draft
chore: improve addon controller job management to prevent blocking updates#9806
Conversation
…dates - Add job timeout (5 minutes default) to prevent indefinite hanging - Implement generation tracking for jobs to enable cleanup of outdated jobs - Add automatic cleanup of outdated jobs when addon generation changes - Ensure new addon updates can proceed without waiting for stuck jobs - Add comprehensive test coverage for job cleanup scenarios - Use constants for annotation keys to improve maintainability This resolves issues where addon updates were blocked by stuck jobs due to image pull failures or other pod startup issues.
Collaborator
|
Auto Cherry-pick Instructions |
63cae6b to
adeb054
Compare
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment |
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.
Problem Description
The addon controller had issues with stuck jobs that could prevent addon updates from being applied:
activeDeadlineSecondscould 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
ImagePullBackOffor other pod startup issues), the controller would wait for these jobs indefinitely, preventing new updates from being applied.Solution
1. Job Timeout Configuration
activeDeadlineSecondsto all helm jobs (default: 5 minutes)KUBEBLOCKS_ADDON_JOB_TIMEOUT2. Generation Tracking
addon.kubeblocks.io/generationto 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:
AddonGenerationconstant for annotation keycontrollers/extensions/addon_controller_test.go:
Configuration files:
KUBEBLOCKS_ADDON_JOB_TIMEOUTenvironment 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.