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: Do flattening only the temporary cloned images not the images given to user for mapping #2190

Closed
Madhu-1 opened this issue Jun 18, 2021 · 9 comments · Fixed by #2900
Closed
Assignees
Labels
component/rbd Issues related to RBD keepalive This label can be used to disable stale bot activiity in the repo Priority-0 highest priority issue question Further information is requested
Milestone

Comments

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Jun 18, 2021

In the case of CreateVolume from snapshot and CreateVolume from Volume, when the soft or hard limit is reached we do flattening on the image. and we need to ensure that we only flatten the intermediate clones we create not the volumes which might get mapped when the application mounts the PVC. flattening on the images can affect the read/write performance of the image due to some internal locking.

@Madhu-1 Madhu-1 added component/rbd Issues related to RBD question Further information is requested labels Jun 18, 2021
@Madhu-1
Copy link
Collaborator Author

Madhu-1 commented Jun 18, 2021

This needs some testing and may or may not code changes but it's good to validate this case.

@Madhu-1 Madhu-1 added the Priority-0 highest priority issue label Jun 18, 2021
@Madhu-1 Madhu-1 added this to the release-3.4.0 milestone Jun 22, 2021
@humblec
Copy link
Collaborator

humblec commented Jul 28, 2021

As discussed we have to continue the analysis and get into the completion in upcoming releases. Moving this out of 3.4.0 release.

@humblec humblec removed this from the release-3.4.0 milestone Jul 28, 2021
@Rakshith-R
Copy link
Contributor

In current implementation of CephCSI rbd driver, flattening is triggered for two reasons hitting snaps and CloneDepth limit:
Ceph CSI rbd processes(highly summarized):

  • k8s snapshot = PVC->snap->tmp-snap-img->snap
  • k8s PVC-restore= Snapshot's snap->clone-img
  • k8s PVC-PVC-clone= PVC -> snap->temp-clone-img->snap->clone-img

(snap refers to rbd image snapshot)

With respect to snap limit:

  • rbd image snap is taken during k8s snapshot and pvc-pvc cloning.
  • Thus flattening due to hitting snap limit can occur only on rbd temp image underlying snapshot and temp clone image underlying PVC-clone.

With respect to CloneDepth limit:
To be analysed.

Every k8s PVC's underlying image if it has a parent rbd image, it's either a k8s snapshot's image(PVC-restore) or temporary-clone image(PVC-PVC-clone).

@Rakshith-R
Copy link
Contributor

func (rv *rbdVolume) flattenCloneImage(ctx context.Context) error {
if rv.ThickProvision {
// thick-provisioned images do not need flattening
return nil
}
tempClone := rv.generateTempClone()
// reducing the limit for cloned images to make sure the limit is in range,
// If the intermediate clone reaches the depth we may need to return ABORT
// error message as it need to be flatten before continuing, this may leak
// omap entries and stale temporary snapshots in corner cases, if we reduce
// the limit and check for the depth of the parent image clain itself we
// can flatten the parent images before used to avoid the stale omap entries.
hardLimit := rbdHardMaxCloneDepth
softLimit := rbdSoftMaxCloneDepth
// choosing 2 so that we don't need to flatten the image in the request.
const depthToAvoidFlatten = 2
if rbdHardMaxCloneDepth > depthToAvoidFlatten {
hardLimit = rbdHardMaxCloneDepth - depthToAvoidFlatten
}
if rbdSoftMaxCloneDepth > depthToAvoidFlatten {
softLimit = rbdSoftMaxCloneDepth - depthToAvoidFlatten
}
err := tempClone.getImageInfo()
if err == nil {
return tempClone.flattenRbdImage(ctx, tempClone.conn.Creds, false, hardLimit, softLimit)
}
if !errors.Is(err, ErrImageNotFound) {
return err
}
return rv.flattenRbdImage(ctx, rv.conn.Creds, false, hardLimit, softLimit)
}

If a temporary clone does not exist for given image ,
we need to find the parent image here, which would be a rbd image image under k8s snapshot and flatten it instead.

