@@ -26,6 +26,7 @@ import (
2626 "reflect"
2727 "regexp"
2828 "slices"
29+ "strconv"
2930 "strings"
3031
3132 "github.com/go-logr/logr"
@@ -72,7 +73,10 @@ const (
7273const (
7374 // Annotation name for ownerref information
7475 ownerRefAnnotationKey = "csi.ceph.io/ownerref"
75- logRotateCmd = `while true; do logrotate --verbose /logrotate-config/csi; sleep 15m; done`
76+ // Annotation to enable CSI-Addons volume condition reporter
77+ driverCSIAddonsFeatureVolumeCondition = "addons.csi.ceph.io/volume-condition"
78+
79+ logRotateCmd = `while true; do logrotate --verbose /logrotate-config/csi; sleep 15m; done`
7680)
7781
7882// A regexp used to parse driver's prefix and type from the full name
@@ -236,10 +240,7 @@ func (r *driverReconcile) reconcile() error {
236240 r .reconcileControllerPluginDeployment ,
237241 r .reconcileNodePluginDeamonSet ,
238242 r .reconcileLivenessService ,
239- }
240-
241- if r .isRbdDriver () {
242- reconcilers = append (reconcilers , r .reconcileNodePluginDeamonSetForCsiAddons )
243+ r .reconcileNodePluginDeamonSetForCsiAddons ,
243244 }
244245
245246 // Concurrently reconcile different aspects of the clusters actual state to meet
@@ -981,7 +982,38 @@ func (r *driverReconcile) reconcileNodePluginDeamonSetForCsiAddons() error {
981982
982983 log := r .log .WithValues ("csiAddonsDaemonSetName" , daemonSet .Name )
983984
984- if ! ptr .Deref (r .driver .Spec .DeployCsiAddons , false ) {
985+ withCsiAddonsDaemonSet := false
986+ withCsiAddonsVolumeCondition := false
987+
988+ if r .isRbdDriver () {
989+ withCsiAddonsDaemonSet = ptr .Deref (r .driver .Spec .DeployCsiAddons , false )
990+ }
991+
992+ // check if the driver wants CSI-Addons features
993+ if feature := r .driver .GetAnnotations ()[driverCSIAddonsFeatureVolumeCondition ]; feature != "" {
994+ enabled , err := strconv .ParseBool (feature )
995+ if err != nil {
996+ r .log .Error (
997+ err ,
998+ "Unable to parse annotation on driver.csi.ceph.io" ,
999+ "name" ,
1000+ client .ObjectKeyFromObject (& r .driver ),
1001+ driverCSIAddonsFeatureVolumeCondition ,
1002+ feature ,
1003+ )
1004+ return err
1005+ }
1006+
1007+ withCsiAddonsVolumeCondition = enabled
1008+ // if the feature is enabled, enable the daemonset too
1009+ withCsiAddonsDaemonSet = withCsiAddonsDaemonSet || withCsiAddonsVolumeCondition
1010+ }
1011+
1012+ if r .isNfsDriver () {
1013+ withCsiAddonsDaemonSet = false
1014+ }
1015+
1016+ if ! withCsiAddonsDaemonSet {
9851017 if err := r .Delete (r .ctx , daemonSet ); client .IgnoreNotFound (err ) != nil {
9861018 log .Error (err , "failed to delete csi addons daemonset" )
9871019 return err
@@ -1062,6 +1094,7 @@ func (r *driverReconcile) reconcileNodePluginDeamonSetForCsiAddons() error {
10621094 utils .If (logRotationEnabled , utils .LogToStdErrContainerArg , "" ),
10631095 utils .If (logRotationEnabled , utils .AlsoLogToStdErrContainerArg , "" ),
10641096 utils .If (logRotationEnabled , utils .LogFileContainerArg ("csi-addons" ), "" ),
1097+ utils .If (withCsiAddonsVolumeCondition , utils .CsiAddonsVolumeConditionArg , "" ),
10651098 },
10661099 ),
10671100 Ports : []corev1.ContainerPort {
@@ -1080,6 +1113,12 @@ func (r *driverReconcile) reconcileNodePluginDeamonSetForCsiAddons() error {
10801113 if logRotationEnabled {
10811114 mounts = append (mounts , utils .LogsDirVolumeMount )
10821115 }
1116+ if withCsiAddonsVolumeCondition {
1117+ mounts = append (mounts ,
1118+ utils .PluginMountDirVolumeMount (kubeletDirPath ),
1119+ utils .PodsMountDirVolumeMount (kubeletDirPath ),
1120+ )
1121+ }
10831122 return mounts
10841123 }),
10851124 Resources : ptr .Deref (
@@ -1124,6 +1163,14 @@ func (r *driverReconcile) reconcileNodePluginDeamonSetForCsiAddons() error {
11241163 utils .LogRotateDirVolumeName (r .driver .Name ),
11251164 )
11261165 }
1166+
1167+ if withCsiAddonsVolumeCondition {
1168+ volumes = append (
1169+ volumes ,
1170+ utils .PluginMountDirVolume (kubeletDirPath ),
1171+ utils .PodsMountDirVolume (kubeletDirPath ),
1172+ )
1173+ }
11271174 return volumes
11281175 }),
11291176 },
0 commit comments