Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix potential panics when retrieving VSphereCluster from Cluster.spec.infrastructureRef #2505

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Nov 14, 2023

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
To be honest. Not sure how Machines can exist before Cluster.spec.infrastructureRef is set, but given someone hit this case with CAPD (kubernetes-sigs/cluster-api#9673), I think there is no reason not to play it safe in CAPV as well.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 14, 2023
@sbueringer
Copy link
Member Author

/cherry-pick release-1.8

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.8 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.8

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/test-infra repository.

@sbueringer
Copy link
Member Author

/cherry-pick release-1.7

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.7

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 14, 2023
@sbueringer
Copy link
Member Author

/assign @fabriziopandini @chrischdi

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Attention: 18 lines in your changes are missing coverage. Please review.

Comparison is base (ea2041d) 63.69% compared to head (1b211d9) 63.73%.
Report is 37 commits behind head on main.

Files Patch % Lines
controllers/vspherecluster_reconciler.go 0.00% 8 Missing ⚠️
pkg/util/cluster.go 0.00% 6 Missing and 2 partials ⚠️
controllers/vspheremachine_controller.go 93.10% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2505      +/-   ##
==========================================
+ Coverage   63.69%   63.73%   +0.04%     
==========================================
  Files         123      123              
  Lines        8746     8786      +40     
==========================================
+ Hits         5571     5600      +29     
- Misses       2761     2767       +6     
- Partials      414      419       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

ok with the requeue for now. But let's clarify and open an issue for that if we want to add a watch instead.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b7fa108e2b6cf096e5935596898e35a6e2cf532c

@sbueringer
Copy link
Member Author

Thx! I'm leaning towards just changing the watch. I see no reason why we couldn't watch the cluster in the supervisor mode. But I want to give Naadir some time to respond

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 20, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2023
@sbueringer
Copy link
Member Author

@fabriziopandini @chrischdi PTAL :)

@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2023
@sbueringer
Copy link
Member Author

/hold cancel

@fabriziopandini @randomvariable an lgtm would be great :)

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 20, 2023
@sbueringer
Copy link
Member Author

@chrischdi Can you lgtm?

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 49251e308f8f9779fb7eb18df176778339661fe7

@chrischdi
Copy link
Member

/retest

@randomvariable
Copy link
Member

/lgtm

/retest

@sbueringer
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit da206f1 into kubernetes-sigs:main Dec 5, 2023
18 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Dec 5, 2023
@k8s-infra-cherrypick-robot

@sbueringer: #2505 failed to apply on top of branch "release-1.8":

Applying: Fix potential panics when retrieving VSphereCluster from Cluster.spec.infrastructureRef
Using index info to reconstruct a base tree...
M	controllers/vspherecluster_reconciler.go
M	controllers/vspheremachine_controller.go
M	controllers/vspherevm_controller.go
M	pkg/util/cluster.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/util/cluster.go
Auto-merging controllers/vspherevm_controller.go
Auto-merging controllers/vspheremachine_controller.go
CONFLICT (content): Merge conflict in controllers/vspheremachine_controller.go
Auto-merging controllers/vspherecluster_reconciler.go
CONFLICT (content): Merge conflict in controllers/vspherecluster_reconciler.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix potential panics when retrieving VSphereCluster from Cluster.spec.infrastructureRef
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.8

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/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: #2505 failed to apply on top of branch "release-1.7":

Applying: Fix potential panics when retrieving VSphereCluster from Cluster.spec.infrastructureRef
Using index info to reconstruct a base tree...
M	controllers/vspherecluster_reconciler.go
M	controllers/vspheremachine_controller.go
M	controllers/vspherevm_controller.go
M	pkg/util/cluster.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/util/cluster.go
Auto-merging controllers/vspherevm_controller.go
Auto-merging controllers/vspheremachine_controller.go
CONFLICT (content): Merge conflict in controllers/vspheremachine_controller.go
Auto-merging controllers/vspherecluster_reconciler.go
CONFLICT (content): Merge conflict in controllers/vspherecluster_reconciler.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix potential panics when retrieving VSphereCluster from Cluster.spec.infrastructureRef
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.7

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/test-infra repository.

@sbueringer sbueringer deleted the pr-fix-machine-nil branch December 5, 2023 10:13
@sbueringer
Copy link
Member Author

Given the merge conflicts I would skip cherry-picking. I mostly opened this PR because we did similar changes to CAPD. There are no reports of CAPV observing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants