Skip to content

Commit 8e7dc16

Browse files
committed
make 2nd probe call to test new connection
1 parent 4aecb73 commit 8e7dc16

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
@@ -344,12 +344,20 @@ func (ca *clusterAccessor) HealthCheck(ctx context.Context) (bool, bool) {
344344

345345
ca.rLock(ctx)
346346
restClient := ca.lockedState.connection.restClient
347+
restConfig := ca.lockedState.connection.restConfig
347348
ca.rUnlock(ctx)
348349

349350
log.V(6).Info("Run health probe")
350351

351352
// Executing the health probe is intentionally done without a lock to avoid blocking other reconcilers.
352353
_, err := restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
354+
if err == nil {
355+
// Execute health probe with a new restClient (this verifies that a new connection works).
356+
restClient, err = rest.UnversionedRESTClientFor(restConfig)
357+
if err == nil {
358+
_, err = restClient.Get().AbsPath("/").Timeout(ca.config.HealthProbe.Timeout).DoRaw(ctx)
359+
}
360+
}
353361

354362
ca.lock(ctx)
355363
defer ca.unlock(ctx)

0 commit comments

Comments
 (0)