Skip to content

Commit 0b5953c

Browse files
sebsotoopenshift-cherrypick-robot
authored andcommitted
Fix panic when replacing services configmap
Removes the dereferencing of a nil error
1 parent 0cdee98 commit 0b5953c

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

controllers/configmap_controller.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,27 @@ func (r *ConfigMapReconciler) reconcileServices(ctx context.Context, windowsServ
202202

203203
// If a ConfigMap with invalid values is found, WMCO will delete and recreate it with proper values
204204
data, err := servicescm.Parse(windowsServices.Data)
205-
if err != nil || data.ValidateExpectedContent(r.servicesManifest) != nil {
206-
// Deleting will trigger an event for the configmap_controller, which will re-create a proper ConfigMap
207-
if err = r.client.Delete(ctx, windowsServices); err != nil {
208-
return err
205+
if err == nil {
206+
validateErr := data.ValidateExpectedContent(r.servicesManifest)
207+
if validateErr == nil {
208+
return nil
209209
}
210-
r.log.Info("Deleted invalid resource", "ConfigMap",
211-
kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: windowsServices.Name}, "Error", err.Error())
212-
return nil
210+
r.log.V(1).Info("Invalid content",
211+
"ConfigMap", kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: windowsServices.Name},
212+
"Error", validateErr)
213+
} else {
214+
r.log.V(1).Info("Parse error",
215+
"ConfigMap", kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: windowsServices.Name},
216+
"Error", err)
217+
}
218+
// Deleting will trigger an event for the configmap_controller, which will re-create a proper ConfigMap
219+
if err = r.client.Delete(ctx, windowsServices); err != nil {
220+
return err
213221
}
214-
// TODO: actually react to changes to the services ConfigMap
222+
r.log.Info("Deleted invalid resource", "ConfigMap",
223+
kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: windowsServices.Name})
215224
return nil
225+
// TODO: actually react to changes to the services ConfigMap
216226
}
217227

218228
// removeOutdatedServicesConfigMaps deletes any outdated services ConfigMaps, if all nodes have moved past that version

0 commit comments

Comments
 (0)