From d922c945666c5f7ed5004f46f7143f63168452d6 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Fri, 16 Aug 2024 12:34:08 +0200 Subject: [PATCH] [openstackclient] re-create pod when NodeSelector changes When the NodeSelector gets updated via the OpenStackClient NodeSelector api we have to re-create the pod that it gets scheduled for the new configuration Jira: OSPRH-9443 Signed-off-by: Martin Schuppert --- controllers/client/openstackclient_controller.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/client/openstackclient_controller.go b/controllers/client/openstackclient_controller.go index 58bbb831d..4fd51896a 100644 --- a/controllers/client/openstackclient_controller.go +++ b/controllers/client/openstackclient_controller.go @@ -17,6 +17,7 @@ import ( "context" "errors" "fmt" + "reflect" "time" "github.com/go-logr/logr" @@ -342,8 +343,14 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ osclient.Name, errors.New("Config changed recreate pod"), // Specify the error message ) + case !reflect.DeepEqual(osclient.Spec.NodeSelector, instance.Spec.NodeSelector): + // if NodeSelecor change force re-create by triggering NewForbidden + return k8s_errors.NewForbidden( + schema.GroupResource{Group: "", Resource: "pods"}, // Specify the group and resource type + osclient.Name, + errors.New("Cannot update Pod spec field - Spec.NodeSelector"), // Specify the error message + ) } - } osclient.Labels = util.MergeStringMaps(osclient.Labels, clientLabels)