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

Issue 8044: generic restore - allow to ignore delay binding for WaitForFirstConsumer #8550

Conversation

Lyndon-Li
Copy link
Contributor

@Lyndon-Li Lyndon-Li commented Dec 24, 2024

Fix issue #8044, allow users to ignore delay binding the restorePVC of data mover when it is in WaitForFirstConsumer mode

@Lyndon-Li Lyndon-Li force-pushed the restore-pvc-ignore-wait-for-first-consumer branch from 505f06b to 5b1f3bd Compare December 24, 2024 02:28
Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 83.78378% with 6 lines in your changes missing coverage. Please review.

Project coverage is 59.16%. Comparing base (6860dab) to head (cfad06b).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cmd/cli/nodeagent/server.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8550      +/-   ##
==========================================
- Coverage   59.18%   59.16%   -0.02%     
==========================================
  Files         370      370              
  Lines       39591    39605      +14     
==========================================
+ Hits        23433    23434       +1     
- Misses      14677    14689      +12     
- Partials     1481     1482       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Lyndon-Li Lyndon-Li force-pushed the restore-pvc-ignore-wait-for-first-consumer branch from 5b1f3bd to 423065a Compare December 26, 2024 02:28
@Lyndon-Li Lyndon-Li force-pushed the restore-pvc-ignore-wait-for-first-consumer branch from 423065a to a56b06b Compare December 26, 2024 02:29
@Lyndon-Li Lyndon-Li changed the title Issue 8044: generic restore - allow to ignore WaitForFirstConsumer Issue 8044: generic restore - allow to ignore delay binding for WaitForFirstConsumer Dec 26, 2024
@Lyndon-Li Lyndon-Li marked this pull request as ready for review December 26, 2024 02:30
@Lyndon-Li Lyndon-Li requested a review from ywk253100 January 3, 2025 02:28
storageClass, err = storageClient.StorageClasses().Get(ctx, *tmpPVC.Spec.StorageClassName, metav1.GetOptions{})
if err != nil {
return false, errors.Wrapf(err, "error to get storage class %s", *tmpPVC.Spec.StorageClassName)
if !ignoreConsume {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a trivial comment, if ignoreConsume == true it seems we don't need to enter the Pollxx function, and the code will be slightly easier to read:

	tmpPVC, err := pvcGetter.PersistentVolumeClaims(namespace).Get(ctx, pvc, metav1.GetOptions{})
	if err != nil {
		return false, errors.Wrapf(err, "error to get pvc %s/%s", namespace, pvc)
	}
	if ignoreConsume {
                return "", tmpPVC, nil
        }
	err := wait.PollUntilContextTimeout(ctx, waitInternal, timeout, true, func(ctx context.Context) (bool, error) {
	        	if tmpPVC.Spec.StorageClassName != nil && storageClass == nil {
	        	.....
	        	updated = tmpPVC
	        	return true, nil
	        })
	        return selectedNode, updated, err

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a side benefit with the current code --- we could probe if the targetPVC exists by always calling pvcGetter.PersistentVolumeClaims(namespace).Get. If the targetPVC doesn't exists, we could fail the restore earlier.
For sure, to achieve the same purpose, we could realign the code for better understanding --- adding another pvcGetter.PersistentVolumeClaims(namespace).Get outside of Pollxx, but that will add redundant code.

So let's keep it as is for now.

Copy link
Contributor

@reasonerjt reasonerjt left a comment

Choose a reason for hiding this comment

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

Approved with a trivial comment.

It can be merged if you don't want to make the change.

@Lyndon-Li Lyndon-Li merged commit be5f56a into vmware-tanzu:main Jan 8, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants