Fix nil pointer dereference in ValidateClusterUpdate when old cluster is nil#18167
Fix nil pointer dereference in ValidateClusterUpdate when old cluster is nil#18167Debasish-87 wants to merge 1 commit intokubernetes:masterfrom
Conversation
Signed-off-by: Debasish-87 <22btics06@suiit.ac.in>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @Debasish-87! |
|
Hi @Debasish-87. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@Debasish-87: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fix nil pointer dereference in ValidateClusterUpdate when old cluster is nil
ValidateClusterUpdate currently assumes that the old cluster is non-nil and
dereferences old.Spec.EtcdClusters without a guard, which can lead to a panic
when old is nil.
This scenario can occur during validation flows where an old cluster object
is not provided (e.g., certain initialization or fuzz testing paths).
This change adds a nil check for the old cluster and safely returns the
validation results for the new cluster when old is nil. This prevents the
panic while preserving existing validation behavior.
A unit test has been added to ensure that ValidateClusterUpdate handles a
nil old cluster without panicking.
Fixes #18097
/release-note
Fix a nil pointer dereference in ValidateClusterUpdate when old cluster is nil, preventing a potential panic during cluster validation.