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: flatten datasource image before creating volume #2900

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

Rakshith-R
Copy link
Contributor

@Rakshith-R Rakshith-R commented Feb 23, 2022

This commit encures that parent image is flattened before
creating volume.

  • If the data source is a PVC, the underlying image's parent
    is flattened(which would be a temp clone or snapshot).
    hard & soft limit is reduced by 2 to account for depth that
    will be added by temp & final clone.

  • If the data source is a Snapshot, the underlying image is
    itself flattened.
    hard & soft limit is reduced by 1 to account for depth that
    will be added by the clone which will be restored from the
    snapshot.

Flattening of resulting PVC image restored from snapshot is removed.
Flattening step for temp clone & final image is removed when pvc clone is
being created.

Fixes: #2190

Signed-off-by: Rakshith R [email protected]

@mergify mergify bot added the component/rbd Issues related to RBD label Feb 23, 2022
@Rakshith-R
Copy link
Contributor Author

/retest all

@Rakshith-R Rakshith-R force-pushed the fix-parent-flatten branch 4 times, most recently from d3c7ee0 to 5a01cfe Compare February 28, 2022 05:29
@Rakshith-R Rakshith-R marked this pull request as ready for review February 28, 2022 05:30
@Rakshith-R Rakshith-R requested review from Madhu-1, nixpanic and a team February 28, 2022 05:30
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.

@Rakshith-R have you tested this with hardlimit and softlimit of 1?

Comment on lines 339 to 340
hardLimit := rbdHardMaxCloneDepth
softLimit := rbdSoftMaxCloneDepth
Copy link
Collaborator

Choose a reason for hiding this comment

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

declare this outside of if statements as its common for both snapshot and volume

