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

rbd: add support for flattenMode option for replication #4678

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

Rakshith-R
Copy link
Contributor

@Rakshith-R Rakshith-R commented Jun 13, 2024

This commit adds support for flattenMode option
for replication.
If the flattenMode is set to "force" in
volumereplicationclass parameters, cephcsi will
add a task to flatten the image if it has parent.
This enable cephcsi to then mirror such images after flattening them.
The error message when the image's parent is
in trash or unmirrored is improved as well.

Checklist:

  • Commit Message Formatting: Commit titles and messages follow
    guidelines in the developer
    guide
    .
  • Reviewed the developer guide on Submitting a Pull
    Request
  • Pending release
    notes

    updated with breaking and/or notable changes for the next major release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

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 unrelated
    failure (please report the failure too!)

test results

Restored PVC

  • alive snapshot:
I0619 09:20:05.482558       1 utils.go:198] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 09:20:05.485272       1 utils.go:199] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC request: {"parameters":{"schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18"}
I0619 09:20:05.506278       1 omap.go:89] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 got omap values: (pool="replicapool", namespace="", name="csi.volume.ae66b7a1-21d7-4205-bc0a-d620e1fbab18"): map[csi.imageid:11c0103d7da8 csi.imagename:csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 csi.volname:pvc-cf11e3a2-50c8-438a-8911-958e046772f8 csi.volume.owner:rook-ceph]
W0619 09:20:05.845510       1 replication.go:153] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 09:20:05.845583       1 replication.go:129] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 flattenMode is not set in parameters, setting to default (never)
E0619 09:20:06.336891       1 replication.go:314] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 failed to enable mirroring on image "replicapool/csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18":parent image "replicapool/csi-snap-ad971f5b-61a2-4bf4-8c0b-4ec61cec216e" is not enabled for mirroring
E0619 09:20:06.340126       1 utils.go:203] ID: 36 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC error: rpc error: code = Internal desc = failed to enable mirroring on image "replicapool/csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18": parent image "replicapool/csi-snap-ad971f5b-61a2-4bf4-8c0b-4ec61cec216e" is not enabled for mirroring
  • deleted snapshot
I0619 09:21:45.816334       1 utils.go:198] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 09:21:45.819942       1 utils.go:199] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC request: {"parameters":{"schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18"}
I0619 09:21:45.828980       1 omap.go:89] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 got omap values: (pool="replicapool", namespace="", name="csi.volume.ae66b7a1-21d7-4205-bc0a-d620e1fbab18"): map[csi.imageid:11c0103d7da8 csi.imagename:csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 csi.volname:pvc-cf11e3a2-50c8-438a-8911-958e046772f8 csi.volume.owner:rook-ceph]
W0619 09:21:45.958255       1 replication.go:153] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 09:21:45.958630       1 replication.go:129] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 flattenMode is not set in parameters, setting to default (never)
E0619 09:21:46.093419       1 replication.go:314] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 system is not in a state required for the operation's execution: failed to enable mirroring on image "replicapool/csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18": parent is in trash
E0619 09:21:46.093596       1 utils.go:203] ID: 49 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC error: rpc error: code = FailedPrecondition desc = system is not in a state required for the operation's execution: failed to enable mirroring on image "replicapool/csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18": parent is in trash
  • with flattenMode force
