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: add check for pending clone #311

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Conversation

yati1998
Copy link
Contributor

Incase any pvc is in pending state and the backend subvolume is create, it will be counted as stale.
this commit adds the error check to make sure user doesn't delete the subvolume if it the pvc is in
pending state.

@yati1998 yati1998 requested review from Madhu-1, travisn and subhamkrai and removed request for Madhu-1 and travisn July 11, 2024 18:45
pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
state, err := getSubvolumeState(ctx, clientsets, operatorNamespace, clusterNamespace, fs.Name, sv.Name, svg.Name)
// subvolume info returns error in case of pending clone or if it is not ready
// it is suggested to delete the pvc before deleting the subvolume.
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Considering the err!=nil as pending is not the right assumption, it can fail for other reasons as well. please add a valid check to look for specific strings in error

@yati1998 yati1998 requested a review from Madhu-1 July 15, 2024 11:31
logging.Info("Subvolume info not found for: %q", err)
logging.Info("Please delete the pending pv if any before deleting the subvolume %s", sv.Name)
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

what if the error is not nil and not EAGAIN?

can you please test this and see if we are getting EAGAIN here to make sure we are good 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yatipadia:kubectl-rook-ceph$ ./bin/kubectl-rook-ceph subvolume ls
Filesystem  Subvolume  SubvolumeGroup  State
myfs csi-vol-9e760985-c5cd-46d1-8484-8ecfa1e3d6bc csi in-use
myfs csi-vol-5d13c38b-2263-46bc-826b-6c0df2ad4bcb csi in-use
Error: Error EAGAIN: subvolume 'csi-vol-71bb4f78-1373-4b7e-8400-ea5fd96a22dc' is not ready for operation info
. failed to run command. command terminated with exit code 11%!(EXTRA string=failed to get subvolume info)
Info: Subvolume info not found for: "Error EAGAIN: subvolume 'csi-vol-71bb4f78-1373-4b7e-8400-ea5fd96a22dc' is not ready for operation info\n. failed to run command. command terminated with exit code 11"
Info: Please delete the pending pv if any before deleting the 

Here's the output if the clone is in pending state , the info command is not ready incase the subvolume is not properly created, so this should be fine.

Copy link
Member

Choose a reason for hiding this comment

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

@yati1998 in case of err !=nil and error is not syscall.EAGAIN we need to log it as error and let the user run the tool again, we should not ignore errors unless we know why we are doing like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please review it again, thank you @Madhu-1

if checkSnapshot(ctx, clientsets, operatorNamespace, clusterNamespace, fs.Name, sv.Name, svg.Name) {
status = staleWithSnapshot
// check for snapshot only if the subvolume info doesn't return any error.
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

why we need this check here? i assume err should be handled above not here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in case there is error running subvolume info command, we shouldn't check for the snapshot also, that would just be an addition to run time.

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, after adding continue to above case, we no more need this check as in case of err it will not go further. Thanks for notifying.

if err != nil {
if errors.Is(err, syscall.EAGAIN) {
logging.Info("Subvolume info not found for: %q %q", sv.Name, err)
logging.Info("Please delete the pending pv if any before deleting the subvolume %s", sv.Name)
Copy link
Member

Choose a reason for hiding this comment

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

they also need to scale down the cephfs csi deployment to avoid stale resources isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the log @Madhu-1

@yati1998 yati1998 requested a review from Madhu-1 July 16, 2024 09:25
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.

LGTM

pkg/filesystem/subvolume.go Outdated Show resolved Hide resolved
@yati1998 yati1998 force-pushed the pending-lone branch 2 times, most recently from 8ba12c2 to 2f80851 Compare July 16, 2024 10:02
Incase any pvc is in pending state and the backend
subvolume is create, it will be counted as stale.
this commit adds the error check to make sure user
doesn't delete the subvolume if it the pvc is in
pending state.

Signed-off-by: yati1998 <[email protected]>
@yati1998 yati1998 requested a review from travisn July 17, 2024 03:45
@travisn travisn merged commit 59b8895 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.

3 participants