Problem
readGuestKubeconfig and retryRunPrivileged use local time.Now deadlines and time.Sleep calls without a context. When the VMI watch cancels the agent, SSH is closed, but these loops can continue trying until their local timeout.
References
cmd/crc-agent/guest.go:441-488
cmd/crc-agent/sshrunner.go:79-94
Suggested direction
Pass the caller context into both retry functions and use the existing wait.PollUntilContextTimeout pattern. Keep SSH closure so cancellation also interrupts blocked commands. Apply the configured SSHReadyTimeout to WaitForConnectivity and use a context-aware dial.
Tests
Add cancellation tests that verify prompt return and no further attempts, plus timeout coverage for SSH connectivity.
Problem
readGuestKubeconfigandretryRunPrivilegeduse localtime.Nowdeadlines andtime.Sleepcalls without a context. When the VMI watch cancels the agent, SSH is closed, but these loops can continue trying until their local timeout.References
cmd/crc-agent/guest.go:441-488cmd/crc-agent/sshrunner.go:79-94Suggested direction
Pass the caller context into both retry functions and use the existing
wait.PollUntilContextTimeoutpattern. Keep SSH closure so cancellation also interrupts blocked commands. Apply the configuredSSHReadyTimeouttoWaitForConnectivityand use a context-aware dial.Tests
Add cancellation tests that verify prompt return and no further attempts, plus timeout coverage for SSH connectivity.