I0619 09:24:53.228433       1 utils.go:198] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 09:24:53.228743       1 utils.go:199] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC request: {"parameters":{"flattenMode":"force","schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18"}
I0619 09:24:53.237278       1 omap.go:89] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 got omap values: (pool="replicapool", namespace="", name="csi.volume.ae66b7a1-21d7-4205-bc0a-d620e1fbab18"): map[csi.imageid:11c0103d7da8 csi.imagename:csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 csi.volname:pvc-cf11e3a2-50c8-438a-8911-958e046772f8 csi.volume.owner:rook-ceph]
W0619 09:24:53.387365       1 replication.go:153] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 09:24:53.538514       1 rbd_util.go:829] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 rbd: adding task to flatten image "replicapool/csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18"
E0619 09:24:53.736260       1 replication.go:314] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 flatten in progress: flatten is in progress for image csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18
E0619 09:24:53.736433       1 utils.go:203] ID: 53 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC error: rpc error: code = Aborted desc = flatten in progress: flatten is in progress for image csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18
...
I0619 09:24:55.058061       1 utils.go:198] ID: 57 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 09:24:55.058184       1 utils.go:199] ID: 57 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC request: {"parameters":{"flattenMode":"force","schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18"}
I0619 09:24:55.090814       1 omap.go:89] ID: 57 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 got omap values: (pool="replicapool", namespace="", name="csi.volume.ae66b7a1-21d7-4205-bc0a-d620e1fbab18"): map[csi.imageid:11c0103d7da8 csi.imagename:csi-vol-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 csi.volname:pvc-cf11e3a2-50c8-438a-8911-958e046772f8 csi.volume.owner:rook-ceph]
W0619 09:24:55.170256       1 replication.go:153] ID: 57 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 09:24:56.210444       1 utils.go:205] ID: 57 Req-ID: 0001-0009-rook-ceph-0000000000000002-ae66b7a1-21d7-4205-bc0a-d620e1fbab18 GRPC response: {}

PVC-PVC clone

  • with flattenMode default never:
I0619 09:29:13.460421       1 utils.go:198] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 09:29:13.468826       1 utils.go:199] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 GRPC request: {"parameters":{"schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7"}
I0619 09:29:13.491370       1 omap.go:89] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 got omap values: (pool="replicapool", namespace="", name="csi.volume.f3f494a9-c9f9-4734-b9e4-b04cd58cfac7"): map[csi.imageid:187bfd24f7c6 csi.imagename:csi-vol-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 csi.volname:pvc-12fe2ae9-cb90-4bee-9247-6146f11bf8e2 csi.volume.owner:rook-ceph]
W0619 09:29:13.620327       1 replication.go:153] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 09:29:13.620533       1 replication.go:129] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 flattenMode is not set in parameters, setting to default (never)
E0619 09:29:14.225457       1 replication.go:314] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 failed to enable mirroring on image "replicapool/csi-vol-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7":parent image "replicapool/csi-vol-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7-temp" is not enabled for mirroring
E0619 09:29:14.226126       1 utils.go:203] ID: 78 Req-ID: 0001-0009-rook-ceph-0000000000000002-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7 GRPC error: rpc error: code = Internal desc = failed to enable mirroring on image "replicapool/csi-vol-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7": parent image "replicapool/csi-vol-f3f494a9-c9f9-4734-b9e4-b04cd58cfac7-temp" is not enabled for mirroring
  • with flattenMode force
I0619 10:17:48.127012       1 utils.go:198] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 10:17:48.127174       1 utils.go:199] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC request: {"parameters":{"flattenMode":"force","schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93"}
I0619 10:17:48.139129       1 omap.go:89] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 got omap values: (pool="replicapool", namespace="", name="csi.volume.d73378c1-62b3-454e-8646-dae3207e7f93"): map[csi.imageid:1d39997d6758 csi.imagename:csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93 csi.volname:pvc-95b1e8ca-590d-420e-9c93-d6686e857d2a csi.volume.owner:rook-ceph]
W0619 10:17:48.284313       1 replication.go:153] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 10:17:48.468021       1 rbd_util.go:634] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 rbd: delete csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93-temp using mon 192.168.122.191:6789, pool replicapool
I0619 10:17:48.494034       1 rbd_util.go:676] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 rbd: adding task to remove image "replicapool/csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93-temp" with id "1d39206cc57d" from trash
I0619 10:17:48.503025       1 rbd_util.go:700] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 rbd: successfully added task to move image "replicapool/csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93-temp" with id "1d39206cc57d" to trash
I0619 10:17:48.503080       1 rbd_util.go:850] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 rbd: adding task to flatten image "replicapool/csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93"
E0619 10:17:48.599921       1 replication.go:314] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 flatten in progress: flatten is in progress for image csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93
E0619 10:17:48.600632       1 utils.go:203] ID: 33 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC error: rpc error: code = Aborted desc = flatten in progress: flatten is in progress for image csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93
...
0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC call: /replication.Controller/EnableVolumeReplication
I0619 10:17:57.469112       1 utils.go:199] ID: 37 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC request: {"parameters":{"flattenMode":"force","schedulingInterval":"1m"},"secrets":"***stripped***","volume_id":"0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93"}
I0619 10:17:57.481057       1 omap.go:89] ID: 37 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 got omap values: (pool="replicapool", namespace="", name="csi.volume.d73378c1-62b3-454e-8646-dae3207e7f93"): map[csi.imageid:1d39997d6758 csi.imagename:csi-vol-d73378c1-62b3-454e-8646-dae3207e7f93 csi.volname:pvc-95b1e8ca-590d-420e-9c93-d6686e857d2a csi.volume.owner:rook-ceph]
W0619 10:17:57.530084       1 replication.go:153] ID: 37 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 mirroringMode is not set in parameters, setting to mirroringMode to default (snapshot)
I0619 10:17:57.603214       1 utils.go:205] ID: 37 Req-ID: 0001-0009-rook-ceph-0000000000000002-d73378c1-62b3-454e-8646-dae3207e7f93 GRPC response: {}

