Skip to content

Commit 266c5aa

Browse files
committed
plumb root context through restart polling logic
1 parent 21b06c5 commit 266c5aa

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

pkg/controllers/kube-apiserver.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ import (
5555
)
5656

5757
const (
58-
kubeAPIStartupTimeout = 60
58+
kubeAPIStartupTimeout = 60 * time.Second
5959
// rbacHookDeadlockTimeout is the time to wait for the RBAC bootstrap hook
6060
// before declaring a deadlock. This is shorter than kubeAPIStartupTimeout
6161
// to allow for faster recovery.
62-
rbacHookDeadlockTimeout = 15
62+
rbacHookDeadlockTimeout = 15 * time.Second
6363
// rbacHookCheckInterval is how often to check the RBAC hook status
6464
rbacHookPollDelayStart = 5 * time.Second
65-
rbacHookCheckInterval = 2
65+
rbacHookCheckInterval = 2 * time.Second
6666
// rbacHookMaxWaitDuration is the absolute maximum time to wait for the RBAC hook
6767
// regardless of etcd health state changes. This prevents flapping from extending
6868
// detection indefinitely.
@@ -368,7 +368,7 @@ func (s *KubeAPIServer) Run(ctx context.Context, ready chan<- struct{}, stopped
368368

369369
// Run standard readiness check
370370
go func() {
371-
err := wait.PollUntilContextTimeout(ctx, time.Second, kubeAPIStartupTimeout*time.Second, true, func(ctx context.Context) (bool, error) {
371+
err := wait.PollUntilContextTimeout(ctx, time.Second, kubeAPIStartupTimeout, true, func(ctx context.Context) (bool, error) {
372372
var status int
373373
if err := restClient.Get().AbsPath("/readyz").Do(ctx).StatusCode(&status).Error(); err != nil {
374374
klog.Infof("%q not yet ready: %v", s.Name(), err)
@@ -440,7 +440,7 @@ func (s *KubeAPIServer) Run(ctx context.Context, ready chan<- struct{}, stopped
440440
panic(perr)
441441
case <-rbacDeadlockDetected:
442442
klog.Error("RBAC bootstrap hook deadlock detected - restarting microshift-etcd.scope to recover")
443-
if err := restartMicroshiftEtcdScope(); err != nil {
443+
if err := restartMicroshiftEtcdScope(ctx); err != nil {
444444
klog.Errorf("Failed to restart microshift-etcd.scope: %v", err)
445445
}
446446
return fmt.Errorf("RBAC bootstrap hook deadlock detected after %d seconds", rbacHookDeadlockTimeout)
@@ -583,11 +583,11 @@ func isEtcdHealthy(ctx context.Context) (bool, error) {
583583

584584
// restartMicroshiftEtcdScope restarts the microshift-etcd.scope to recover from deadlock.
585585
// This forces a clean restart of etcd which can help break the circular dependency.
586-
func restartMicroshiftEtcdScope() error {
586+
func restartMicroshiftEtcdScope(ctx context.Context) error {
587587
klog.Info("Stopping microshift-etcd.scope for recovery")
588588

589589
// Set a timeout in case systemd or DBus stalls and the fail-fast recovery path hangs and Run never returns
590-
cmdCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
590+
cmdCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
591591
defer cancel()
592592

593593
stopCmd := exec.CommandContext(cmdCtx, "systemctl", "stop", "microshift-etcd.scope")

0 commit comments

Comments
 (0)