@@ -335,6 +359,29 @@ func flattenParentImage(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
return err
}
}
if rbdSnap != nil {
err := rbdSnap.Connect(cr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

where defer Destroy is called for this one?

if rbdSnap != nil {
err := rbdSnap.Connect(cr)
if err != nil {
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.

need to return grpc error?

@Rakshith-R Rakshith-R force-pushed the fix-parent-flatten branch from 5a01cfe to 265e59a Compare March 1, 2022 06:36
@Rakshith-R
Copy link
Contributor Author

@Rakshith-R have you tested this with hardlimit and softlimit of 1?

  • It will not affect the flattening at this stage according to this check, pre existing behaviour will continue.
		const depthToAvoidFlatten = 2 #1 for snapshot
		if rbdHardMaxCloneDepth > depthToAvoidFlatten {
			hardLimit = rbdHardMaxCloneDepth - depthToAvoidFlatten
		}
		if rbdSoftMaxCloneDepth > depthToAvoidFlatten {
			softLimit = rbdSoftMaxCloneDepth - depthToAvoidFlatten
		}
		
  • Flattening for the temporary clones and final image is being removed in this pr,
    Where the lower limit would have flattened intermediate clones(for clone) and final image(for snapshot) before the pr change.
    IMO, the above change(2nd) is fine since cephcsi is the one which decides when depth should be checked and flattening operation performed.

@Rakshith-R Rakshith-R requested a review from Madhu-1 March 1, 2022 06:49
@Rakshith-R
Copy link
Contributor Author

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2022

rebase

✅ Branch has been successfully rebased

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.

changes LGTM can you please set max limit RbdHardMaxCloneDepth to 2 here https://github.com/ceph/ceph-csi/blob/devel/scripts/install-helm.sh#L182 to test no stale are left behind?


// flattenParentImage flatten the given image's parent if it exists according to hard and soft
// limits.
func (ri *rbdImage) flattenParentImage(ctx context.Context, hardLimit, softLimit uint) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we already have flattenParentImage image in controllerserver. rename this to flattenParent?

@Rakshith-R
Copy link
Contributor Author

changes LGTM can you please set max limit RbdHardMaxCloneDepth to 2 here https://github.com/ceph/ceph-csi/blob/devel/scripts/install-helm.sh#L182 to test no stale are left behind?

@Madhu-1 , Due to #2327 , setting this lower depth will leave stale images.
That's why this option was not set earlier.

@Rakshith-R Rakshith-R requested a review from Madhu-1 March 11, 2022 10:44
@Rakshith-R
Copy link
Contributor Author

/retest all

@Rakshith-R Rakshith-R requested review from a team and removed request for nixpanic March 14, 2022 12:01
@Rakshith-R
Copy link
Contributor Author

@Mergifyio rebase
ptal @ceph/ceph-csi-contributors

@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2022

rebase

✅ Branch has been successfully rebased

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Mar 15, 2022

changes LGTM can you please set max limit RbdHardMaxCloneDepth to 2 here https://github.com/ceph/ceph-csi/blob/devel/scripts/install-helm.sh#L182 to test no stale are left behind?

@Madhu-1 , Due to #2327 , setting this lower depth will leave stale images. That's why this option was not set earlier.

Asked to make sure in any case there wont be any stale resources left behind

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, small nit

@Rakshith-R
Copy link
Contributor Author

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Mar 17, 2022

rebase

✅ Branch has been successfully rebased

@mergify
Copy link
Contributor

mergify bot commented Mar 17, 2022

refresh

✅ Pull request refreshed

@github-actions
Copy link

/retest ci/centos/mini-e2e/k8s-1.21

@github-actions
Copy link

@Rakshith-R "ci/centos/mini-e2e/k8s-1.21" test failed. Logs are available at location for debugging

@github-actions
Copy link

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Mar 17, 2022

@github-actions[bot] is not allowed to run commands

@Rakshith-R
Copy link
Contributor Author

/retest ci/centos/upgrade-tests-rbd

@Rakshith-R
Copy link
Contributor Author

/retest ci/centos/k8s-e2e-external-storage/1.23

@Rakshith-R
Copy link
Contributor Author

@Rakshith-R
Copy link
Contributor Author

@Mergifyio rebase

This commit ensures that parent image is flattened before
creating volume.
- If the data source is a PVC, the underlying image's parent
  is flattened(which would be a temp clone or snapshot).
  hard & soft limit is reduced by 2 to account for depth that
  will be added by temp & final clone.

- If the data source is a Snapshot, the underlying image is
  itself flattened.
  hard & soft limit is reduced by 1 to account for depth that
  will be added by the clone which will be restored from the
  snapshot.

Flattening step for resulting PVC image restored from snapshot is removed.
Flattening step for temp clone & final image is removed when pvc clone is
being created.

Fixes: ceph#2190

Signed-off-by: Rakshith R <[email protected]>
@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2022

rebase

✅ Branch has been successfully rebased

@ceph-csi-bot
Copy link
Collaborator

/retest ci/centos/k8s-e2e-external-storage/1.22

@ceph-csi-bot
Copy link
Collaborator

@Rakshith-R "ci/centos/k8s-e2e-external-storage/1.22" test failed. Logs are available at location for debugging

@ceph-csi-bot
Copy link
Collaborator

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2022

refresh

✅ Pull request refreshed

@ceph-csi-bot
Copy link
Collaborator

/retest ci/centos/mini-e2e/k8s-1.22

@ceph-csi-bot
Copy link
Collaborator

@Rakshith-R "ci/centos/mini-e2e/k8s-1.22" test failed. Logs are available at location for debugging

@ceph-csi-bot
Copy link
Collaborator

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2022

refresh

✅ Pull request refreshed

@mergify mergify bot merged commit a56f9a0 into ceph:devel Mar 18, 2022
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this pull request Nov 14, 2024
CephCSI should not flatten image that can be mounted
for use by the user.
`checkFlatten()` was called in a recovery code flow
of PVC restored from snapshot and was missed while
refractoring in ceph#2900

refer: ceph#2900

Signed-off-by: Rakshith R <[email protected]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this pull request Nov 14, 2024
CephCSI should not flatten image that can be mounted
for use by the user.
`checkFlatten()` was called in a recovery code flow
of PVC restored from snapshot and was missed while
refractoring in ceph#2900

refer: ceph#2900

Signed-off-by: Rakshith R <[email protected]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this pull request Nov 19, 2024
CephCSI should not flatten image that can be mounted
for use by the user.
`checkFlatten()` was called in a recovery code flow
of PVC restored from snapshot and was missed while
refractoring in ceph#2900

refer: ceph#2900

Signed-off-by: Rakshith R <[email protected]>
mergify bot pushed a commit that referenced this pull request Nov 19, 2024
CephCSI should not flatten image that can be mounted
for use by the user.
`checkFlatten()` was called in a recovery code flow
of PVC restored from snapshot and was missed while
refractoring in #2900

refer: #2900

Signed-off-by: Rakshith R <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/retry/e2e Label to retry e2e retesting on approved PR's component/rbd Issues related to RBD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RBD: Do flattening only the temporary cloned images not the images given to user for mapping
4 participants