@mergify mergify bot added the component/rbd Issues related to RBD label Jun 13, 2024
Copy link
Contributor

mergify bot commented Jun 13, 2024

This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏

@Rakshith-R Rakshith-R force-pushed the flattenMode branch 8 times, most recently from 0839781 to 5588b73 Compare June 17, 2024 07:29
@Rakshith-R Rakshith-R marked this pull request as ready for review June 19, 2024 10:26
@Rakshith-R
Copy link
Contributor Author

I've added testing results in pr description.
The pr is ready for review.

@Rakshith-R Rakshith-R requested review from nixpanic, Madhu-1 and a team June 19, 2024 10:27
@iPraveenParihar
Copy link
Contributor

I've added testing results in pr description. The pr is ready for review.

@Rakshith-R, I don't see the testing results in the PR description. can you re-check if you have missed it?

@Rakshith-R
Copy link
Contributor Author

I've added testing results in pr description. The pr is ready for review.

@Rakshith-R, I don't see the testing results in the PR description. can you re-check if you have missed it?

forgot to press update button.
Its updated now.
ptal

return corerbd.FlattenModeNever
}

switch corerbd.FlattenMode(val) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
switch corerbd.FlattenMode(val) {
mode := corerbd.FlattenMode(val);
switch mode {
case corerbd.FlattenModeForce, corerbd.FlattenModeNever:
return mode,nil
default:
log.DebugLog(ctx, "flattenMode %v not supported",mode)
return mode,err
}

lets return error in case of its a user mistake instead of choosing FlattenModeNever

Comment on lines +300 to +299
if err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this check seems to be wrong?

const (
// FlattenModeNever indicates that the image should never be flattened.
FlattenModeNever FlattenMode = "never"
// FlattenModeForce indicates that the image with parent should definitely
Copy link
Collaborator

Choose a reason for hiding this comment

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

FlattenModeForce indicates that the image with the parent must be flattened

// if the flattenMode is FlattenModeForce, it flattens the image itself.
// if the parent image is in trash, it returns an error.
// if the parent image exists and is not enabled for mirroring, it returns an error.
func (rv *rbdVolume) HandleParentImage(
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we rename this to MirrorImageIfParentExists or something else as we are not handling the ParentImage rather we are flattening of the image only if the parent exists ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HandleParentImage can also be read as handling the cases where parent image may exist and the method to handle such parent depends.
Currently we either error out or flatten the live image.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we are acting/handling on the actual image not on the parent, IMO we don't handle anything in parentImage we are having few checks on it, the main idea is to flatten the main/live image. For me, it make sense to have something like MirrorImageIfParentExists and HandleParentImage looks to be generic and doesn't mention what exactly we are handing here. please feel free to rename to anything else that gives a sense of what we are doing in this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed it to HandleParentImageExistence to imply this function contains logic to handle existence of a parent
image

}

if flattenMode == FlattenModeForce {
err := rv.DeleteTempImage(ctx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add a comment why we are deleting the temporary clone here

Comment on lines 77 to 78
"failed to get mirroring info of parent %q of image %q: %w",
rv, parent, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"failed to get mirroring info of parent %q of image %q: %w",
rv, parent, err)
"failed to get mirroring info of parent %q of image %q: %w",
parent, rv, err)

rv, parent, err)
}

