-
Notifications
You must be signed in to change notification settings - Fork 559
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
Conversation
@@ -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 |
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 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() |
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.
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 { |
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.
can you add a unit-tests in internal/cephfs/store/volumeoptions_test.go
for this function?
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.
Yes, sure. I'll update the PR.
@@ -0,0 +1,82 @@ | |||
package store |
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.
please include the header as in other files in this directory
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, updated.
// default BackingSnapshot to true only for ReadOnly volume requests | ||
opts.BackingSnapshot = IsVolumeCreateRO(req.VolumeCapabilities) |
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.
The datasource needs to be a snapshot for this to work.
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.
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?
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.
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.
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 Rakshith, updated.
/test ci/centos/mini-e2e-helm/k8s-1.26 |
return false | ||
} | ||
|
||
func IsDataSourceSnapshot(volumeSource *csi.VolumeContentSource) bool { |
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.
VolumeSource can itself be nil too,
for a bare createPVC, this can lead to a panic here
|
||
// Deleting snapshot before deleting pvcClone should succeed. It will be | ||
// deleted once all volumes that are backed by this snapshot are gone. |
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.
// 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
/test ci/centos/mini-e2e-helm/k8s-1.26 |
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 !
/test ci/centos/mini-e2e-helm/k8s-1.25 |
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.
@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) | |||
} | |||
|
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.
Is this extra line required? IMO, you can remove this.
@Mergifyio rebase |
To get the future behavior now, you can configure Or you can create a dedicated github account for squash and rebase operations, and use it in different |
✅ Branch has been successfully rebased |
/test ci/centos/k8s-e2e-external-storage/1.23 |
/test ci/centos/k8s-e2e-external-storage/1.26 |
/test ci/centos/mini-e2e-helm/k8s-1.23 |
/test ci/centos/mini-e2e-helm/k8s-1.24 |
/test ci/centos/mini-e2e-helm/k8s-1.25 |
/test ci/centos/mini-e2e-helm/k8s-1.26 |
/test ci/centos/mini-e2e/k8s-1.23 |
/test ci/centos/mini-e2e/k8s-1.24 |
/test ci/centos/mini-e2e/k8s-1.25 |
/test ci/centos/mini-e2e/k8s-1.26 |
/test ci/centos/upgrade-tests-cephfs |
/test ci/centos/upgrade-tests-rbd |
/test ci/centos/k8s-e2e-external-storage/1.23 |
/test ci/centos/k8s-e2e-external-storage/1.24 |
/test ci/centos/k8s-e2e-external-storage/1.25 |
/test ci/centos/k8s-e2e-external-storage/1.26 |
/test ci/centos/mini-e2e-helm/k8s-1.23 |
/test ci/centos/mini-e2e-helm/k8s-1.24 |
/test ci/centos/mini-e2e-helm/k8s-1.25 |
/test ci/centos/mini-e2e-helm/k8s-1.26 |
/test ci/centos/mini-e2e/k8s-1.23 |
/test ci/centos/mini-e2e/k8s-1.24 |
/test ci/centos/mini-e2e/k8s-1.25 |
/test ci/centos/mini-e2e/k8s-1.26 |
/test ci/centos/upgrade-tests-cephfs |
/test ci/centos/upgrade-tests-rbd |
@@ -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`) | |
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.
@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
istrue
, then the volume is backed by a snapshot or, if that's not possible, an error is returned.backingSnapshot
isfalse
, 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.
this commit makes shallow volume as default feature for ROX volumes.
Signed-off-by: riya-singhal31 [email protected]
Fixes: #3603