feat: validate docker image references in upgrade options #10387
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.
What? (description)
This commit adds validation for Docker image references in the UpgradeOptions struct. The validation ensures that all image fields (kubelet, apiserver, controller-manager, scheduler, proxy) are valid Docker image references before proceeding with the upgrade process.
The implementation:
This change helps prevent potential issues during the upgrade process by catching invalid image references early with clear error messages.
Why? (reasoning)
When working with the library, I broke my Kubernetes cluster.
I started to investigate the issue and realized that the Upgrade function was not checking if all the necessary parameters had been submitted.
For instance, it turned out that the image being downloaded was
:v1.31.1
, which is clearly the wrong version to download.This caused the Kubernetes cluster to become unstable. I have created a patch to validate these options and ensure that they are correct.
I have written a simple example to demonstrate this behavior.
https://gist.github.com/azalio/4017548d95cc9b75ae2e8c9725fccca6
Acceptance
Please use the following checklist:
make conformance
)make fmt
)I have launched, but these are not my own changes.
make lint
)make docs
)make unit-tests
)