@Madhu-1
Copy link
Collaborator Author

Madhu-1 commented Sep 3, 2021

func (rv *rbdVolume) flattenCloneImage(ctx context.Context) error {
if rv.ThickProvision {
// thick-provisioned images do not need flattening
return nil
}
tempClone := rv.generateTempClone()
// reducing the limit for cloned images to make sure the limit is in range,
// If the intermediate clone reaches the depth we may need to return ABORT
// error message as it need to be flatten before continuing, this may leak
// omap entries and stale temporary snapshots in corner cases, if we reduce
// the limit and check for the depth of the parent image clain itself we
// can flatten the parent images before used to avoid the stale omap entries.
hardLimit := rbdHardMaxCloneDepth
softLimit := rbdSoftMaxCloneDepth
// choosing 2 so that we don't need to flatten the image in the request.
const depthToAvoidFlatten = 2
if rbdHardMaxCloneDepth > depthToAvoidFlatten {
hardLimit = rbdHardMaxCloneDepth - depthToAvoidFlatten
}
if rbdSoftMaxCloneDepth > depthToAvoidFlatten {
softLimit = rbdSoftMaxCloneDepth - depthToAvoidFlatten
}
err := tempClone.getImageInfo()
if err == nil {
return tempClone.flattenRbdImage(ctx, tempClone.conn.Creds, false, hardLimit, softLimit)
}
if !errors.Is(err, ErrImageNotFound) {
return err
}
return rv.flattenRbdImage(ctx, rv.conn.Creds, false, hardLimit, softLimit)
}

If a temporary clone does not exist for a given image ,

In which case the temporary clone does not exists?

from PVC-PVC clone case both image and the temporary image will be deleted when we delete the image.

we need to find the parent image here, which would be a rbd image image under k8s snapshot and flatten it instead.

Yes, the snapshot needs to be flattened in case of PVC restoration from snapshot operation.

@Rakshith-R
Copy link
Contributor

In which case the temporary clone does not exists?

I meant ErrImageNotFound for temp clone -> for a snapshot restored parent PVC.

@github-actions
Copy link

github-actions bot commented Oct 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the wontfix This will not be worked on label Oct 3, 2021
@Rakshith-R Rakshith-R removed the wontfix This will not be worked on label Oct 4, 2021
@Madhu-1 Madhu-1 added the keepalive This label can be used to disable stale bot activiity in the repo label Oct 4, 2021
@humblec humblec added this to the release-3.6 milestone Jan 27, 2022
@Yuggupta27 Yuggupta27 self-assigned this Feb 2, 2022
@Rakshith-R
Copy link
Contributor

@Yuggupta27 , I was planning to work on this.
If you did understand the issue and the fix discussed above in the comments, then its fine
else let me know, I can continue and send a pr for this soon.

@Madhu-1 Madhu-1 assigned Rakshith-R and unassigned Yuggupta27 Feb 10, 2022
@Rakshith-R
Copy link
Contributor

if rbdSnap != nil {
err = rbdVol.flattenRbdImage(ctx, false, rbdHardMaxCloneDepth, rbdSoftMaxCloneDepth)
if err != nil {
log.ErrorLog(ctx, "failed to flatten image %s: %v", rbdVol, err)
return err
}

one more place where we are flattening the image which will be given to user for mapping.
The parent underlying snapshot image can be flattened instead.

Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Feb 28, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 1, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 10, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 11, 2022
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]>
ceph-csi-bot pushed a commit to Rakshith-R/ceph-csi that referenced this issue Mar 15, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 15, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 15, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 15, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 16, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 16, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 16, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 17, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 17, 2022
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]>
Rakshith-R added a commit to Rakshith-R/ceph-csi that referenced this issue Mar 18, 2022
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 mergify bot closed this as completed in #2900 Mar 18, 2022
mergify bot pushed a commit that referenced this issue Mar 18, 2022
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: #2190

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
component/rbd Issues related to RBD keepalive This label can be used to disable stale bot activiity in the repo Priority-0 highest priority issue question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants