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

Add nil check for groupSnapshotContent in deleteCSIGroupSnapshotOperaion and unit tests #1152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manishym
Copy link
Contributor

@manishym manishym commented Sep 6, 2024

  • Add a check to ensure groupSnapshotContent is not nil in deleteCSIGroupSnapshotOperation to prevent panics.
  • Enhance error handling for missing SnapshotHandle in VolumeSnapshotContent objects during deletion.
  • Create initial unit tests in groupsnapshot_helper_test.go to cover cases where groupSnapshotContent is nil or incomplete.

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:
Before fix:

[Running: /usr/local/go/bin/go test -timeout 30s -run ^TestDeleteCSIGroupSnapshotOperation$ [github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller)]
--- FAIL: TestDeleteCSIGroupSnapshotOperation (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x105c44fd4]
goroutine 7 [running]:
testing.tRunner.func1.2({0x1060d4860, 0x107102300})
        /Users/manish/.gvm/pkgsets/go1.22.5/global/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
        /Users/manish/.gvm/pkgsets/go1.22.5/global/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1634 +0x33c
panic({0x1060d4860?, 0x107102300?})
        /Users/manish/.gvm/pkgsets/go1.22.5/global/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770 +0x124
[github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller.(*csiSnapshotSideCarController).deleteCSIGroupSnapshotOperation(0x14000094e48](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller.(*csiSnapshotSideCarController).deleteCSIGroupSnapshotOperation(0x14000094e48), 0x140000d65a0)
        /Users/manish/work/openshift/external-snapshotter/pkg/sidecar-controller/groupsnapshot_helper.go:263 +0x404
[github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller.TestDeleteCSIGroupSnapshotOperation(0x140002df520)](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller.TestDeleteCSIGroupSnapshotOperation(0x140002df520))
        /Users/manish/work/openshift/external-snapshotter/pkg/sidecar-controller/groupsnapshot_helper_test.go:50 +0x1d4
testing.tRunner(0x140002df520, 0x10634dda8)
        /Users/manish/.gvm/pkgsets/go1.22.5/global/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 1
        /Users/manish/.gvm/pkgsets/go1.22.5/global/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1742 +0x318
FAIL    [github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller)        1.298s
FAIL
[Command exited with 1]

After fix:

[Running: /usr/local/go/bin/go test -timeout 30s -run ^TestDeleteCSIGroupSnapshotOperation$ [github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller)]
ok      [github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller](http://github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller) 

Which issue(s) this PR fixes:

Fixes #1123

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 6, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @manishym. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 6, 2024
@xing-yang
Copy link
Collaborator

/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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 11, 2024
@manishym
Copy link
Contributor Author

/retest

@xing-yang
Copy link
Collaborator

Can you please rebase?

…tion and unit tests

- Add a check to ensure `groupSnapshotContent` is not nil in `deleteCSIGroupSnapshotOperation` to prevent panics.
- Enhance error handling for missing `SnapshotHandle` in `VolumeSnapshotContent` objects during deletion.
- Create initial unit tests in `groupsnapshot_helper_test.go` to cover cases where `groupSnapshotContent` is nil or incomplete.

Signed-off-by: Manish <[email protected]>
@manishym manishym force-pushed the snapshotter_panic_in_volumegroupsnapshot_processing_1123 branch from 5f04b1b to 9752e2a Compare October 9, 2024 08:22
Copy link
Member

@nixpanic nixpanic left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2024
@nixpanic nixpanic removed their assignment Oct 15, 2024
@xing-yang
Copy link
Collaborator

/approve
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: manishym, 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 Nov 4, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2024
@Madhu-1
Copy link
Contributor

Madhu-1 commented Nov 20, 2024

@manishym can you please rebase the PR

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. 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.

snapshotter panic in volumegroupsnapshot processing
5 participants