Skip to content

🌱 log less values in hbmh Reconcile. #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions controllers/hetznerbaremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
log := ctrl.LoggerFrom(ctx)

start := time.Now()
defer func() {
// check duration of reconcile. Warn if it took too long.
duration := time.Since(start)
if duration > 15*time.Second {
log.Info("Reconcile took too long", "duration", duration, "res", res, "reterr", reterr)
}
}()

// Fetch the Hetzner bare metal host instance.
bmHost := &infrav1.HetznerBareMetalHost{}
Expand All @@ -87,10 +80,18 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
return reconcile.Result{}, err
}

log = log.WithValues("state", bmHost.Spec.Status.ProvisioningState)
ctx = ctrl.LoggerInto(ctx, log)

initialProvisioningState := bmHost.Spec.Status.ProvisioningState
defer func() {
// check duration of reconcile. Warn if it took too long.
duration := time.Since(start)
if duration > 10*time.Second {
log.Info("Reconcile took too long", "duration", duration, "res", res, "reterr", reterr)
}
if initialProvisioningState != bmHost.Spec.Status.ProvisioningState {
log.Info("Provisioning state changed", "from", initialProvisioningState, "to", bmHost.Spec.Status.ProvisioningState)
log.Info("Provisioning state changed", "newState", bmHost.Spec.Status.ProvisioningState, "duration", duration)
}
}()

Expand Down Expand Up @@ -140,6 +141,7 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
}
if err := r.Client.Get(ctx, hetznerClusterName, hetznerCluster); err != nil {
if apierrors.IsNotFound(err) {
log.Info("HetznerCluster not found. Requeueing")
return reconcile.Result{RequeueAfter: 10 * time.Second}, nil
}
return reconcile.Result{}, fmt.Errorf("failed to get HetznerCluster: %w", err)
Expand All @@ -153,8 +155,6 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
return reconcile.Result{}, fmt.Errorf("failed to get Cluster: %w", err)
}

log = log.WithValues("Cluster", klog.KObj(cluster))

hetznerBareMetalMachine := &infrav1.HetznerBareMetalMachine{}

if bmHost.Spec.ConsumerRef != nil {
Expand All @@ -170,8 +170,6 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl

log = log.WithValues("HetznerBareMetalMachine", klog.KObj(hetznerBareMetalMachine))

ctx = ctrl.LoggerInto(ctx, log)

// Get Hetzner robot api credentials
secretManager := secretutil.NewSecretManager(log, r.Client, r.APIReader)
robotCreds, err := getAndValidateRobotCredentials(ctx, req.Namespace, hetznerCluster, secretManager)
Expand Down
Loading