From 4f4d3bb2f1c33d40b0b444fe7acf9bb0e03538af Mon Sep 17 00:00:00 2001 From: AmaliMatharaarachchi Date: Thu, 30 May 2024 16:24:08 +0530 Subject: [PATCH] fix status --- .../controllers/dp/gateway_controller.go | 32 +++++++++---------- adapter/pkg/health/health.go | 6 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/adapter/internal/operator/controllers/dp/gateway_controller.go b/adapter/internal/operator/controllers/dp/gateway_controller.go index 4ee2356197..995c02453e 100644 --- a/adapter/internal/operator/controllers/dp/gateway_controller.go +++ b/adapter/internal/operator/controllers/dp/gateway_controller.go @@ -193,10 +193,10 @@ func (gatewayReconciler *GatewayReconciler) Reconcile(ctx context.Context, req c gatewayStateData, listenerStatuses, err := gatewayReconciler.resolveGatewayState(ctx, gatewayDef) // Check whether the status change is needed for gateway statusChanged := isStatusChanged(gatewayDef, listenerStatuses) - loggers.LoggerAPKOperator.Infof("Status changed ? %+v", statusChanged) + loggers.LoggerAPKOperator.Debugf("Gateway Status changed ? %+v", statusChanged) if err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3122, logging.BLOCKER, "Error resolving Gateway State %s: %v", req.NamespacedName.String(), err)) + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3122, logging.MAJOR, "Error resolving Gateway State %s: %v", req.NamespacedName.String(), err)) return ctrl.Result{}, err } state := constants.Update @@ -237,7 +237,7 @@ func (gatewayReconciler *GatewayReconciler) resolveListenerSecretRefs(ctx contex namespace := gwapiv1.Namespace(string(*secretRef.Namespace)) if err := gatewayReconciler.client.Get(ctx, types.NamespacedName{Name: string(secretRef.Name), Namespace: utils.GetNamespace(&namespace, gatewayNamespace)}, &secret); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3123, logging.BLOCKER, "Unable to find associated secret %s in %s: %v", secretRef.Name, string(*secretRef.Namespace), err)) + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3123, logging.MAJOR, "Unable to find associated secret %s in %s: %v", secretRef.Name, string(*secretRef.Namespace), err)) return nil, err } return secret.Data, nil @@ -309,7 +309,7 @@ func (gatewayReconciler *GatewayReconciler) resolveGatewayState(ctx context.Cont LastTransitionTime: metav1.Now(), ObservedGeneration: gateway.Generation, }) - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3105, logging.BLOCKER, "Error resolving listener certificates: %v", err)) + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3105, logging.MAJOR, "Error resolving listener certificates: %v", err)) return nil, listenerstatuses, err } resolvedListenerCerts[string(listener.Name)] = data @@ -595,22 +595,22 @@ func (gatewayReconciler *GatewayReconciler) handleGatewayStatus(gatewayKey types UpdateStatus: func(obj k8client.Object) k8client.Object { h, ok := obj.(*gwapiv1.Gateway) if !ok { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3109, logging.BLOCKER, "Error while updating Gateway status %v", obj)) + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3109, logging.MAJOR, "Error while updating Gateway status %v", obj)) } hCopy := h.DeepCopy() - var gwCondition []metav1.Condition = hCopy.Status.Conditions + var gwConditions []metav1.Condition generation := hCopy.ObjectMeta.Generation - gwCondition[0].Status = "True" - gwCondition[0].Message = message - gwCondition[0].LastTransitionTime = timeNow - // gwCondition[0].Reason = append(gwCondition[0].Reason, event) - gwCondition[0].Reason = "Reconciled" - gwCondition[0].Type = constants.Accept - for i := range gwCondition { - // Assign generation to ObservedGeneration - gwCondition[i].ObservedGeneration = generation + for _, gwCondition := range hCopy.Status.Conditions { + gwCondition.Status = "True" + gwCondition.Message = message + gwCondition.LastTransitionTime = timeNow + // gwCondition[0].Reason = append(gwCondition[0].Reason, event) + gwCondition.Reason = "Reconciled" + // gwCondition.Type = constants.Accept + gwCondition.ObservedGeneration = generation + gwConditions = append(gwConditions, gwCondition) } - hCopy.Status.Conditions = gwCondition + hCopy.Status.Conditions = gwConditions for _, listener := range hCopy.Status.Listeners { for _, listener1 := range listeners { if string(listener.Name) == string(listener1.Name) { diff --git a/adapter/pkg/health/health.go b/adapter/pkg/health/health.go index 4f65c16dd9..bea6dd2149 100644 --- a/adapter/pkg/health/health.go +++ b/adapter/pkg/health/health.go @@ -58,8 +58,8 @@ type Server struct { // Check responds the health check client with health status of the Adapter func (s Server) Check(ctx context.Context, request *healthservice.HealthCheckRequest) (*healthservice.HealthCheckResponse, error) { - logger.LoggerHealth.Debugf("Querying health state for Adapter service \"%s\"", request.Service) - logger.LoggerHealth.Debugf("Internal health state map: %v", serviceHealthStatus) + // logger.LoggerHealth.Debugf("Querying health state for Adapter service \"%s\"", request.Service) + // logger.LoggerHealth.Debugf("Internal health state map: %v", serviceHealthStatus) if request.Service == "" { // overall health of the server @@ -69,7 +69,7 @@ func (s Server) Check(ctx context.Context, request *healthservice.HealthCheckReq } if isHealthy { - logger.LoggerHealth.Debug("Responding health state of Adapter as HEALTHY") + // logger.LoggerHealth.Debug("Responding health state of Adapter as HEALTHY") return &healthservice.HealthCheckResponse{Status: healthservice.HealthCheckResponse_SERVING}, nil } logger.LoggerHealth.Debug("Responding health state of Adapter as NOT_HEALTHY")