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

csi: option to customize csi driver name prefix #13622

Merged
merged 1 commit into from Jan 29, 2024

Conversation

Madhu-1
Copy link
Member

@Madhu-1 Madhu-1 commented Jan 25, 2024

For now, we are using the operator namespace name as the prefix for the csi driver, This PR provides an option for the users if someone wants to have their prefix for the csi driver, if someone tries to change the prefix for existing csi driver rook operator will fail to reconcile the csi driver. If the option is not set the default behavior will continue as it is where the operator namespace will be used as a prefix for the csi driver name(s).

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 minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Copy link
Contributor

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

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

typo diver instead of driver in the commit message and PR description.

failing CI test could be a flake.

@@ -320,5 +320,8 @@ func (r *ReconcileCSI) setParams(ver *version.Info) error {
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_NFS_ATTACH_REQUIRED", "true"), "false") {
CSIParam.NFSAttachRequired = false
}

CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", "")
Copy link
Member

Choose a reason for hiding this comment

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

Can we just default to the operator namespace here?

Suggested change
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", "")
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", r.opConfig.OperatorNamespace)

}

// If the driver name prefix is not set, set it to the operator namespace.
if tp.DriverNamePrefix == "" {
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed if we set the default as mentioned previously

}

if EnableRBD {
rbdDriverNamePrefix, err := getCSIDriverNamePrefixFromDeployment(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, csiRBDProvisioner, "csi-rbdplugin")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of checking all three deployments, can we just check one of them? Either they will all succeed, or they will all fail, so we shouldn't need to check all three.

Copy link
Member Author

Choose a reason for hiding this comment

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

@travisn i added all 3 to ensure that we are good for all the 3 drivers because there are cases where either 1 is a disabled case. please let me know if you still prefer to check for only one, if its it should be rbd or cephfs?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking let's check the first one that is enabled, then we can skip checking the others. If these checks are moved out to a helper method it will be simple to implement by returning after the first enabled one is checked.

deploy/examples/operator.yaml Show resolved Hide resolved
@BlaineEXE
Copy link
Member

BlaineEXE commented Jan 25, 2024

Is this a commonly-requested feature? TBH, I think the overall simplicity of using the operator namespace as the prefix is good. It means that we don't need to document any special "if you did this, then this example changes", etc. etc. etc.

Being able to provide a simple "this is the way to do this" is a big win for users overall, IMO.

Also consider that if any users decide to do this and they use the cluster helm chart, they will probably complain about their storageclasses not being generated right.

If users are having a problem with the generated name being too long, would it be sufficient to provide an example for how to change the namespace that Rook is installed in instead?

@Madhu-1
Copy link
Member Author

Madhu-1 commented Jan 26, 2024

Is this a commonly-requested feature? TBH, I think the overall simplicity of using the operator namespace as the prefix is good. It means that we don't need to document any special "if you did this, then this example changes", etc. etc. etc.

This is not a commonly-requested feature but it is kind of really required if someone doesn't want a dynamic CSI driver name changes based on the namespace where Rook is deployed.

Being able to provide a simple "this is the way to do this" is a big win for users overall, IMO.

Also consider that if any users decide to do this and they use the cluster helm chart, they will probably complain about their storageclasses not being generated right.

I didn't consider this case because i did search only in the .go file.

If users are having a problem with the generated name being too long, would it be sufficient to provide an example for how to change the namespace that Rook is installed in instead?

The problem is not with the namespace name length (but it could also be one reason) but the main problem is with dynamic csi driver names as i mentioned above.

@Madhu-1 Madhu-1 force-pushed the csi-name-prefix branch 2 times, most recently from e7a8833 to 66b9525 Compare January 26, 2024 10:52
@Madhu-1 Madhu-1 requested a review from travisn January 26, 2024 10:52
@Madhu-1 Madhu-1 force-pushed the csi-name-prefix branch 2 times, most recently from bfaaf3c to 3bdd341 Compare January 26, 2024 10:58
`my-prefix.nfs.csi.ceph.com`.

!!! note
Please be careful when setting the `CSI_DRIVER_NAME_PREFIX`
Copy link
Member

Choose a reason for hiding this comment

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

May need indentation of 4 spaces for the paragraph to get the rendered docs correctly

...
```

Please note that for the RBD driver, the prefix will be
Copy link
Member

Choose a reason for hiding this comment

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

How about a bullet list?

Suggested change
Please note that for the RBD driver, the prefix will be
When the prefix is set, the driver names will be:
- RBD: `my-prefix.rbd.csi.ceph.com`
- CephFS: ...
- NFS: ...

...
```

Same prefix must be set in the volumesnapshotclass as well:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Same prefix must be set in the volumesnapshotclass as well:
The same prefix must be set in the volumesnapshotclass as well:

@@ -35,6 +35,52 @@ example, if the Rook operator is running in the namespace `my-namespace` the
provisioner value should be `my-namespace.rbd.csi.ceph.com`. The same provisioner
name must be set in both the storageclass and snapshotclass.

## Configure custom Driver name prefix for CSI Drivers

To use a custom prefix for the CSI drivers, you need to set the
Copy link
Member

Choose a reason for hiding this comment

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

Let's mention that the namespace is the default prefix

Suggested change
To use a custom prefix for the CSI drivers, you need to set the
To use a custom prefix for the CSI drivers instead of the namespace prefix, set the


To use a custom prefix for the CSI drivers, you need to set the
`CSI_DRIVER_NAME_PREFIX` environment variable in the operator configmap. For
instance, to use the prefix `my-prefix` for the CSI drivers, you can set the
Copy link
Member

Choose a reason for hiding this comment

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

Don't say "you" in the documentation, just use the command form to be more direct.

Suggested change
instance, to use the prefix `my-prefix` for the CSI drivers, you can set the
instance, to use the prefix `my-prefix` for the CSI drivers, set the


Once the configmap is updated, the CSI drivers will be deployed with the
`my-prefix` prefix. You must set the same prefix in both the storageclass and
snapshotclass. For example, if you want to use the prefix `my-prefix` for the
Copy link
Member

Choose a reason for hiding this comment

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

There are a few other places to change, I won't mention them all

Suggested change
snapshotclass. For example, if you want to use the prefix `my-prefix` for the
snapshotclass. For example, to use the prefix `my-prefix` for the

deploy/charts/rook-ceph-cluster/values.yaml Show resolved Hide resolved
pkg/operator/ceph/csi/spec.go Show resolved Hide resolved
}

if EnableRBD {
rbdDriverNamePrefix, err := getCSIDriverNamePrefixFromDeployment(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, csiRBDProvisioner, "csi-rbdplugin")
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking let's check the first one that is enabled, then we can skip checking the others. If these checks are moved out to a helper method it will be simple to implement by returning after the first enabled one is checked.

deploy/examples/operator.yaml Show resolved Hide resolved
@BlaineEXE
Copy link
Member

Is this a commonly-requested feature? TBH, I think the overall simplicity of using the operator namespace as the prefix is good. It means that we don't need to document any special "if you did this, then this example changes", etc. etc. etc.

This is not a commonly-requested feature but it is kind of really required if someone doesn't want a dynamic CSI driver name changes based on the namespace where Rook is deployed.

If users are having a problem with the generated name being too long, would it be sufficient to provide an example for how to change the namespace that Rook is installed in instead?

The problem is not with the namespace name length (but it could also be one reason) but the main problem is with dynamic csi driver names as i mentioned above.

I still don't understand why dynamic CSI driver names are an issue. If users aren't complaining of this, it seems like an extra amount of complexity to continue maintaining when we don't need to.

@Madhu-1
Copy link
Member Author

Madhu-1 commented Jan 26, 2024

Is this a commonly-requested feature? TBH, I think the overall simplicity of using the operator namespace as the prefix is good. It means that we don't need to document any special "if you did this, then this example changes", etc. etc. etc.

This is not a commonly-requested feature but it is kind of really required if someone doesn't want a dynamic CSI driver name changes based on the namespace where Rook is deployed.

If users are having a problem with the generated name being too long, would it be sufficient to provide an example for how to change the namespace that Rook is installed in instead?

The problem is not with the namespace name length (but it could also be one reason) but the main problem is with dynamic csi driver names as i mentioned above.

I still don't understand why dynamic CSI driver names are an issue. If users aren't complaining of this, it seems like an extra amount of complexity to continue maintaining when we don't need to.

dynamic csi driver name is an issue because it's not expected to change the csi driver names based on the deployment namespaces just for example kubervirt always expects the csi driver name to be consistent because it provides the best option to the users based on the hardcoded driver names. This option is getting added to ensure that we can be backward compatible and also open an option to allow user(s) always to set the static driver names in their cluster.

--- update ---

https://github.com/kubevirt/containerized-data-importer/blob/0b4ebe81af353d2611344ac8cfef64cc1c4d58ad/pkg/storagecapabilities/storagecapabilities.go#L43 One example where it's having hardcoded values. after discussing more with the kubevirt team (internally) it's suggested that it's not expected to change the driver names based on the namespace name because the names are the representation of the csi driver it should not get changed dynamically because no one can predict the names in dynamic cases.

-e "s/\(.*\): [-_A-Za-z0-9]*\.\(.*\) # driver:namespace:cluster/\1: $ROOK_CLUSTER_NAMESPACE.\2 # driver:namespace:cluster/g" \
common.yaml operator.yaml cluster.yaml # add other files or change these as desired for your config

# You need to use `apply` for all Ceph clusters after the first if you have only one Operator
kubectl apply -f common.yaml -f operator.yaml -f cluster.yaml # add other files as desired for yourconfig
```

Refer to the CSI driver
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Refer to the CSI driver
Also see the CSI driver

-e "s/\(.*\): [-_A-Za-z0-9]*\.\(.*\) # driver:namespace:cluster/\1: $ROOK_CLUSTER_NAMESPACE.\2 # driver:namespace:cluster/g" \
common.yaml operator.yaml cluster.yaml # add other files or change these as desired for your config

# You need to use `apply` for all Ceph clusters after the first if you have only one Operator
kubectl apply -f common.yaml -f operator.yaml -f cluster.yaml # add other files as desired for yourconfig
```

Refer to the CSI driver
[documentation](../Ceph-CSI/ceph-csi-drivers.md#Configure-CSI-Drivers-in-non-default-namespace)
to update examples to use a non-default namespace.
Copy link
Member

Choose a reason for hiding this comment

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

How about more specific?

Suggested change
to update examples to use a non-default namespace.
to update the csi provisioner names in the storage class.

@@ -35,6 +35,87 @@ example, if the Rook operator is running in the namespace `my-namespace` the
provisioner value should be `my-namespace.rbd.csi.ceph.com`. The same provisioner
name must be set in both the storageclass and snapshotclass.

search for `# csi-provisioner-name` in the [csi
Copy link
Member

Choose a reason for hiding this comment

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

The docs actually cannot use a relative path to the code because the docs are generated to a different site. I'd suggest no need for a link, we can have a simple comment like this:

Suggested change
search for `# csi-provisioner-name` in the [csi
To find the provisioner name in the example storage classes, search for: `# csi-provisioner-name`

example](../deploy/examples/csi/) folder and update the name of the
`provisioner`/`driver` as required.

The following `sed` command can be used to update the provisioner name in the
Copy link
Member

Choose a reason for hiding this comment

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

In the interest of simple docs, I'd suggest not even including this example. Maintaining this sed will be difficult too.

Once the configmap is updated, the CSI drivers will be deployed with the
`my-prefix` prefix. The same prefix must be set in both the storageclass and
snapshotclass. For example, to use the prefix `my-prefix` for the
CSI drivers, you can set the following in the storageclass:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
CSI drivers, you can set the following in the storageclass:
CSI drivers, update the provisioner in the storageclass:

environment variable. It should be done only in fresh deployments because
changing the prefix in an existing cluster will result in unexpected behavior.

search for `# csi-provisioner-name` in the [csi
Copy link
Member

Choose a reason for hiding this comment

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

Same suggestions as above for this section

# The prefix of the driver name can be configured by updating
# CSI_DRIVER_NAME_PREFIX in the rook-ceph-operator-config configmap by default
# it is namespace name where rook operator is running i.e rook-ceph.
driver: .cephfs.csi.ceph.com # csi-provisioner-name
Copy link
Member

Choose a reason for hiding this comment

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

We still need to keep the default rook-ceph prefix there. And actually I'm thinking we don't need lines 6-8 documented in every storage class. It's not going to be a common scenario to update the storage class, so they can just use the documentation topic, and no need to document here. If we just have the # csi-provisioner-name tag, then they can easily search where to update it.

Copy link
Member Author

Choose a reason for hiding this comment

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

i think while doing testing the rook-ceph got removed, brought it back and removed extra text as well

deploy/examples/operator.yaml Show resolved Hide resolved
pkg/operator/ceph/csi/spec.go Show resolved Hide resolved
To find the provisioner name in the example storageclasses and
volumesnapshotclass, search for: `# csi-provisioner-name`

## Configure custom Driver name prefix for CSI Drivers
Copy link
Member

Choose a reason for hiding this comment

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

This section seems like it needs to be combined with the previous section. How about making it a subsection?

Suggested change
## Configure custom Driver name prefix for CSI Drivers
### Configure custom Driver name prefix for CSI Drivers

pkg/operator/ceph/csi/spec.go Show resolved Hide resolved
if rbdDriverNamePrefix != "" && rbdDriverNamePrefix != driverNamePrefix {
return errors.Errorf("rbd driver already exists with prefix %q, cannot use prefix %q", rbdDriverNamePrefix, driverNamePrefix)
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

If the driver was not found, looks like this will return here instead of checking the next driver. If no prefix was found, shall we check the next driver?

Copy link
Member Author

Choose a reason for hiding this comment

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

i missed that case, move the check as required, this should cover both cases now. Thanks

For now we are using the operator namespace name
as the prefix for the csi driver, This PR provides
an option for the users if someone wants to have
their own prefix for the csi driver, if someone tries
to change the prefix for existing csi driver rook
operator will fail to reconcile the csi driver.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

CI issues look unrelated

Copy link
Contributor

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

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

The change looks good and clean now. pylint test is failing but this has to be unrelated since no python code is changed.

@travisn travisn merged commit 3b1a428 into rook:master Jan 29, 2024
49 of 50 checks passed
travisn added a commit that referenced this pull request Jan 31, 2024
csi: option to customize csi driver name prefix (backport #13622)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants