Skip to content

Commit

Permalink
Change restart policy on gvisor pod
Browse files Browse the repository at this point in the history
Change the restart policy on the gvisor pod to Always. This way, if a
user runs

minikube addons enable gvisor
minikube stop
minikube start

when the addon manager tries to restart the gvisor pod, it will be
restarted and gvisor will start running automatically. This PR also adds an
integration test for this functionality.
  • Loading branch information
Priya Wadhwa committed Dec 11, 2018
1 parent d7c0b48 commit a5e6cf6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deploy/addons/gvisor/gvisor-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ spec:
- name: gvisor
hostPath:
path: /tmp/gvisor
restartPolicy: Never
restartPolicy: Always
56 changes: 46 additions & 10 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"testing"
"time"

"github.com/docker/machine/libmachine/state"
"k8s.io/apimachinery/pkg/labels"
pkgutil "k8s.io/minikube/pkg/util"
"k8s.io/minikube/test/integration/util"
Expand Down Expand Up @@ -186,19 +187,14 @@ func testServicesList(t *testing.T) {

func testGvisor(t *testing.T) {
minikubeRunner := NewMinikubeRunner(t)
kubectlRunner := util.NewKubectlRunner(t)
minikubeRunner.RunCommand("addons enable gvisor", true)

t.Log("waiting for gvisor controller to come up")
if err := util.WaitForGvisorControllerRunning(t); err != nil {
t.Fatalf("waiting for gvisor controller to be up: %v", err)
}

untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml")
t.Log("creating pod with untrusted workload annotation")
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", untrustedPath}); err != nil {
t.Fatalf("creating untrusted nginx resource: %v", err)
}
createUntrustedWorkload(t)

t.Log("making sure untrusted workload is Running")
if err := util.WaitForUntrustedNginxRunning(); err != nil {
Expand All @@ -212,16 +208,56 @@ func testGvisor(t *testing.T) {
t.Fatalf("waiting for gvisor controller to be deleted: %v", err)
}

t.Log("recreating untrusted workload pod")
if _, err := kubectlRunner.RunCommand([]string{"replace", "-f", untrustedPath, "--force"}); err != nil {
t.Fatalf("replacing untrusted nginx resource: %v", err)
}
createUntrustedWorkload(t)

t.Log("waiting for FailedCreatePodSandBox event")
if err := util.WaitForFailedCreatePodSandBoxEvent(); err != nil {
t.Fatalf("waiting for FailedCreatePodSandBox event: %v", err)
}
deleteUntrustedWorkload(t)
}

func testGvisorRestart(t *testing.T) {
minikubeRunner := NewMinikubeRunner(t)
minikubeRunner.EnsureRunning()
fmt.Println("enabling gvisor")
minikubeRunner.RunCommand("addons enable gvisor", true)

t.Log("waiting for gvisor controller to come up")
if err := util.WaitForGvisorControllerRunning(t); err != nil {
t.Fatalf("waiting for gvisor controller to be up: %v", err)
}

minikubeRunner.RunCommand("delete", false)
minikubeRunner.CheckStatus(state.None.String())
minikubeRunner.Start()
minikubeRunner.CheckStatus(state.Running.String())

t.Log("waiting for gvisor controller to come up")
if err := util.WaitForGvisorControllerRunning(t); err != nil {
t.Fatalf("waiting for gvisor controller to be up: %v", err)
}

createUntrustedWorkload(t)
t.Log("making sure untrusted workload is Running")
if err := util.WaitForUntrustedNginxRunning(); err != nil {
t.Fatalf("waiting for nginx to be up: %v", err)
}
deleteUntrustedWorkload(t)
}

func createUntrustedWorkload(t *testing.T) {
kubectlRunner := util.NewKubectlRunner(t)
untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml")
t.Log("creating pod with untrusted workload annotation")
if _, err := kubectlRunner.RunCommand([]string{"replace", "-f", untrustedPath, "--force"}); err != nil {
t.Fatalf("creating untrusted nginx resource: %v", err)
}
}

func deleteUntrustedWorkload(t *testing.T) {
kubectlRunner := util.NewKubectlRunner(t)
untrustedPath, _ := filepath.Abs("testdata/nginx-untrusted.yaml")
if _, err := kubectlRunner.RunCommand([]string{"delete", "-f", untrustedPath}); err != nil {
t.Logf("error deleting untrusted nginx resource: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestFunctionalContainerd(t *testing.T) {
minikubeRunner.EnsureRunning()

t.Run("Gvisor", testGvisor)
t.Run("GvisorRestart", testGvisorRestart)
minikubeRunner.RunCommand("delete", true)
}

Expand Down

0 comments on commit a5e6cf6

Please sign in to comment.