Skip to content

Commit 91c619e

Browse files
authored
Merge pull request #618 from vdice/fix/k3d-restart
fix(containerd): update restart for k3d scenarios
2 parents 83f6cf4 + 4ff67ff commit 91c619e

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

.github/workflows/helm-chart-smoketest.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ jobs:
172172
run: kubectl label node --all spin=true
173173

174174
- name: verify only one installer pod with Succeeded status
175-
# TODO: provisioning on k3d still leads to the first installer pod finishing with provisioner status Unknown and phase Failed
176-
if: matrix.config.type != 'k3d'
177175
run: |
178176
timeout 60s bash -c 'until [[ "$(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.status.phase}" 2>/dev/null)" == "Succeeded" ]]; do sleep 2; done'
179177
@@ -201,8 +199,7 @@ jobs:
201199
kubectl describe runtimeclass wasmtime-spin-v2
202200
203201
# Get install pod logs
204-
# Note: there may be multiple pods pending k3d fix for issue https://github.com/spinframework/runtime-class-manager/issues/393
205-
install_pod=$(kubectl get pods -n rcm --no-headers -o name | awk '{if ($1 ~ "-spin-v2-install") print $0}' | tail -n 1)
202+
install_pod=$(kubectl get pods -n rcm --no-headers -o name | awk '{if ($1 ~ "-spin-v2-install") print $0}')
206203
kubectl describe -n rcm $install_pod || true
207204
kubectl logs -n rcm -c downloader $install_pod || true
208205
kubectl logs -n rcm -c provisioner $install_pod || true

internal/containerd/restart_unix.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,14 @@ func (c K3sRestarter) Restart() error {
9696
return fmt.Errorf("unable to restart k3s: %w", err)
9797
}
9898
} else {
99-
// TODO: this approach still leads to the behavior mentioned in https://github.com/spinframework/runtime-class-manager/issues/140:
100-
// The first pod's provisioner container exits with code 255, leading to pod status Unknown,
101-
// followed by the subsequent pod's provisioner container no-op-ing and finishing with status Completed.
102-
pid, err := getPid("k3s")
103-
if err != nil {
104-
return err
105-
}
106-
slog.Debug("found k3s process", "pid", pid)
107-
108-
err = syscall.Kill(pid, syscall.SIGHUP)
99+
// Assuming k3d; PID 1 is the main k3d entrypoint which should be restarted
100+
// rather than the nested k3s process
101+
out, err := nsenterCmd("kill", "1").CombinedOutput()
102+
slog.Debug(string(out))
109103
if err != nil {
110-
return fmt.Errorf("failed to send SIGHUP to k3s: %w", err)
104+
return fmt.Errorf("unable to restart k3s via TERM signal to PID 1: %w", err)
111105
}
112106
}
113-
114107
return nil
115108
}
116109

0 commit comments

Comments
 (0)