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

cephfs: use shallow volumes for the ROX accessMode #3651

Merged
merged 1 commit into from
Feb 21, 2023
Merged

cephfs: use shallow volumes for the ROX accessMode #3651

merged 1 commit into from
Feb 21, 2023

Conversation

riya-singhal31
Copy link
Contributor

@riya-singhal31 riya-singhal31 commented Feb 7, 2023

this commit makes shallow volume as default feature for ROX volumes.

Signed-off-by: riya-singhal31 rsinghal@redhat.com

Fixes: #3603

@riya-singhal31 riya-singhal31 changed the title cephfs: use shallow volumes for the ROX accessMode [WIP]cephfs: use shallow volumes for the ROX accessMode Feb 7, 2023
@mergify mergify bot added the component/cephfs Issues related to CephFS label Feb 7, 2023
@@ -235,6 +235,7 @@ func NewVolumeOptions(
opts.Monitors = strings.Join(clusterData.Monitors, ",")
opts.SubvolumeGroup = clusterData.CephFS.SubvolumeGroup
opts.Owner = k8s.GetOwner(volOptions)
opts.BackingSnapshot = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will impact the volume creation for other access modes, the Request is to support backingSnapshot for only ROX modes. For other access modes, we should create a subvolume.

@@ -236,6 +236,16 @@ func NewVolumeOptions(
opts.SubvolumeGroup = clusterData.CephFS.SubvolumeGroup
opts.Owner = k8s.GetOwner(volOptions)

// backingSnapshot will be used only with read-only access modes
volCaps := req.GetVolumeCapabilities()
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this a helper function so that testing is easier?

    // default BackingSnapshot to true only for ReadOnly volume requests
    opt.BackingSnapshot = isVolumeCreateRO(req)
    ...
}

func isVolumeCreateRO(req *csi.CreateVolumeRequest) bool {
    ...
}

That way, you can add a unit test for isVolumeCreateRO(), document it's behaviour and reduce the complexity of NewVolumeOptions().

@@ -323,6 +325,19 @@ func NewVolumeOptions(
return &opts, nil
}

func isVolumeCreateRO(req *csi.CreateVolumeRequest) bool {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a unit-tests in internal/cephfs/store/volumeoptions_test.go for 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.

Yes, sure. I'll update the PR.

@@ -0,0 +1,82 @@
package store
Copy link
Member

Choose a reason for hiding this comment

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

please include the header as in other files in this directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated.

Comment on lines 238 to 239
// default BackingSnapshot to true only for ReadOnly volume requests
opts.BackingSnapshot = IsVolumeCreateRO(req.VolumeCapabilities)
Copy link
Contributor

Choose a reason for hiding this comment

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

The datasource needs to be a snapshot for this to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we are just specifying the value for backing snapshot based on the access mode of volume.
The data source should be handled by user, while creating the yaml of volume. right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Here we are just specifying the value for backing snapshot based on the access mode of volume. The data source should be handled by user, while creating the yaml of volume. right?

This will cause a error when data source is pvc.

We should default backingSnapshot option to true if the datasource is a snapshot and request is for a RO volume.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Rakshith, updated.

@riya-singhal31
Copy link
Contributor Author

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

@riya-singhal31 riya-singhal31 requested review from Rakshith-R and nixpanic and removed request for nixpanic and Rakshith-R February 15, 2023 09:37
return false
}

func IsDataSourceSnapshot(volumeSource *csi.VolumeContentSource) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

VolumeSource can itself be nil too,
for a bare createPVC, this can lead to a panic here

Comment on lines 1922 to 1924

// Deleting snapshot before deleting pvcClone should succeed. It will be
// deleted once all volumes that are backed by this snapshot are gone.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Deleting snapshot before deleting pvcClone should succeed. It will be
// deleted once all volumes that are backed by this snapshot are gone.

check snapshot count right after deletesnapshoy

@riya-singhal31
Copy link
Contributor Author

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

Rakshith-R
Rakshith-R previously approved these changes Feb 20, 2023
Copy link
Contributor

@Rakshith-R Rakshith-R left a comment

Choose a reason for hiding this comment

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

Thanks !

@Rakshith-R
Copy link
Contributor

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

@Rakshith-R Rakshith-R requested a review from a team February 20, 2023 09:54
@riya-singhal31 riya-singhal31 marked this pull request as ready for review February 20, 2023 10:06
Copy link
Contributor

@yati1998 yati1998 left a comment

Choose a reason for hiding this comment

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

@riya-singhal31 , just a small nit. else looks good to me.

@@ -1617,8 +1617,8 @@ var _ = Describe(cephfsType, func() {
if err != nil {
framework.Failf("failed to delete CephFS storageclass: %v", 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 this extra line required? IMO, you can remove this.

@riya-singhal31 riya-singhal31 changed the title [WIP]cephfs: use shallow volumes for the ROX accessMode cephfs: use shallow volumes for the ROX accessMode Feb 20, 2023
Madhu-1
Madhu-1 previously approved these changes Feb 20, 2023
@Rakshith-R
Copy link
Contributor

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Feb 20, 2023

⚠️ This pull request got rebased on behalf of a random user of the organization.
This behavior will change on the 1st February 2023, Mergify will pick the author of the pull request instead.

To get the future behavior now, you can configure bot_account options (e.g.: bot_account: { author } or update_bot_account: { author }.

Or you can create a dedicated github account for squash and rebase operations, and use it in different bot_account options.

@mergify
Copy link
Contributor

mergify bot commented Feb 20, 2023

rebase

✅ Branch has been successfully rebased

@Rakshith-R Rakshith-R added the ok-to-test Label to trigger E2E tests label Feb 20, 2023
@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

/test ci/centos/upgrade-tests-cephfs

@github-actions
Copy link

/test ci/centos/upgrade-tests-rbd

@github-actions github-actions bot removed the ok-to-test Label to trigger E2E tests label Feb 21, 2023
@mergify mergify bot added the ok-to-test Label to trigger E2E tests label Feb 21, 2023
@mergify mergify bot merged commit b28b5e6 into ceph:devel Feb 21, 2023
3 checks passed
@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

/test ci/centos/upgrade-tests-cephfs

@github-actions
Copy link

/test ci/centos/upgrade-tests-rbd

@github-actions github-actions bot removed the ok-to-test Label to trigger E2E tests label Feb 21, 2023
@@ -70,7 +70,7 @@ you're running it inside a k8s cluster and find the config itself).
| `pool` | no | Ceph pool into which volume data shall be stored |
| `volumeNamePrefix` | no | Prefix to use for naming subvolumes (defaults to `csi-vol-`). |
| `snapshotNamePrefix` | no | Prefix to use for naming snapshots (defaults to `csi-snap-`) |
| `backingSnapshot` | no | Boolean value. The PVC shall be backed by the CephFS snapshot specified in its data source. `pool` parameter must not be specified. (defaults to `false`) |
| `backingSnapshot` | no | Boolean value. The PVC shall be backed by the CephFS snapshot specified in its data source. `pool` parameter must not be specified. (defaults to `true`) |

Choose a reason for hiding this comment

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

@riya-singhal31 Here you say the default is true. However, I looked a bit at the code and it seems there are 3 options:

  • backingSnapshot is true, then the volume is backed by a snapshot or, if that's not possible, an error is returned.
  • backingSnapshot is false, then the volume is never backed by a snapshot.
  • backingSnapshot is not set, then the volume is backed by a snapshot if supported (i.e., IsShallowVolumeSupported(req) returns true.

Is my interpretation of the source code correct? If yes, then you cannot say that the default is true, because the default behavior deviates from the behavior in the true/false cases.

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/cephfs Issues related to CephFS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cephfs: use shallow volumes for the ROX accessModes
6 participants