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 PVC nil pointer dereference during migration-enabled volume expand #111894

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

wongma7
Copy link
Contributor

@wongma7 wongma7 commented Aug 17, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

#111891 reported nil pointer dereference in KCM. Stack trace shows it happened because SetClaimResizer returned nil pvc and non-nil err, this nil PVC was passed to ClaimToClaimKey which panicked.

I think it is also possible for nil pointer dereference to happen at the informer Get which could also return nil pvc and non-nil err so I updated that as well to avoid dereferencing pvc object.

Finally, I updated every other place in this function that tries to call either util.ClaimToClaimKey(pvc) or util.GetPersistentVolumeClaimQualifiedName(pvc) for consistency and because they're unnecessary when we already have the key

Which issue(s) this PR fixes:

Fixes #111891

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. labels Aug 17, 2022
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.25 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.25.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Aug 17 13:39:06 UTC 2022.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 17, 2022
@k8s-ci-robot
Copy link
Contributor

@wongma7: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 17, 2022
@wongma7
Copy link
Contributor Author

wongma7 commented Aug 17, 2022

/sig storage

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 17, 2022
@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Aug 17, 2022
@mattcary
Copy link
Contributor

/retest

(looks like flake failures)

@gnufied
Copy link
Member

gnufied commented Aug 17, 2022

I checked the code btw and I think 1.24, 1.23 and master are safe. The bug might only exist in 1.22 or older versions of Kubernetes.

@wongma7
Copy link
Contributor Author

wongma7 commented Aug 17, 2022

yeah, because of 1ddd598 actually it looks like it is impossible for PatchPVCStatus and thus SetClaimResizer to return nil pvc in 1.23+*. How should I proceed, just open a PR directly to 1.22, or merge this in master as a 'code hygiene' kind of change and cherry-pick to 1.22?

@gnufied
Copy link
Member

gnufied commented Aug 17, 2022

I kind of feel bad about leaving broken code in 1.22 because fix we are putting here does not directly fix the issue and there may be more "users" of the nil pvc and they may break too.

Lets accept this PR anyways and then while backporting to 1.22 fix the PatchPVCStatus function too?

@gnufied
Copy link
Member

gnufied commented Aug 17, 2022

/lgtm

@gnufied
Copy link
Member

gnufied commented Aug 17, 2022

/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2022
@gnufied
Copy link
Member

gnufied commented Aug 17, 2022

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied, wongma7

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 Aug 17, 2022
@wongma7
Copy link
Contributor Author

wongma7 commented Aug 18, 2022

/test pull-kubernetes-e2e-gce-storage-snapshot

@k8s-ci-robot k8s-ci-robot merged commit 69136c0 into kubernetes:master Aug 24, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Aug 24, 2022
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-controller-manager crashes when AWS EBS pvc is unable to resize
4 participants