Skip to content

Commit 283f94a

Browse files
committed
combine condition check to make it more compact
1 parent 03b6dd6 commit 283f94a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

controllers/clustercache/cluster_cache.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,18 +512,11 @@ func (cc *clusterCache) Reconcile(ctx context.Context, req reconcile.Request) (r
512512
requeueAfterDurations = append(requeueAfterDurations, accessor.config.HealthProbe.Interval)
513513
}
514514
}
515-
}
516-
517-
// Send events to cluster sources.
518-
lastProbeSuccessTime := accessor.GetLastProbeSuccessTimestamp(ctx)
519-
cc.sendEventsToClusterSources(ctx, cluster, time.Now(), lastProbeSuccessTime, didConnect, didDisconnect)
520515

521-
// Check if kubeconfig was updated (only when connected).
522-
if connected {
516+
// Check if kubeconfig was updated
523517
kubeconfigUpdated, err := accessor.KubeConfigUpdated(ctx)
524518
if err != nil {
525519
log.Error(err, "error checking if kubeconfig was updated")
526-
// Don't return error here, just log it and continue
527520
} else if kubeconfigUpdated {
528521
log.Info("Kubeconfig was updated, disconnecting to re-connect with the new kubeconfig")
529522
accessor.Disconnect(ctx)
@@ -532,6 +525,10 @@ func (cc *clusterCache) Reconcile(ctx context.Context, req reconcile.Request) (r
532525
}
533526
}
534527

528+
// Send events to cluster sources.
529+
lastProbeSuccessTime := accessor.GetLastProbeSuccessTimestamp(ctx)
530+
cc.sendEventsToClusterSources(ctx, cluster, time.Now(), lastProbeSuccessTime, didConnect, didDisconnect)
531+
535532
// Requeue based on requeueAfterDurations (fallback to defaultRequeueAfter).
536533
return reconcile.Result{RequeueAfter: minDurationOrDefault(requeueAfterDurations, defaultRequeueAfter)}, nil
537534
}

0 commit comments

Comments
 (0)