Skip to content

Commit

Permalink
Use --kubelet-root-dir in a couple of inttests
Browse files Browse the repository at this point in the history
Use --kubelet-root-dir for the inttests:
- kubeletcertrotate
- reset

Signed-off-by: Natanael Copa <[email protected]>
  • Loading branch information
ncopa committed Nov 7, 2024
1 parent 3283caf commit 2d7aed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inttest/kubeletcertrotate/kubeletcertrotate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *kubeletCertRotateSuite) SetupTest() {
s.Require().NoError(err)

// Start the workers using the join token
s.Require().NoError(s.RunWorkersWithToken(workerJoinToken))
s.Require().NoError(s.RunWorkersWithToken(workerJoinToken, "--kubelet-root-dir=/var/lib/kubelet"))

client, err := s.KubeClient(s.ControllerNode(0))
s.Require().NoError(err)
Expand All @@ -74,7 +74,7 @@ func (s *kubeletCertRotateSuite) SetupTest() {
workerSSH, err := s.SSH(s.Context(), s.WorkerNode(0))
s.Require().NoError(err)
s.T().Log("waiting to see kubelet rotating the client cert before triggering Plan creation")
_, err = workerSSH.ExecWithOutput(s.Context(), "inotifywait --no-dereference /var/lib/k0s/kubelet/pki/kubelet-client-current.pem")
_, err = workerSSH.ExecWithOutput(s.Context(), "inotifywait --no-dereference /var/lib/kubelet/pki/kubelet-client-current.pem")
s.Require().NoError(err)
output, err := workerSSH.ExecWithOutput(s.Context(), "k0s status -ojson")
s.Require().NoError(err)
Expand Down
6 changes: 4 additions & 2 deletions inttest/reset/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *suite) TestReset() {

if ok := s.Run("k0s gets up", func() {
s.Require().NoError(s.InitController(0, "--disable-components=konnectivity-server,metrics-server"))
s.Require().NoError(s.RunWorkers())
s.Require().NoError(s.RunWorkers("--kubelet-root-dir=/var/lib/kubelet"))

kc, err := s.KubeClient(s.ControllerNode(0))
s.Require().NoError(err)
Expand All @@ -55,18 +55,20 @@ func (s *suite) TestReset() {

s.NoError(ssh.Exec(ctx, "test -d /var/lib/k0s", common.SSHStreams{}), "/var/lib/k0s is not a directory")
s.NoError(ssh.Exec(ctx, "test -d /run/k0s", common.SSHStreams{}), "/run/k0s is not a directory")
s.NoError(ssh.Exec(ctx, "test -d /var/lib/kubelet", common.SSHStreams{}), "/var/lib/kubelet is not a directory")

s.NoError(ssh.Exec(ctx, "pidof containerd-shim-runc-v2 >&2", common.SSHStreams{}), "Expected some running containerd shims")

s.NoError(s.StopWorker(workerNode), "Failed to stop k0s")

streams, flushStreams := common.TestLogStreams(s.T(), "reset")
err = ssh.Exec(ctx, "k0s reset --debug", streams)
err = ssh.Exec(ctx, "k0s reset --debug --kubelet-root-dir=/var/lib/kubelet", streams)
flushStreams()
s.NoError(err, "k0s reset didn't exit cleanly")

// /var/lib/k0s is a mount point in the Docker container and can't be deleted, so it must be empty
s.NoError(ssh.Exec(ctx, `x="$(ls -A /var/lib/k0s)" && echo "$x" >&2 && [ -z "$x" ]`, common.SSHStreams{}), "/var/lib/k0s is not empty")
s.NoError(ssh.Exec(ctx, "! test -e /var/lib/kubelet", common.SSHStreams{}), "/var/lib/kubelet still exists")
s.NoError(ssh.Exec(ctx, "! test -e /run/k0s", common.SSHStreams{}), "/run/k0s still exists")
s.NoError(ssh.Exec(ctx, "! pidof containerd-shim-runc-v2 >&2", common.SSHStreams{}), "Expected no running containerd shims")
})
Expand Down

0 comments on commit 2d7aed2

Please sign in to comment.