@@ -37,8 +37,6 @@ import (
37
37
rbacv1 "k8s.io/api/rbac/v1"
38
38
storagev1 "k8s.io/api/storage/v1"
39
39
"k8s.io/apimachinery/pkg/api/errors"
40
- //"k8s.io/apimachinery/pkg/api/resource"
41
- //metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
42
40
"k8s.io/apimachinery/pkg/runtime"
43
41
"k8s.io/apimachinery/pkg/runtime/schema"
44
42
"k8s.io/apimachinery/pkg/types"
@@ -106,7 +104,7 @@ func (r *IBMObjectCSIReconciler) Reconcile(ctx context.Context, req ctrl.Request
106
104
r .ControllerHelper .Log = csiLog
107
105
108
106
// Check if the reconcile was triggered by the ConfigMap events
109
- if req .Name == "cos-csi-driver-configmap" {
107
+ if req .Name == constants . ResourceReqLimitsConfigMap {
110
108
reqLogger .Info ("Reconcile triggered by ConfigMap event" )
111
109
// Handle the update of IBMObjectCSI
112
110
return r .handleConfigMapReconcile (ctx , req )
@@ -198,10 +196,10 @@ func (r *IBMObjectCSIReconciler) handleConfigMapReconcile(ctx context.Context, r
198
196
err := r .Get (ctx , req .NamespacedName , configMap )
199
197
if err != nil {
200
198
if errors .IsNotFound (err ) {
201
- reqLogger .Info ("ConfigMap " , "cos-csi-driver-configmap" , " not found in namespace" , req .Namespace )
199
+ reqLogger .Info ("ConfigMap" , req . Name , "not found in namespace" , req .Namespace )
202
200
// what action should be taken when cm is not found?
203
201
} else {
204
- reqLogger .Error (err , "Failed to get ConfigMap " , "cos-csi-driver-configmap" )
202
+ reqLogger .Error (err , "Failed to get ConfigMap" , req . Name )
205
203
// Error reading the object - requeue the request.
206
204
return reconcile.Result {}, err
207
205
}
@@ -212,14 +210,18 @@ func (r *IBMObjectCSIReconciler) handleConfigMapReconcile(ctx context.Context, r
212
210
CSINodeMemoryRequest := configMap .Data ["CSINodeMemoryRequest" ]
213
211
CSINodeCPULimit := configMap .Data ["CSINodeCPULimit" ]
214
212
CSINodeMemoryLimit := configMap .Data ["CSINodeMemoryLimit" ]
213
+
215
214
reqLogger .Info ("The resource requests and limits fetched from configmap" ,
216
- " CSINodeCPURequest: " , CSINodeCPURequest , " CSINodeMemoryRequest: " , CSINodeMemoryRequest ,
217
- " CSINodeCPULimit: " , CSINodeCPULimit , " CSINodeMemoryLimit: " , CSINodeMemoryLimit )
215
+ "CSINodeCPURequest" , CSINodeCPURequest , "CSINodeMemoryRequest" , CSINodeMemoryRequest ,
216
+ "CSINodeCPULimit" , CSINodeCPULimit , "CSINodeMemoryLimit" , CSINodeMemoryLimit )
218
217
219
218
// Fetch the IBMObjectCSI instance
220
219
instance := & objectdriverv1alpha1.IBMObjectCSI {}
221
220
222
- err = r .Get (ctx , types.NamespacedName {Namespace : "ibm-object-csi-operator-system" , Name : "ibm-object-csi" }, instance )
221
+ err = r .Get (ctx , types.NamespacedName {
222
+ Namespace : constants .ObjectCSIDriverOperatorDeployNS ,
223
+ Name : constants .ObjectCSIDriver },
224
+ instance )
223
225
if err != nil {
224
226
reqLogger .Error (err , "Failed to get IBMObjectCSI instance" )
225
227
return reconcile.Result {}, err
@@ -239,7 +241,7 @@ func (r *IBMObjectCSIReconciler) handleConfigMapReconcile(ctx context.Context, r
239
241
reqLogger .Error (err , "Failed to update IBMObjectCSI instance with ConfigMap values" )
240
242
return reconcile.Result {}, err
241
243
}
242
- reqLogger .Info ("IBMObjectCSI CR updated successfully . Node pods will get restarted to reflect updated resource requests and limits" )
244
+ reqLogger .Info ("IBMObjectCSI CR is getting updated . Node pods will get restarted to reflect updated resource requests and limits" )
243
245
244
246
return reconcile.Result {}, nil
245
247
}
@@ -585,16 +587,16 @@ func configMapPredicate() predicate.Predicate {
585
587
triggerReconcile := predicate.Funcs {
586
588
CreateFunc : func (e event.CreateEvent ) bool {
587
589
configmap := e .Object .(* corev1.ConfigMap )
588
- if configmap .Name == "cos-csi-driver-configmap" {
589
- logger .Info ("Create detected on the configmap" , " configmap: " , configmap .Name )
590
+ if configmap .Name == constants . ResourceReqLimitsConfigMap {
591
+ logger .Info ("Create detected on the configmap" , "configmap" , configmap .Name )
590
592
return true
591
593
}
592
594
return false
593
595
},
594
596
UpdateFunc : func (e event.UpdateEvent ) bool {
595
597
configmap := e .ObjectNew .(* corev1.ConfigMap )
596
- if configmap .Name == "cos-csi-driver-configmap" {
597
- logger .Info ("Update detected on the configmap" , " configmap: " , configmap .Name )
598
+ if configmap .Name == constants . ResourceReqLimitsConfigMap {
599
+ logger .Info ("Update detected on the configmap" , "configmap" , configmap .Name )
598
600
return true
599
601
}
600
602
return false
0 commit comments