Skip to content

Commit 0940369

Browse files
committed
refactor: avoid logging error and sentinel for status
Signed-off-by: Dario Tranchitella <[email protected]>
1 parent f82350f commit 0940369

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

controllers/tenantcontrolplane_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ func (r *TenantControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
199199
}
200200

201201
if err = utils.UpdateStatus(ctx, r.Client, tenantControlPlane, resource); err != nil {
202+
if kamajierrors.ShouldReconcileErrorBeIgnored(err) {
203+
log.V(1).Info("sentinel error, enqueuing back request", "error", err.Error())
204+
205+
return ctrl.Result{Requeue: true}, nil
206+
}
207+
202208
log.Error(err, "update of the resource failed", "resource", resource.GetName())
203209

204210
return ctrl.Result{}, err

internal/resources/k8s_service_resource.go

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"k8s.io/utils/ptr"
1515
"sigs.k8s.io/controller-runtime/pkg/client"
1616
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
17-
"sigs.k8s.io/controller-runtime/pkg/log"
1817

1918
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
2019
"github.com/clastix/kamaji/internal/utilities"
@@ -42,17 +41,13 @@ func (r *KubernetesServiceResource) CleanUp(context.Context, *kamajiv1alpha1.Ten
4241
}
4342

4443
func (r *KubernetesServiceResource) UpdateTenantControlPlaneStatus(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
45-
logger := log.FromContext(ctx, "resource", r.GetName())
46-
4744
tenantControlPlane.Status.Kubernetes.Service.ServiceStatus = r.resource.Status
4845
tenantControlPlane.Status.Kubernetes.Service.Name = r.resource.GetName()
4946
tenantControlPlane.Status.Kubernetes.Service.Namespace = r.resource.GetNamespace()
5047
tenantControlPlane.Status.Kubernetes.Service.Port = r.resource.Spec.Ports[0].Port
5148

5249
address, err := tenantControlPlane.DeclaredControlPlaneAddress(ctx, r.Client)
5350
if err != nil {
54-
logger.Error(err, "cannot retrieve Tenant Control Plane address")
55-
5651
return err
5752
}
5853
tenantControlPlane.Status.ControlPlaneEndpoint = net.JoinHostPort(address, strconv.FormatInt(int64(tenantControlPlane.Spec.NetworkProfile.Port), 10))

0 commit comments

Comments
 (0)