@@ -145,13 +145,13 @@ func (r *Reconciler) ReconcilePhaseCreatingForMainClusters() error {
145145
146146 // create notification log pvc if bucket notifications is enabled and pvc was not set explicitly
147147 if r .NooBaa .Spec .BucketNotifications .Enabled {
148- if err := r .ReconcileODFPersistentLoggingPVC (
149- "bucketNotifications.pvc" ,
150- "InvalidBucketNotificationConfiguration" ,
151- "Bucket notifications requires a Persistent Volume Claim (PVC) with ReadWriteMany (RWX) access mode. Please specify the 'bucketNotifications.pvc'." ,
152- r .NooBaa .Spec .BucketNotifications .PVC ,
153- r .BucketNotificationsPVC ); err != nil {
154- return err
148+ if err := r .ReconcileODFPersistentLoggingPVC (
149+ "bucketNotifications.pvc" ,
150+ "InvalidBucketNotificationConfiguration" ,
151+ "Bucket notifications requires a Persistent Volume Claim (PVC) with ReadWriteMany (RWX) access mode. Please specify the 'bucketNotifications.pvc'." ,
152+ r .NooBaa .Spec .BucketNotifications .PVC ,
153+ r .BucketNotificationsPVC ); err != nil {
154+ return err
155155 }
156156 }
157157
@@ -287,10 +287,15 @@ func (r *Reconciler) SetDesiredNooBaaDB() error {
287287 },
288288 },
289289 }
290-
291290 }
292291 }
293292
293+ // set terminationGracePeriodSeconds to 70 seconds to allow for graceful shutdown
294+ // we set 70 to account for the 60 seconds timeout of the fast shutdow in preStop, plus some slack
295+ // see here: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#hook-handler-execution
296+ gracePeriod := int64 (70 )
297+ podSpec .TerminationGracePeriodSeconds = & gracePeriod
298+
294299 if r .NooBaa .Spec .ImagePullSecret == nil {
295300 podSpec .ImagePullSecrets =
296301 []corev1.LocalObjectReference {}
@@ -472,10 +477,10 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) {
472477
473478 if r .NooBaa .Spec .BucketNotifications .Enabled {
474479 envVar := corev1.EnvVar {
475- Name : "NOTIFICATION_LOG_DIR" ,
480+ Name : "NOTIFICATION_LOG_DIR" ,
476481 Value : "/var/logs/notifications" ,
477482 }
478- util .MergeEnvArrays (& c .Env , & []corev1.EnvVar {envVar });
483+ util .MergeEnvArrays (& c .Env , & []corev1.EnvVar {envVar })
479484 }
480485
481486}
@@ -555,10 +560,10 @@ func (r *Reconciler) SetDesiredCoreApp() error {
555560 }}
556561 util .MergeVolumeMountList (& c .VolumeMounts , & notificationVolumeMounts )
557562
558- notificationVolumes := []corev1.Volume {{
563+ notificationVolumes := []corev1.Volume {{
559564 Name : notificationsVolume ,
560- VolumeSource : corev1.VolumeSource {
561- PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
565+ VolumeSource : corev1.VolumeSource {
566+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
562567 ClaimName : r .BucketNotificationsPVC .Name ,
563568 },
564569 },
@@ -1230,8 +1235,8 @@ func (r *Reconciler) ReconcileDBConfigMap(cm *corev1.ConfigMap, desiredFunc func
12301235 return r .isObjectUpdated (result ), nil
12311236}
12321237
1233- //ReconcileODFPersistentLoggingPVC ensures a persistent logging pvc (either for bucket logging or bucket notificatoins)
1234- //is properly configured. If needed and possible, allocate one from CephFS
1238+ // ReconcileODFPersistentLoggingPVC ensures a persistent logging pvc (either for bucket logging or bucket notificatoins)
1239+ // is properly configured. If needed and possible, allocate one from CephFS
12351240func (r * Reconciler ) ReconcileODFPersistentLoggingPVC (
12361241 fieldName string ,
12371242 errorName string ,
@@ -1243,7 +1248,7 @@ func (r *Reconciler) ReconcileODFPersistentLoggingPVC(
12431248
12441249 // Return if persistent logging PVC already exists
12451250 if pvcName != nil {
1246- pvc .Name = * pvcName ;
1251+ pvc .Name = * pvcName
12471252 log .Infof ("PersistentLoggingPVC %s already exists and supports RWX access mode. Skipping ReconcileODFPersistentLoggingPVC." , * pvcName )
12481253 return nil
12491254 }
@@ -1257,7 +1262,7 @@ func (r *Reconciler) ReconcileODFPersistentLoggingPVC(
12571262 if ! r .preparePersistentLoggingPVC (pvc , fieldName ) {
12581263 return util .NewPersistentError (errorName , errorText )
12591264 }
1260- r .Own (pvc );
1265+ r .Own (pvc )
12611266
12621267 log .Infof ("Persistent logging PVC %s does not exist. Creating..." , pvc .Name )
12631268 err := r .Client .Create (r .Ctx , pvc )
@@ -1269,7 +1274,7 @@ func (r *Reconciler) ReconcileODFPersistentLoggingPVC(
12691274
12701275}
12711276
1272- //prepare persistent logging pvc
1277+ // prepare persistent logging pvc
12731278func (r * Reconciler ) preparePersistentLoggingPVC (pvc * corev1.PersistentVolumeClaim , fieldName string ) bool {
12741279 pvc .Spec .AccessModes = []corev1.PersistentVolumeAccessMode {corev1 .ReadWriteMany }
12751280
@@ -1282,9 +1287,9 @@ func (r *Reconciler) preparePersistentLoggingPVC(pvc *corev1.PersistentVolumeCla
12821287 if util .KubeCheck (sc ) {
12831288 r .Logger .Infof ("%s not provided, defaulting to 'cephfs' storage class %s to create persistent logging pvc" , fieldName , sc .Name )
12841289 pvc .Spec .StorageClassName = & sc .Name
1285- return true ;
1290+ return true
12861291 } else {
1287- return false ;
1292+ return false
12881293 }
12891294}
12901295
0 commit comments