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

Avoid panicking when snapshotting a non-CSI PV #1067

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

leonardoce
Copy link
Contributor

@leonardoce leonardoce commented Apr 16, 2024

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

This PR avoids the external-snapshotter controller from panicking when the user requests a VolumeGroupSnapshot across non-CSI PVs.

In my tests, master was failing with:

goroutine 124 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc0000f8800?})
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:56 +0xcd
panic({0x17ff940?, 0x29eba50?})
	/Users/leonardo.cecchi/.asdf/installs/golang/1.21.9/go/src/runtime/panic.go:914 +0x21f
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).createGroupSnapshotContent(0xc00031ad00, 0xc0008883c0)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/groupsnapshot_controller_helper.go:757 +0x2db
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).syncUnreadyGroupSnapshot(0xc0000f8ff0?, 0xc0008883c0)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/groupsnapshot_controller_helper.go:445 +0x105b
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).syncGroupSnapshot(0xc00031ad00, 0xc0008883c0)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/groupsnapshot_controller_helper.go:319 +0x6c5
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).updateGroupSnapshot(0xc00031ad00, 0xc0008883c0)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/groupsnapshot_controller_helper.go:247 +0x2a7
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).syncGroupSnapshotByKey(0xc00031ad00, {0xc000058480, 0x1e})
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/snapshot_controller_base.go:702 +0xb87
github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).groupSnapshotWorker(0xc00031ad00)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/snapshot_controller_base.go:647 +0xed
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x30?)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:226 +0x33
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x0?, {0x1cc8900, 0xc0000f7290}, 0x1, 0xc0000ae540)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:227 +0xaf
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x0?, 0x0, 0x0, 0x0?, 0x0?)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:204 +0x7f
k8s.io/apimachinery/pkg/util/wait.Until(0x0?, 0x0?, 0x0?)
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/vendor/k8s.io/apimachinery/pkg/util/wait/backoff.go:161 +0x1e
created by github.com/kubernetes-csi/external-snapshotter/v7/pkg/common-controller.(*csiSnapshotCommonController).Run in goroutine 48
	/Users/leonardo.cecchi/go/src/github.com/kubernetes-csi/external-snapshotter/pkg/common-controller/snapshot_controller_base.go:234 +0x729

With this PR, the controller won't panic anymore, and an event will be recorder for the volumegroupsnapshot telling the user what happened:

➜ k get events |grep volumegroupsnapshot
13s         Warning   CreateGroupSnapshotContentFailed     volumegroupsnapshot/new-groupsnapshot-demo                 Cannot snapshot a non-CSI volume: pvc-de499b35-6856-4c52-98fc-74f3caa6ac27
42s         Warning   GroupSnapshotContentCreationFailed   volumegroupsnapshot/new-groupsnapshot-demo                 failed to create group snapshot content with error cannot snapshot a non-CSI volume for group snapshot default/new-groupsnapshot-demo: pvc-de499b35-6856-4c52-98fc-74f3caa6ac27

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Prevent snapshot controller from panicking when requesting a VolumeGroupSnapshot of a non-CSI volume.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Apr 16, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 16, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @leonardoce. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 16, 2024
@nixpanic
Copy link
Member

Nice catch!

/lgtm
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 16, 2024
@nixpanic
Copy link
Member

/unassign
/assign xing-yang

@k8s-ci-robot k8s-ci-robot assigned xing-yang and unassigned nixpanic Apr 16, 2024
@xing-yang
Copy link
Collaborator

In the release note, can you change "external-snapshotter" to "snapshot controller"?

@leonardoce
Copy link
Contributor Author

In the release note, can you change "external-snapshotter" to "snapshot controller"?

@xing-yang done. Thank you!

@xing-yang
Copy link
Collaborator

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: leonardoce, xing-yang

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 Apr 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit b906618 into kubernetes-csi:master Apr 16, 2024
8 checks passed
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

4 participants