Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

improve preflight check and add a containerd test case for ignite run #416

Merged
merged 2 commits into from
Sep 11, 2019
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
36 changes: 31 additions & 5 deletions e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ import (
"gotest.tools/assert"
)

var e2eHome = os.Getenv("IGNITE_E2E_HOME")

func TestIgniteRunWithDockerAndDockerBridge(t *testing.T) {
// vmName should be unique for each test
const vmName = "e2e_test_ignite_run_docker_docker_bridge"
const vmName = "e2e_test_ignite_run_docker_and_docker_bridge"

dir := os.Getenv("IGNITE_E2E_HOME")
assert.Assert(t, dir != "", "IGNITE_E2E_HOME should be set")
assert.Assert(t, e2eHome != "", "IGNITE_E2E_HOME should be set")

binary := path.Join(dir, "bin/ignite")
binary := path.Join(e2eHome, "bin/ignite")
cmd := exec.Command(binary,
"--runtime=docker",
"--network-plugin=docker-bridge",
"run", "--name=" + vmName,
"run", "--name="+vmName,
"weaveworks/ignite-ubuntu")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand All @@ -46,3 +47,28 @@ func TestIgniteRunWithDockerAndDockerBridge(t *testing.T) {

assert.Check(t, err, fmt.Sprintf("%q should not fail to run", cmd.Args))
}

func TestIgniteRunWithContainerdAndCNI(t *testing.T) {
// vmName should be unique for each test
const vmName = "e2e_test_ignite_run_containerd_and_cni"

binary := path.Join(e2eHome, "bin/ignite")
cmd := exec.Command(binary,
"--runtime=containerd",
"--network-plugin=cni",
"run", "--name="+vmName,
"weaveworks/ignite-ubuntu")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()

defer func() {
cmd := exec.Command(binary,
"--runtime=containerd",
"--network-plugin=cni",
"rm", "-f", vmName)
assert.Check(t, cmd.Run(), "vm removal should not fail")
}()

assert.Check(t, err, fmt.Sprintf("%q should not fail to run", cmd.Args))
}
13 changes: 12 additions & 1 deletion pkg/constants/dependencies.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package constants

var Dependencies = [...]string{
var BinaryDependencies = [...]string{
"mount",
"umount",
"tar",
Expand All @@ -13,3 +13,14 @@ var Dependencies = [...]string{
"ssh",
"git",
}

var PathDependencies = [...]string{
"/dev/mapper/control",
"/dev/net/tun",
"/dev/kvm",
}

var CNIDependencies = [...]string{
"/opt/cni/bin/loopback",
"/opt/cni/bin/bridge",
}
18 changes: 11 additions & 7 deletions pkg/preflight/checkers/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/constants"
"github.com/weaveworks/ignite/pkg/network"
"github.com/weaveworks/ignite/pkg/preflight"
"github.com/weaveworks/ignite/pkg/providers"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -94,17 +95,20 @@ type AvailablePathChecker struct {
}

func StartCmdChecks(vm *api.VM, ignoredPreflightErrors sets.String) error {
// the number "4" is chosen for the static preflight checkers see below
nCheckers := 4 + len(vm.Spec.Network.Ports) + len(constants.Dependencies)
checks := make([]preflight.Checker, 0, nCheckers)
checks = append(checks, ExistingFileChecker{filePath: "/dev/mapper/control"})
checks = append(checks, ExistingFileChecker{filePath: "/dev/net/tun"})
checks = append(checks, ExistingFileChecker{filePath: "/dev/kvm"})
checks := []preflight.Checker{}
for _, dependency := range constants.PathDependencies {
checks = append(checks, ExistingFileChecker{filePath: dependency})
}
if providers.NetworkPluginName == network.PluginCNI {
for _, dependency := range constants.CNIDependencies {
checks = append(checks, ExistingFileChecker{filePath: dependency})
}
}
checks = append(checks, providers.Runtime.PreflightChecker())
for _, port := range vm.Spec.Network.Ports {
checks = append(checks, PortOpenChecker{port: port.HostPort})
}
for _, dependency := range constants.Dependencies {
for _, dependency := range constants.BinaryDependencies {
checks = append(checks, BinInPathChecker{bin: dependency})
}
return runChecks(checks, ignoredPreflightErrors)
Expand Down