if parentMirroringInfo.State == librbd.MirrorImageEnabled {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if parentMirroringInfo.State == librbd.MirrorImageEnabled {
if parentMirroringInfo.State != librbd.MirrorImageEnabled {
fmt.Errorf("%w:failed to enable mirroring on image %q: "+
"parent image %q is not enabled for mirroring",
ErrFailedPrecondition, rv, parent)
}
return nil

@@ -703,6 +703,27 @@ func (ri *rbdImage) trashRemoveImage(ctx context.Context) error {
return nil
}

// DeleteTempImage deletes the temporary image created for pvc-pvc clone.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// DeleteTempImage deletes the temporary image created for pvc-pvc clone.
// DeleteTempImage deletes the temporary image created for volume datasource.

Comment on lines 717 to 718
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v",
tempClone, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not log here, dont pass the ctx and log it in caller if there is any error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lets not log here, dont pass the ctx and log it in caller if there is any error?

ctx is definitely required for other function calls in this function.
I'll move the log upwards.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it looks like its not addressed, can you please check this one again

Copy link
Collaborator

@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.

small nits, LGTM

case corerbd.FlattenModeForce, corerbd.FlattenModeNever:
return mode, nil
}
log.DebugLog(ctx, "%q=%q is not supported", flattenModeKey, val)
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets log it as in error message in caller not as debug here

// if the flattenMode is FlattenModeForce, it flattens the image itself.
// if the parent image is in trash, it returns an error.
// if the parent image exists and is not enabled for mirroring, it returns an error.
func (rv *rbdVolume) HandleParentImage(
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are acting/handling on the actual image not on the parent, IMO we don't handle anything in parentImage we are having few checks on it, the main idea is to flatten the main/live image. For me, it make sense to have something like MirrorImageIfParentExists and HandleParentImage looks to be generic and doesn't mention what exactly we are handing here. please feel free to rename to anything else that gives a sense of what we are doing in this function.

Comment on lines 57 to 59
log.ErrorLog(ctx, "failed to delete temporary rbd image: %v", err)

return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
log.ErrorLog(ctx, "failed to delete temporary rbd image: %v", err)
return err
return fmt.Errorf("failed to delete temporary rbd image: %w", err)

Comment on lines 712 to 714
err = tempClone.ensureImageCleanup(ctx)

return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
err = tempClone.ensureImageCleanup(ctx)
return err
return tempClone.ensureImageCleanup(ctx)

Comment on lines 717 to 718
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v",
tempClone, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

it looks like its not addressed, can you please check this one again

Copy link
Collaborator

@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

@Rakshith-R
Copy link
Contributor Author

@Mergifyio queue

Copy link
Contributor

mergify bot commented Jun 20, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at d166229

This commit adds support for flattenMode option
for replication.
If the flattenMode is set to "force" in
volumereplicationclass parameters, cephcsi will
add a task to flatten the image if it has parent.
This enable cephcsi to then mirror such images after
flattening them.
The error message when the image's parent is
in trash or unmirrored is improved as well.

Signed-off-by: Rakshith R <[email protected]>
@mergify mergify bot added the ok-to-test Label to trigger E2E tests label Jun 20, 2024
@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-cephfs

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-rbd

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.28

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.29

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.28

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.29

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.28

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.30

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.29

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.27

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.30

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.30

@ceph-csi-bot ceph-csi-bot removed the ok-to-test Label to trigger E2E tests label Jun 20, 2024
@mergify mergify bot merged commit d166229 into ceph:devel Jun 20, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/rbd Issues related to RBD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants