From e84e5f384eb425e64386f4574cd1e53db1b207d9 Mon Sep 17 00:00:00 2001 From: Lily Pan Date: Tue, 19 May 2026 16:29:45 -0700 Subject: [PATCH] add validator to ensure unused cached kube binaries are cleaned up --- e2e/validation.go | 1 + e2e/validators.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/e2e/validation.go b/e2e/validation.go index 3cf65423dd0..6f063fb8d86 100644 --- a/e2e/validation.go +++ b/e2e/validation.go @@ -131,6 +131,7 @@ func ValidateCommonLinux(ctx context.Context, s *Scenario) { // ensure that no unexpected systemd units are in a failed state ValidateNoFailedSystemdUnits(ctx, s) + ValidateStaleCachedKubeBinariesRemoved(ctx, s) } func ValidateCommonWindows(ctx context.Context, s *Scenario) { diff --git a/e2e/validators.go b/e2e/validators.go index 96597ada092..4564c1e3780 100644 --- a/e2e/validators.go +++ b/e2e/validators.go @@ -2577,6 +2577,19 @@ func ValidateScriptlessNBCCSECmd(ctx context.Context, s *Scenario) { } } +// ValidateStaleCachedKubeBinariesRemoved validates that stale versioned kube binaries (e.g. kubelet-1.29.0, kubectl-1.29.0) +// have been removed from /opt/bin/ after the correct version is installed. +func ValidateStaleCachedKubeBinariesRemoved(ctx context.Context, s *Scenario) { + s.T.Helper() + // List any remaining versioned kubelet/kubectl binaries in /opt/bin/ + cmd := `find /opt/bin -maxdepth 1 \( -name "kubelet-*" -o -name "kubectl-*" \) -type f 2>/dev/null` + result := execScriptOnVMForScenarioValidateExitCode(ctx, s, cmd, 0, "could not list stale cached binaries") + staleFiles := strings.TrimSpace(result.stdout) + if staleFiles != "" { + s.T.Fatalf("expected no stale cached binaries in /opt/bin/, but found:\n%s", staleFiles) + } +} + // ValidateRxBufferDefault validates rx buffer config using default values based on VM's CPU count func ValidateRxBufferDefault(ctx context.Context, s *Scenario) { s.T.Helper()