Skip to content

Commit

Permalink
fix status
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaliMatharaarachchi committed Jun 3, 2024
1 parent 25ab53f commit 4f4d3bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions adapter/internal/operator/controllers/dp/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions adapter/pkg/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 4f4d3bb

Please sign in to comment.