Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ggriffiths
Copy link
Contributor

Signed-off-by: Grant Griffiths [email protected]

What this PR does / why we need it:

Which issue(s) this PR fixes (optional)
Closes #

Special notes for your reviewer:

return nil, err
}

_, err = volumes.Update(ctx, &api.SdkVolumeUpdateRequest{
Copy link
Contributor Author

@ggriffiths ggriffiths Dec 22, 2022

Choose a reason for hiding this comment

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

volumes.Clone calls driver.Snapshot, which removes pvc/namespace labels to avoid misuse. Another possible fix is to change driver.Snapshot to take additional pvc/namespace parameters, but the fix in this PR is far less invasive for a patch.

Labels: getClonedPVCMetadata(locator),
})
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any need to cleanup the cloned volume before returning an error from 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.

yeah, will add this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no longer an issue since we're handling at the sdk layer


_, err = volumes.Update(ctx, &api.SdkVolumeUpdateRequest{
VolumeId: cloneResp.GetVolumeId(),
Labels: getClonedPVCMetadata(locator),
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to worry about merging with the existing labels instead of overwriting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

volumes.Updates code suggests we don't, but I'll merge them here to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, going to move this to the SDK layer to handle this more broadly. will re-request review then.

@ggriffiths ggriffiths force-pushed the clone_add_labels branch 5 times, most recently from 8c96be1 to 2d5f4e7 Compare December 22, 2022 04:15
@ggriffiths ggriffiths requested review from a team and pureneelesh December 22, 2022 04:16
@ggriffiths
Copy link
Contributor Author

test results:
restored pvc has pvc= and namespace= labels, as well as a bunch of other labels from the original volume.

[root@ggriffiths-k8s1-node1 /]# /opt/pwx/bin/pxctl v i 781948984762600138 | grep pvc=
	Labels          	 :  sharedv4=true,sharedv4_svc_type=ClusterIP,csi.storage.k8s.io/pv/name=pvc-b74dda8e-b258-41b0-a3f1-1abaa3e5bc41,csi.storage.k8s.io/pvc/name=mysql-data,csi.storage.k8s.io/pvc/namespace=default,namespace=default,pvc=hpvc-restore,repl=2

// Cloned volume may not have locator or volume.
// This is unlikely, but we'll avoid a panic here.
if clone.GetVolume() != nil && clone.GetVolume().GetLocator() != nil &&
clone.GetVolume().GetLocator().GetVolumeLabels() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the last check on line 206 is not needed since clonedLabels will just be nil on line 207 which is ok.

@ggriffiths ggriffiths merged commit d00f0c4 into libopenstorage:master Dec 23, 2022
@ggriffiths ggriffiths deleted the clone_add_labels branch December 23, 2022 02:15
github-actions bot pushed a commit that referenced this pull request Dec 23, 2022
@github-actions
Copy link

This pull request cannot be automatically cherry-picked to the target release branch.
This is likely due to a merge conflict. Please cherry-pick this change yourself and handle the merge conflict.

ggriffiths pushed a commit to ggriffiths/openstorage that referenced this pull request Jan 6, 2023
ggriffiths pushed a commit to ggriffiths/openstorage that referenced this pull request Jan 6, 2023
ggriffiths pushed a commit that referenced this pull request Jan 6, 2023
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.

2 participants