Skip to content

Commit 36e1ea5

Browse files
committed
make 2nd probe call to test new connection
1 parent 4852b67 commit 36e1ea5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

controllers/clustercache/cluster_accessor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,20 @@ func (ca *clusterAccessor) HealthCheck(ctx context.Context) (bool, bool) {
340340

341341
ca.rLock(ctx)
342342
restClient := ca.lockedState.connection.restClient
343+
restConfig := ca.lockedState.connection.restConfig
343344
ca.rUnlock(ctx)
344345

345346
log.V(6).Info("Run health probe")
346347

347348
// Executing the health probe is intentionally done without a lock to avoid blocking other reconcilers.
348349
_, err := restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
350+
if err == nil {
351+
// Execute health probe with a new restClient (this verifies that a new connection works).
352+
restClient, err = rest.UnversionedRESTClientFor(restConfig)
353+
if err == nil {
354+
_, err = restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
355+
}
356+
}
349357

350358
ca.lock(ctx)
351359
defer ca.unlock(ctx)

0 commit comments

Comments
 (0)