Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change restart policy on gvisor pod #3445

Merged
merged 3 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
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)
}

// TODO: @priyawadhwa to add test for stop as well
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
3 changes: 1 addition & 2 deletions test/integration/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ func (m *MinikubeRunner) SSH(command string) (string, error) {
func (m *MinikubeRunner) Start() {
switch r := m.Runtime; r {
case constants.ContainerdRuntime:
// TODO: priyawadhwa@ remove iso url once updated iso is being used in integration tests
containerdFlags := "--container-runtime=containerd --network-plugin=cni --docker-opt containerd=/var/run/containerd/containerd.sock --iso-url=https://storage.googleapis.com/k8s-minikube/gvisor-preview.iso"
containerdFlags := "--container-runtime=containerd --network-plugin=cni --docker-opt containerd=/var/run/containerd/containerd.sock"
m.RunCommand(fmt.Sprintf("start %s %s %s", m.StartArgs, m.Args, containerdFlags), true)
default:
m.RunCommand(fmt.Sprintf("start %s %s", m.StartArgs, m.Args), true)
Expand Down