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

csi: delete stale subvolumesnapshot #307

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Conversation

yati1998
Copy link
Contributor

@yati1998 yati1998 commented Jul 4, 2024

this commit checks if there are any stale
volumesnapshots, if yes, it deletes the
snapshots

Copy link
Member

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

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

@yati1998 what about the omap cleanup?

go.mod Outdated Show resolved Hide resolved
if len(splitSnapshotHandle) < 6 {
return nil
}
snapshotHandleId := splitSnapshotHandle[len(splitSnapshotHandle)-1]
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it just compares the snap-id ignore the prefix which matches with snapshothandle.

pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
@yati1998 yati1998 force-pushed the subvolid branch 4 times, most recently from b9b5b61 to bd4100e Compare July 4, 2024 18:45
@yati1998 yati1998 requested a review from Madhu-1 July 4, 2024 18:45
go.mod Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Show resolved Hide resolved
pkg/filesystem/subvolume.go Show resolved Hide resolved
pkg/filesystem/subvolume.go Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
@yati1998
Copy link
Contributor Author

yati1998 commented Jul 9, 2024

@travisn @Madhu-1 please do review the PR, addressed all the changes.

Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

LGTM, just a small test suggestion

pkg/filesystem/subvolume_test.go Show resolved Hide resolved
@yati1998
Copy link
Contributor Author

@subhamkrai do you have any idea why is the ci failing, it seems it is failing due to some plugin test. Can you please check?

go.mod Outdated Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
pkg/filesystem/subvolume.go Show resolved Hide resolved
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
Comment on lines 537 to 572
if err != nil || snapshotcontentname == "" {
logging.Info("No snapshot content found for snapshot %s: %s", snap, err)
return ""
}
Copy link
Member

Choose a reason for hiding this comment

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

am not sure this check is correct, we can consider the error !=nil as not found right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes correct.

Copy link
Member

Choose a reason for hiding this comment

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

This looks like a wrong assumption to consider err!=nil as not found and continue , can you please check this again

Copy link
Member

Choose a reason for hiding this comment

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

Having this assumption will leave a stale entry in the omap, can you please check, if there is any error when running this command it should be logged as Fatal not just info and return empty struct which will skip omap deletion operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay checked that, added the required change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Madhu-1 please do review again.

pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
@yati1998 yati1998 force-pushed the subvolid branch 2 times, most recently from 4de207a to 2b4598b Compare July 10, 2024 08:35
@yati1998 yati1998 requested review from Madhu-1 and subhamkrai July 10, 2024 08:37
go.mod Show resolved Hide resolved
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

The CI is failing:

go: github.com/kubernetes-csi/external-snapshotter/client/[email protected] requires go >= 1.22.0 (running go 1.21.11)
make: *** [Makefile:19: build] Error 1

@yati1998
Copy link
Contributor Author

yati1998 commented Jul 10, 2024

The CI is failing:

go: github.com/kubernetes-csi/external-snapshotter/client/[email protected] requires go >= 1.22.0 (running go 1.21.11)
make: *** [Makefile:19: build] Error 1

yes, checked that, we need to update the go.mod here itself or send another PR and merge it first?

@subhamkrai
Copy link
Collaborator

The CI is failing:

go: github.com/kubernetes-csi/external-snapshotter/client/[email protected] requires go >= 1.22.0 (running go 1.21.11)
make: *** [Makefile:19: build] Error 1

yes, checked that, we need to update the go.mod here itself or send another PR and merge it first?

The CI is failing:

go: github.com/kubernetes-csi/external-snapshotter/client/[email protected] requires go >= 1.22.0 (running go 1.21.11)
make: *** [Makefile:19: build] Error 1

yes, checked that, we need to update the go.mod here itself or send another PR and merge it first?

@yati1998 I created this issue #309 please rebase your PR once that issue is closed.

snapshotHandles := make(map[string]snapshotInfo)
for _, snap := range snapList.Items {
driverName := snap.Spec.Driver
if snap.Status != nil && snap.Status.SnapshotHandle != nil && strings.Contains(driverName, "cephfs") {
Copy link
Member

Choose a reason for hiding this comment

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

cephfs.csi.ceph.com use this one

Comment on lines 537 to 572
if err != nil || snapshotcontentname == "" {
logging.Info("No snapshot content found for snapshot %s: %s", snap, err)
return ""
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a wrong assumption to consider err!=nil as not found and continue , can you please check this again

@yati1998
Copy link
Contributor Author

This looks like a wrong assumption to consider err!=nil as not found and continue , can you please check this again

@Madhu-1 I think this is fine, either there is no omap or some error running the command, anywhich ways we are printing the error too. we do the same for pv also, looks fine to me.

args := []string{"getomapval", snapomapval, "csi.snapname", "-p", poolName, "--namespace", "csi", "/dev/stdout"}
cmd := "rados"
snapshotcontentname, err := runCommand(ctx, clientsets, operatorNamespace, cephClusterNamespace, cmd, args)
if snapshotcontentname == "" {
Copy link
Member

Choose a reason for hiding this comment

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

this should also have err==nil check to work as expected or else if its err!=nil we will have it snapshotcontentname set to empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah, got it.

@travisn
Copy link
Member

travisn commented Jul 16, 2024

@yati1998 Could you look at the CI? Not sure at a glance what the failure is.

@travisn
Copy link
Member

travisn commented Jul 17, 2024

@yati1998 Please rebase it to resolve the merge conflicts

this commit checks if there are any stale
volumesnapshots, if yes, it deletes the
snapshots

Signed-off-by: yati1998 <[email protected]>
@yati1998
Copy link
Contributor Author

@yati1998 Please rebase it to resolve the merge conflicts

can you please review now?

@travisn travisn merged commit aa0561d into rook:master Jul 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants