Commit Graph
45 Commits
Author SHA1 Message Date
subhamkrai 3b7a7b8958 csi: delete csi operator CR's when disabled
this commit deletes csi operator CR's when
user wants to revert back to csi driver for
some reasons. This commits deletes CR's like
`clientProfile, cephConnection, driver,
operatorConfig, and clientProfileMapping`.

Signed-off-by: subhamkrai <srai@redhat.com>
2025-08-29 15:38:20 +05:30
Travis Nielsen b2b28e1280 csi: set csi operator as default if no settings found
If the ROOK_USE_CSI_OPERATOR setting is not found in the
rook-ceph-operator-config configmap, the default now
is to use the csi operator instead of the previous
csi driver

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2025-08-28 12:26:28 -06:00
Travis Nielsen 7b2dfdba17 Merge pull request #16150 from OdedViner/log_panics_controller
core: log panics in controller reconcile functions
2025-07-29 09:59:27 -06:00
Oded Viner cf13deee6f core: log panics in controller reconcile functions
add RecoverAndLogException() helper to log panics with stack trace.
added defer call in all rook controller Reconcile() methods for
better error visibility in operator logs

Signed-off-by: Oded Viner <oviner@redhat.com>
2025-07-29 13:20:38 +03:00
subhamkrai 6df727b91a csi: update csi-operator yaml to v1
this commit updates the csi-operator complete deployment
file csi-operator.yaml to v1 from v1alpha1.

Signed-off-by: subhamkrai <srai@redhat.com>
2025-07-23 21:02:59 +05:30
Oded Viner 0a9100be83 csi: delete rook-ceph-csi-config if csi operator is enabled
removes the rook-ceph-csi-config configmap when
switching to external csi operator

Signed-off-by: Oded Viner <oviner@redhat.com>
2025-06-15 12:48:24 +03:00
Joshua Hoblitt 9f1ed201db core: typed watch handlers and predicates
All existing controller runtime watches are converted to use "typed"
handlers and predicates instead of operating on `client.Object`.  The
intent is to be bug for bug equivalent with the existing logic while
replacing run time type assertions and switch statements with compile
time type constraints and type casts. In several cases, functions using
assertions were split up such that each function only handles a single
Kind at a time. It is hoped that this will improve readability and
maintainability while facilitating future refactoring such as migrating
some watches to using IndexFields.

Of particular note is that the massive switch statement in
`WatchControllerPredicate()`  from
`pkg/operator/ceph/controller/predicate.go` has been replaced with
generics, reflection, and splitting the obc logic into its own predicate
function. There are still many helper functions operating on
`client.Object`. These were not updated unless required by the compiler
in order to limit the size of this change. The type safety of these
funcs should be improved as followup work.

 It is strongly suggested that going forward, handlers and predicates
 only handle a single Kind (generic or not) and that switches / type
 assertions are heavily discouraged or forbidden. This PR removed all
 but a single switch statement in a predicate, which should be addressed
 in future work.

Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
2025-04-04 09:40:56 -07:00
Travis NielsenandDmitry Mishin d109dc9029 core: implement operator settings as env vars
The operator settings loaded from the configmap have proven
inefficient for load time and frequently checking the configmap.
To avoid this ineffenciency, the configmap is only loaded once
each time it is created or updated. The values in the configmap
are applied as environment variables, which then are very efficient
to query throughout the various controllers, without needing
to be concerned about loading the configmap again.

Co-authored-by: Dmitry Mishin <dmitry.mishin@gmail.com>
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2025-02-24 12:12:45 -07:00
Travis Nielsen 2ff429e479 csi: remove version check for k8s and cephcsi
The version checks for the csi driver are removed now
since they are all obsolete. The K8s version and cephcsi
versions are no longer checked. Anyway, the move to the
csi operator would take ownership of version checks
needed in the future, so for now we simplify rook
deployment of the csi driver.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2024-10-30 14:03:51 -06:00
Blaine Gardner 5539eedd1b multus: finish deprecating holder pods
Finish the process of deprecating holder pods by removing Rook's ability
to deploy them. The intent of this change is to make the most
superficial changes possible to accomplish this. There are still
remnants of code in Rook (particularly the CSI controller) that helped
configure or deploy holder pods. Due to the risk of breaking some
features, cleanup work of hose remnants will be deferred for future
work.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
2024-10-23 16:29:02 -06:00
parth-gr 166e4f35b2 csi: fix the disable driver flag in the csi driver reconcile
ROOK_CSI_DISABLE_DRIVER was not working accurate
from https://github.com/rook/rook/pull/14489
The csi driver was installed even if its not
expected

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-09-20 20:30:17 +05:30
subhamkrai a16ad75c92 csi: stop deleting csi-operator resources
to keep it simple we'll not delete the csi-operator resources
we'll only document this for users who want to switch to csi-drivers.
Anyways by next release we'll only support csi-operator only.

Signed-off-by: subhamkrai <srai@redhat.com>
2024-09-08 10:57:53 +05:30
Blaine Gardner 679ccc762d Merge pull request #14576 from travisn/version-detect-annotation
core: Add annotations and labels to detect version jobs
2024-08-16 10:03:41 -06:00
Madhu Rajanna 123025f22c csi: update csi-addons to v0.9.0
As we have new csi-addons v0.9.0
updating the same here as well.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2024-08-16 07:57:16 +02:00
Travis Nielsen 5014d5bcf2 core: add annotations and labels to detect version jobs
The jobs to detect the ceph and csi versions now can have
custom annotationso and labels added to them. They are
very short-lived jobs, but they may need custom annotations
in some environments to run.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2024-08-15 16:48:28 -06:00
subhamkrai 1ad20d07e7 csi: add csi-operator operator config cr
Signed-off-by: subhamkrai <srai@redhat.com>
2024-08-08 11:21:49 +05:30
subhamkrai 4b0b3a55d9 csi: add code for new CSI operator CR cephcluster
adding code changes,rbac changes required for create the new
Ceph-CSI operator CR named cephCluster in api group 'csi.ceph.io'.

Signed-off-by: subhamkrai <srai@redhat.com>
2024-08-08 11:21:45 +05:30
parth-gr 4ca8b12e12 csi: add log rotation for csi cephfs nfs pod containers
Use the same logrotate flow of rbd, as merged in #14305

1) Make the csi cephfs and nfs container logs persisted in a file

2) Use the cephcluster api specs to configure the log rotate

3) Add log rotation to rotate the log file and
Add a sidecar log collector container

And some fixes on the implementation:

1) Add a operator namespace in the log file path

2) Only add volume to the container if logrotate is enabled

Closes: https://github.com/rook/rook/issues/12809, https://github.com/rook/rook/issues/14429

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-07-12 12:50:35 +05:30
Travis Nielsen b8bcd71929 Merge pull request #14421 from subhamkrai/update-go-mods
build: update controller runtime to v0.18.4
2024-07-08 10:10:10 -06:00
parth-gr 2ca0d1390b csi: add securityContext to csi containers
With the recent enhancements csi containers for using
logrotate, they need to run with securityContext to privileged,
on platform like openshift.
Used the ROOK_HOSTPATH_REQUIRES_PRIVILEGED flag
wich is set with operator deployment to see
if the securityCOntext is needed or not

Closes: https://github.com/rook/rook/issues/14400

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-07-08 18:47:26 +05:30
subhamkrai d429ed8be4 build: update controller runtime to v0.18.4
this commit update cntrl runtime to v0.18.4 and other related deps/

Signed-off-by: subhamkrai <srai@redhat.com>
2024-07-05 09:05:12 +05:30
parth-gr d3742119b9 csi: add log rotation for csi rbd pod containers
1) Make the csi rbd container logs persisted in a file
   (csi plugin, csi provisioner, csi addons sidecar)

2) Use the cephcluster api specs to configure the log rotate

3) Add log rotation to rotate the log file and
   Add a sidecar log collector container

part-of: https://github.com/rook/rook/issues/12809

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-06-27 14:20:18 +05:30
parth-gr 47ed6a8632 csi: create csi configmap if csi controller is disabled
Creating a cluster never succeeds if CSI driver is disabled
So to fix that we need to always create the csi configmap

closes: https://github.com/rook/rook/issues/14123

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-04-24 18:06:09 +05:30
Blaine Gardner eb3278d575 csi: only create CSI config configmap in CSI reconciler
There have been some issues with non-CSI Rook controllers that are
creating the CSI config configmap (`rook-ceph-csi-config`). This causes
problems with the K8s OwnerReference. The primary CSI reconciler
(controller) creates the configmap with the correct owner reference,
which is supposed to be the operator deployment.

Other instances were creating the configmap with owner references set to
the CephCluster. This is a minor bug, but it can result in this
configmap being deleted along with the first CephCluster that initially
created it.

To fix this issue, remove all instances of `CreateCsiConfigMap()` except
the single usage which the CSI reconcile uses to initially create the
configmap. Other controllers that might have attempted to create this
configmap previously will return an error indicating that it is waiting
for the configmap to be created.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
2024-04-18 12:22:00 -06:00
parth-gr a72e029459 csi: add a new flag to disable csi driver
added a new flag ROOK_CSI_DISABLE_DRIVER
to disable csi controller.

Signed-off-by: parth-gr <partharora1010@gmail.com>
2024-03-22 18:22:51 +05:30
Blaine Gardner 4f555dbbcb csi: allow force disabling holder pods
Add new CSI_DISABLE_HOLDER_PODS option for rook-ceph-operator.
This option will disable holder pods when set to "true".

In the long term, Rook plans to deprecate the holder pods entirely.
This new option will allow users to choose to migrate their clusters to
non-holder clusters when they are ready and able, giving them time to
gracefully migrate before the holders are permanently removed.

This option is set to "false" by default so that upgrading users don't
have their CSI pods modified unexpectedly.
Example manifests are modified to set this value to true so that new
clusters will not deploy holder pods.

Migrating users are provided with documentation to instruct them about
the new requirements they need to satisfy to successfully remove holder
pods, a procedure for migrating pods from holder to non-holder mounts,
and a way to delete holder pods once they are no longer in use.

When users set CSI_DISABLE_HOLDER_PODS="true", the CSI controller will
no longer deploy or update the holder pod Daemonsets, but it does not
delete any existing Daemonsets. This allows already-attached PVCs to
continue operating normally with their network connection continuing to
exist in the current holder pod. This is critical to avoid causing
ia cluster-wide storage outage.

More info: https://github.com/rook/rook/issues/13055

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
2024-03-14 09:53:08 -06:00
travisn 6f8e42422d core: fix golang linter issues with variables in loops
Loop variables cannot be reliably uses since they will
change with each iteration. Update these loop variable
uses to be safe by indexing the slice rather than
using the loop variable directly.

Also suppress the linter issues for passwords used
in tests.

Signed-off-by: travisn <tnielsen@redhat.com>
2023-12-05 14:14:58 -07:00
parth-gr f007f2aca1 core: report node metrics using ceph telemetry
Add this reporting with the cephcluster reconcile,
Similar way we reported other telemetry's

Closes: https://github.com/rook/rook/issues/12344

Signed-off-by: parth-gr <paarora@redhat.com>
2023-11-16 19:13:22 +05:30
subhamkrai a755ec156a csi: enable csi-addons-side when crds are deployed
when deploying csi, we'll check if csi-addons crds
are deployed we'll enable csi-addons sidecar by default.

Signed-off-by: subhamkrai <srai@redhat.com>
2023-08-31 11:28:49 +05:30
Madhu Rajanna d7a4f0038c csi: set ceph cluster as ControllerRef for holder
Setting ceph cluster as the ControllerRef
for the holder daemonset set so that when
a ceph cluster is deleted the holder daemoset
will also gets deleted.

fixes: #12645

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2023-08-22 10:41:17 +02:00
travisn 557a3e06cc core: api updates for controller runtime v0.15
For the controller runtime v0.15 there are some breaking
changes to the api that need to be updated.

Signed-off-by: travisn <tnielsen@redhat.com>
2023-06-22 10:33:28 -06:00
parth-gr 26584fc6e5 core: update loadclusterInfo with multus check
if Multus is enabled the clusterinfo should be updated with
network as multus as to run the ceph cmds in remote
executor

Signed-off-by: parth-gr <paarora@redhat.com>
2022-09-22 14:46:51 +05:30
Madhu Rajanna 276005cfd5 csi: add holder pod if csi hostnetworking is disabled
If csi is configured not the use the
hostnetworking, deploy the holder
pod for executing the commands with nsenter.
The implementation is same as multus.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2022-06-07 13:09:12 +05:30
Sébastien Han 95b2e60679 csi: do not block the reconcile if all clusters are not ready
If some clusters don't have their monitors up and running, we don't have
a clusterInfo (internal detail struct). We don't want to block the csi
controller reconcile if all the clusters are not ready. So let's proceed
with the elements that are ready and reconcile again to see if others
have made progress.

Signed-off-by: Sébastien Han <seb@redhat.com>
2022-06-03 10:59:31 +02:00
Sébastien Han 73b1347675 core: fix csi-cephfsplugin pod restart on non-hostnetworking env
Implementation of the design proposed in
https://github.com/rook/rook/pull/9903.

Signed-off-by: Sébastien Han <seb@redhat.com>
2022-04-26 17:53:01 +02:00
Rakshith R 34162c3dc5 csi: add nfs nodeplugin daemonset
This commit adds nfs nodeplugin daemonset.
This will allow rook to deploy nfs nodeplugin
which can mount/unmount nfs volumes.

refer:
- https://github.com/ceph/ceph-csi/blob/devel/docs/design/proposals/nfs.md
- https://github.com/kubernetes-csi/csi-driver-nfs

Signed-off-by: Rakshith R <rar@redhat.com>
2022-04-12 11:07:38 +05:30
Divyansh Kamboj 9008409f87 core: add context parameter to functions
This commit adds context parameter to various functions, and remove the
usage of context.TODO.

Closes: https://github.com/rook/rook/issues/8701
Signed-off-by: Divyansh Kamboj <dkamboj@redhat.com>
2022-03-22 08:19:07 +05:30
Madhu Rajanna 2076a3c788 csi: add custom ceph.conf for csi pods
Currently, the admin/user can configure the ceph.conf
for daemon pods using https://rook.io/docs/rook/v1.7/
ceph-advanced-configuration.html#custom-cephconf-settings.
This the above custom ceph.conf is only for ceph pods.
the support to provide constom ceph.conf for cephcsi
is added in cephcsi PR 2476

This PR adds the support to create/update
ceph.conf for csi pods.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2022-03-01 12:42:59 +05:30
Rakshith R 1e9920fb85 csi: cleanup csi driver resources when zero cephclusters exist
This commit modifies ceph-csi controller to be able to cleanup
ceph-csi deployment,daemonset,services & csidriver objects
when no cephcluster exists.

It makes the following changes:
- redundant check for tp.DriverNamePrefix is removed.
- retry to start drivers within reconcile loop is removed,
  controller will retry in case of error now.
- stopDrivers() will now return error in case of failure.
- predicate delete func will now respond to cephcluster deletion.
- CSI resources will be cleaned up when cephcluster does not exist.

Fixes: #9697

Signed-off-by: Rakshith R <rar@redhat.com>
2022-02-09 12:07:34 +05:30
Sébastien Han 1208bc1410 core: reconcile operator configuration with env var
Previously, we were ignoring configuration changes coming from the
operator's pod env variables. We were assuming most users were using the
operator configmap "rook-ceph-operator-config" but most Helm users
don't. Now we will reconcile if a cephcluster is found during a CREATE
event (can be an operator restart or a cephcluster creation) AND no
"rook-ceph-operator-config" is found which means the operator's pod env
var are used.
Also, unit tests have been added (long due) for the predicate!

Closes: #9602, #9487, #9579
Signed-off-by: Sébastien Han <seb@redhat.com>
2022-01-20 16:13:11 +01:00
Sébastien Han da76a772f8 core: disallow multiple clusters in the same namespace
Rook does not support running multiple clusters in the same namespace,
so the operator should not reconcile if a new cluster is added.
The scenario where a cluster is added while the operator is down is also
handled. CR updates are also handled.
When the operator detects more than one cluster it will refuse to
reconcile the CephCluster, and child CRDs will block too until the
operator is ready.
The user must remove one of the clusters before can continue to perform
any reconcile.

Closes: https://github.com/rook/rook/issues/9452
Signed-off-by: Sébastien Han <seb@redhat.com>
2021-12-17 10:56:15 +01:00
Yuichiro Ueno 0b575703c7 core: add context parameter to k8sutil deployment
This commit adds context parameter to k8sutil deployment functions. By
this, we can handle cancellation during API call of deployment resource.

Signed-off-by: Yuichiro Ueno <y1r.ueno@gmail.com>
2021-11-13 14:58:13 +09:00
Renan Campos c4e70933f2 ceph: csi controller to use constants to fetch operator configmap
The CSI controller loop watches ConfigMaps and CephClusters. When a
CephCluster triggers the reconcile loop, the Get call for the ConfigMap
will fail since the name in the request object is that of the
CephCluster. Setting the name and namespace to the constants for the
ConfigMap name and the operator namespace resolves this.

Closes: https://github.com/rook/rook/issues/8958
Signed-off-by: Renan Campos <rcampos@redhat.com>
2021-10-12 09:30:49 -04:00
Travis Nielsen f5c1543ddf build: update min k8s version to 1.16
In Rook v1.8 the min version of K8s supported is updated to 1.16.
Users running on older versions of K8s are recommended to update
to 1.16 or newer before updating to Rook v1.8.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-09-23 16:17:56 -06:00
Sébastien Han b89730d895 ceph: refactor operator initialization sequence
This commit is a large refactor on how the operator starts, stops and
how it starts various sub-components such as the ceph-csi driver. It
also refines the way we cancel orchestrations. We don't use breakpoints
anymore but send our self a SIGUP to reload our controller runtime
manager.
The reload will happen under different circonstances like:

* a new adminission controller secret is created/deleted/changed
* a CephCluster CR is edited

As mentioned earlier, the csi driver now has its own controller, just
like flex. It reacts to change in the operator config map for particular
ROOK_CSI_ fields.

A second new controller for the operator's general config has been
created, it manages:

* the logging level
* the ceph CLI command timeout
* the discovery daemon

The operator reacts much more rapidly to cancellation events by stopping
the manager's context and reloading it.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-09-17 16:57:12 +02:00