From 2c64f3af6c3acd1aca26b7ad078fd81ec4fd6090 Mon Sep 17 00:00:00 2001 From: sridhartigera <63839878+sridhartigera@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:51:02 -0700 Subject: [PATCH] Update EGW status only if it has changed. (#3577) * Update EGW status only if it has changed. --- .../egressgateway/egressgateway_controller.go | 27 ++++++++----------- ...projectcalico.org_felixconfigurations.yaml | 4 +++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/controller/egressgateway/egressgateway_controller.go b/pkg/controller/egressgateway/egressgateway_controller.go index 29492db165..946e41707d 100644 --- a/pkg/controller/egressgateway/egressgateway_controller.go +++ b/pkg/controller/egressgateway/egressgateway_controller.go @@ -373,9 +373,6 @@ func (r *ReconcileEgressGateway) reconcileEgressGateway(ctx context.Context, egw return err } - // Set the condition to progressing - setProgressing(r.client, ctx, egw, string(operatorv1.ResourceNotReady), "Reconciling") - egwVXLANPort := egressgateway.DefaultVXLANPort egwVXLANVNI := egressgateway.DefaultVXLANVNI if fc.Spec.EgressIPVXLANPort != nil { @@ -652,25 +649,25 @@ func getUnreadyEgressGateway(egws []operatorv1.EgressGateway) *operatorv1.Egress // setDegraded updates the degraded status condition of the EGW resource. func setDegraded(cli client.Client, ctx context.Context, egw *operatorv1.EgressGateway, reason, msg string) { - updateEGWStatusConditions(cli, ctx, egw, operatorv1.ComponentDegraded, metav1.ConditionTrue, reason, msg, true) -} - -// setProgressing updates the progressing status condition of the EGW resource. -func setProgressing(cli client.Client, ctx context.Context, egw *operatorv1.EgressGateway, reason, msg string) { - updateEGWStatusConditions(cli, ctx, egw, operatorv1.ComponentProgressing, metav1.ConditionTrue, reason, msg, false) + updateEGWStatusConditions(cli, ctx, egw, operatorv1.ComponentDegraded, metav1.ConditionTrue, reason, msg) } -// setProgressing updates the ready status condition of the EGW resource. +// setAvailable updates the ready status condition of the EGW resource. func setAvailable(cli client.Client, ctx context.Context, egw *operatorv1.EgressGateway, reason, msg string) { - updateEGWStatusConditions(cli, ctx, egw, operatorv1.ComponentAvailable, metav1.ConditionTrue, reason, msg, true) + updateEGWStatusConditions(cli, ctx, egw, operatorv1.ComponentAvailable, metav1.ConditionTrue, reason, msg) } // updateEGWStatusConditions sets the status conditions of the EGW resource and if updateStatus is True, status of the EGW resource // is updated in the datastore. -func updateEGWStatusConditions(cli client.Client, ctx context.Context, egw *operatorv1.EgressGateway, ctype operatorv1.StatusConditionType, status metav1.ConditionStatus, reason, msg string, updateStatus bool) { +func updateEGWStatusConditions(cli client.Client, ctx context.Context, egw *operatorv1.EgressGateway, ctype operatorv1.StatusConditionType, status metav1.ConditionStatus, reason, msg string) { found := false for idx, cond := range egw.Status.Conditions { if cond.Type == string(ctype) { + if cond.Status == status && + cond.Reason == reason && + cond.Message == msg { + return + } cond.Status = status cond.Reason = reason cond.Message = msg @@ -687,10 +684,8 @@ func updateEGWStatusConditions(cli client.Client, ctx context.Context, egw *oper condition := metav1.Condition{Type: string(ctype), Status: status, Reason: reason, Message: msg, LastTransitionTime: metav1.NewTime(time.Now())} egw.Status.Conditions = append(egw.Status.Conditions, condition) } - if updateStatus { - if err := cli.Status().Update(ctx, egw); err != nil { - log.WithValues("Name", egw.Name, "Namespace", egw.Namespace, "error", err).Info("Error updating status") - } + if err := cli.Status().Update(ctx, egw); err != nil { + log.WithValues("Name", egw.Name, "Namespace", egw.Namespace, "error", err).Info("Error updating status") } } diff --git a/pkg/crds/calico/crd.projectcalico.org_felixconfigurations.yaml b/pkg/crds/calico/crd.projectcalico.org_felixconfigurations.yaml index 6382936bd4..4d58f55bbc 100644 --- a/pkg/crds/calico/crd.projectcalico.org_felixconfigurations.yaml +++ b/pkg/crds/calico/crd.projectcalico.org_felixconfigurations.yaml @@ -1037,6 +1037,10 @@ spec: description: 'WireguardRoutingRulePriority controls the priority value to use for the Wireguard routing rule. [Default: 99]' type: integer + wireguardThreadingEnabled: + description: 'WireguardThreadingEnabled controls whether Wireguard + has NAPI threading enabled. [Default: false]' + type: boolean workloadSourceSpoofing: description: WorkloadSourceSpoofing controls whether pods can use the allowedSourcePrefixes annotation to send traffic with a source