Skip to content

Commit

Permalink
Remove unnecessary logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Jan 16, 2024
1 parent f162b16 commit 1013f2a
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions adapter/internal/operator/controllers/dp/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &backend)
requests = apiReconciler.getAPIsForBackend(ctx, &backend)
apiReconciler.handleOwnerReference(ctx, &backend, &requests)
case *dpv1alpha1.Scope:
Expand All @@ -959,7 +958,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &scope)
requests = apiReconciler.getAPIsForScope(ctx, &scope)
apiReconciler.handleOwnerReference(ctx, &scope, &requests)
case *dpv1alpha1.RateLimitPolicy:
Expand All @@ -972,7 +970,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &rl)
requests = apiReconciler.getAPIsForRateLimitPolicy(ctx, &rl)
apiReconciler.handleOwnerReference(ctx, &rl, &requests)
case *dpv1alpha1.BackendJWT:
Expand All @@ -985,7 +982,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &backendJWT)
requests = apiReconciler.getAPIsForBackendJWT(ctx, &backendJWT)
apiReconciler.handleOwnerReference(ctx, &backendJWT, &requests)
case *dpv1alpha1.InterceptorService:
Expand All @@ -998,7 +994,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &interceptorService)
requests = apiReconciler.getAPIsForInterceptorService(ctx, &interceptorService)
apiReconciler.handleOwnerReference(ctx, &interceptorService, &requests)
case *dpv1alpha1.APIPolicy:
Expand All @@ -1011,7 +1006,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &apiPolicy)
requests = apiReconciler.getAPIsForAPIPolicy(ctx, &apiPolicy)
apiReconciler.handleOwnerReference(ctx, &apiPolicy, &requests)
case *dpv1alpha2.Authentication:
Expand All @@ -1024,7 +1018,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &auth)
requests = apiReconciler.getAPIsForAuthentication(ctx, &auth)
apiReconciler.handleOwnerReference(ctx, &auth, &requests)
case *corev1.Secret:
Expand All @@ -1037,7 +1030,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &secret)
requests = apiReconciler.getAPIsForSecret(ctx, &secret)
apiReconciler.handleOwnerReference(ctx, &secret, &requests)
case *corev1.ConfigMap:
Expand All @@ -1050,7 +1042,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", cm)
requests = apiReconciler.getAPIsForConfigMap(ctx, &cm)
apiReconciler.handleOwnerReference(ctx, &cm, &requests)
case *gwapiv1b1.HTTPRoute:
Expand All @@ -1063,7 +1054,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &httpRoute)
requests = apiReconciler.getAPIForHTTPRoute(ctx, &httpRoute)
apiReconciler.handleOwnerReference(ctx, &httpRoute, &requests)
case *dpv1alpha2.GQLRoute:
Expand All @@ -1076,7 +1066,6 @@ func (apiReconciler *APIReconciler) retriveParentAPIsAndUpdateOwnerReferene(ctx
loggers.LoggerAPKOperator.Errorf("Unexpected error occured while loading the cr object from cluster %+v", err)
return
}
loggers.LoggerAPKOperator.Errorf("Object loaded successfully %+v", &gqlRoute)
requests = apiReconciler.getAPIForGQLRoute(ctx, &gqlRoute)
apiReconciler.handleOwnerReference(ctx, &gqlRoute, &requests)
default:
Expand Down Expand Up @@ -2026,16 +2015,13 @@ func (apiReconciler *APIReconciler) handleStatus() {


func (apiReconciler *APIReconciler) handleOwnerReference(ctx context.Context, obj k8client.Object, apiRequests *[]reconcile.Request) {
loggers.LoggerAPKOperator.Infof("Handling owner reference update for object: %v:%v size : %v", obj.GetName(), obj.GetNamespace(), len(*apiRequests))


apis := []dpv1alpha2.API{}
for _, req := range *apiRequests {
var apiCR dpv1alpha2.API
if err := apiReconciler.client.Get(ctx, req.NamespacedName, &apiCR); err == nil {
apis = append(apis, apiCR)
} else {
loggers.LoggerAPKOperator.Infof("Error while loading api: %+v", req)
loggers.LoggerAPKOperator.Errorf("Error while loading api: %+v", req)
}
}
// Prepare owner references for the route
Expand All @@ -2059,19 +2045,8 @@ func (apiReconciler *APIReconciler) handleOwnerReference(ctx context.Context, ob
}
}
if (updateRequired) {
if (len(preparedOwnerReferences) > 0) {
loggers.LoggerAPKOperator.Infof("An update is required for object: %v:%v obj owner size: %v size : %v %v %v %v %v", obj.GetName(), obj.GetNamespace(), len(obj.GetOwnerReferences()), len(preparedOwnerReferences), preparedOwnerReferences[0].UID, preparedOwnerReferences[0].Name, preparedOwnerReferences[0].APIVersion, preparedOwnerReferences[0].Kind)
} else {
loggers.LoggerAPKOperator.Infof("An update is required for object: %v:%v obj owner size: %v size : %v ", obj.GetName(), obj.GetNamespace(), len(obj.GetOwnerReferences()), len(preparedOwnerReferences))
}
obj.SetOwnerReferences(preparedOwnerReferences)
utils.UpdateCR(ctx, apiReconciler.client, obj)
} else {
if (len(preparedOwnerReferences) > 0) {
loggers.LoggerAPKOperator.Infof("Update not required for object: %v:%v obj owner size: %v size : %v %v %v %v %v", obj.GetName(), obj.GetNamespace(), len(obj.GetOwnerReferences()), len(preparedOwnerReferences), preparedOwnerReferences[0].UID, preparedOwnerReferences[0].Name, preparedOwnerReferences[0].APIVersion, preparedOwnerReferences[0].Kind)
} else {
loggers.LoggerAPKOperator.Infof("Update not required for object: %v:%v obj owner size: %v size : %v ", obj.GetName(), obj.GetNamespace(), len(obj.GetOwnerReferences()), len(preparedOwnerReferences))
}
}
}

Expand Down

0 comments on commit 1013f2a

Please sign in to comment.