-
Couldn't load subscription status.
- Fork 580
rbd: use ListChildrenAttributes() instead of ListChildren() #5206
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
rbd: use ListChildrenAttributes() instead of ListChildren() #5206
Conversation
|
/test ci/centos/mini-e2e/k8s-1.31 |
|
/test ci/centos/mini-e2e-helm/k8s-1.31 |
internal/rbd/rbd_util.go
Outdated
|
|
||
| // ListChildren() returns pools, images, err. | ||
| _, children, err := image.ListChildren() | ||
| // ListChildrenAttributes() returns child ImageSpec list, err. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can drop this comment, I think the function is rather clear
internal/rbd/rbd_util.go
Outdated
| if child.Trash { | ||
| continue | ||
| } | ||
| if strings.HasSuffix(child.ImageName, "-temp") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider adding a isTempImage(child) function?
internal/rbd/rbd_util.go
Outdated
| } | ||
| } | ||
| // order the temp clone images first followed by the volume snapshots | ||
| // so that the temp clones are flattened first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the 2nd comment about temp clones are flattened first. I don't get why that is the case. If that is a requirement of the returned list, mention something about the order. Or wherever the list is consumed, use some other way of inspecting the list. Might be cleaner to return two lists, so that the distinction is very clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the 2nd comment about
temp clones are flattened first. I don't get why that is the case. If that is a requirement of the returned list, mention something about the order. Or wherever the list is consumed, use some other way of inspecting the list. Might be cleaner to return two lists, so that the distinction is very clear.
I've removed it from the function definition, since we still are returning full list of child images which are not in trash.
I've expanded the comment in this section with reasons why such ordering is done so it can be understood in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes things a little bit clearer. I don't understand (yet) if, and why callers need to care about the order in the list that is returned. If callers need to care, or benefit from it, why not return separate lists? Or, a struct like { snaps, tempChildren, volSnapChildren } so that callers of the function are very aware of the differences, and can decide how to handle them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes things a little bit clearer. I don't understand (yet) if, and why callers need to care about the order in the list that is returned. If callers need to care, or benefit from it, why not return separate lists? Or, a struct like
{ snaps, tempChildren, volSnapChildren }so that callers of the function are very aware of the differences, and can decide how to handle them?
I've moved the logic to order images into the caller and added a struct for returned parameters.
PTAL
72596fb to
a3dd6d2
Compare
ee0e32a to
db3dd12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, makes it much cleaner. Just a nit that needs addressing.
internal/rbd/rbd_util.go
Outdated
|
|
||
| // listSnapAndChildren returns list of names of snapshots and child images. | ||
| func (ri *rbdImage) listSnapAndChildren() ([]librbd.SnapInfo, []string, error) { | ||
| type SnapAndChildrenInfo struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to export this, use snapAndChildrenInfo instead.
internal/rbd/controllerserver.go
Outdated
| // changed block tracking(rbd snap diff). | ||
| // - favor scalability since multiple PVCs can be restored from same | ||
| // volumesnapshot versus just one PVC-PVC clone. | ||
| children := append(snapAndChildrenInfo.TempCloneChildren, snapAndChildrenInfo.VolumeSnapshotChildren...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golangci-lint complains about this. append() may modify the 1st parameter (snapAndChildrenInfo), which could cause confusion later on in case it is used again (docs).
Instead, you could do it like this:
children := make([]string, len(snapAndChildrenInfo.TempCloneChildren) + len(snapAndChildrenInfo.VolumeSnapshotChildren))
children = append(children, snapAndChildrenInfo.TempCloneChildren...)
children = append(children, snapAndChildrenInfo.VolumeSnapshotChildren...)83e17f9 to
a4ab561
Compare
This commit modifies listSnapAndChildren() to make use of ListChildrenAttributes() instead of ListChildren() which allows us to filter out images in trash. This commit also order the alive images so that temp clone images are followed by images backing volume snapshots so that temp clone images are flattened first. Signed-off-by: Rakshith R <[email protected]>
a4ab561 to
0a35f96
Compare
It needs to be initialized with zero length :( |
|
@Mergifyio queue |
🛑 The pull request has been removed from the queue
|
|
/test ci/centos/k8s-e2e-external-storage/1.31 |
|
/test ci/centos/mini-e2e-helm/k8s-1.31 |
|
/test ci/centos/mini-e2e/k8s-1.31 |
|
/test ci/centos/upgrade-tests-cephfs |
|
/test ci/centos/k8s-e2e-external-storage/1.30 |
|
/test ci/centos/upgrade-tests-rbd |
|
/test ci/centos/mini-e2e-helm/k8s-1.30 |
|
/test ci/centos/mini-e2e/k8s-1.30 |
|
/test ci/centos/k8s-e2e-external-storage/1.32 |
|
/test ci/centos/mini-e2e-helm/k8s-1.32 |
|
/test ci/centos/mini-e2e/k8s-1.32 |
|
This pull request has been removed from the queue for the following reason: The merge conditions cannot be satisfied due to failing checks: You may have to fix your CI before adding the pull request to the queue again. If you want to requeue this pull request, you can post a |
|
/retest ci/centos/upgrade-tests-rbd |
|
@Rakshith-R "ci/centos/upgrade-tests-rbd" test failed. Logs are available at location for debugging |
|
/retest ci/centos/upgrade-tests-cephfs |
|
@Rakshith-R "ci/centos/upgrade-tests-cephfs" test failed. Logs are available at location for debugging |
|
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
|
/retest ci/centos/upgrade-tests-cephfs |
|
@Rakshith-R "ci/centos/upgrade-tests-cephfs" test failed. Logs are available at location for debugging |
|
/retest ci/centos/upgrade-tests-rbd |
|
@Rakshith-R "ci/centos/upgrade-tests-rbd" test failed. Logs are available at location for debugging |
|
@Mergifyio requeue |
☑️ This pull request is already queued |
|
Upgrade tests are failing due to |
|
/retest ci/centos/upgrade-tests-rbd |
|
/retest ci/centos/upgrade-tests-cephfs |
|
@Mergifyio requeue |
☑️ This pull request is already queued |
Describe what this PR does
This commit modifies listSnapAndChildren() to make use of ListChildrenAttributes() instead of ListChildren() which allows us to filter out images in trash.
This commit also order the alive images so that temp clone images are followed by images backing volume snapshots so that temp clone images are flattened first.
Is the change backward compatible?
Yes
Are there concerns around backward compatibility?
No
Related issues
Fixes: #5173
Checklist:
guidelines in the developer
guide.
Request
notes
updated with breaking and/or notable changes for the next major release.
Show available bot commands
These commands are normally not required, but in case of issues, leave any of
the following bot commands in an otherwise empty comment in this PR:
/retest ci/centos/<job-name>: retest the<job-name>after unrelatedfailure (please report the failure too!)