From 9c70bbfa477eab0d1dace2f25c8e105f4ccb9574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20K=C3=A4ldstr=C3=B6m?= Date: Tue, 28 Jan 2020 16:23:06 +0200 Subject: [PATCH 1/3] Support docker-containerd-shim, too --- pkg/runtime/containerd/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/runtime/containerd/client.go b/pkg/runtime/containerd/client.go index ac44f4d90..db6623490 100644 --- a/pkg/runtime/containerd/client.go +++ b/pkg/runtime/containerd/client.go @@ -101,6 +101,12 @@ func getNewestAvailableContainerdRuntime() (string, error) { return plugin.RuntimeLinuxV1, nil } + // legacy fallback needs hard-coded binary name -- it's not exported by containerd/runtime/v1/shim + // this is for debian's packaging of docker.io + if _, err := exec.LookPath("docker-containerd-shim"); err == nil { + return plugin.RuntimeLinuxV1, nil + } + // default to the legacy runtime and return an error so the caller can decide what to do return plugin.RuntimeLinuxV1, fmt.Errorf("a containerd-shim could not be found for runtimes %v, %s", v2ShimRuntimes, plugin.RuntimeLinuxV1) } From 33d9838ab688ffccda42fa6334ff661afff74b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20K=C3=A4ldstr=C3=B6m?= Date: Tue, 28 Jan 2020 21:59:39 +0200 Subject: [PATCH 2/3] Allow docker-containerd too in the path check, and fixup some minor preflight errors --- cmd/ignite/cmd/vmcmd/start.go | 1 + pkg/preflight/checkers/checks.go | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cmd/ignite/cmd/vmcmd/start.go b/cmd/ignite/cmd/vmcmd/start.go index ca17796d2..66bb05a4d 100644 --- a/cmd/ignite/cmd/vmcmd/start.go +++ b/cmd/ignite/cmd/vmcmd/start.go @@ -42,4 +42,5 @@ func NewCmdStart(out io.Writer) *cobra.Command { func addStartFlags(fs *pflag.FlagSet, sf *run.StartFlags) { cmdutil.AddInteractiveFlag(fs, &sf.Interactive) fs.BoolVarP(&sf.Debug, "debug", "d", false, "Debug mode, keep container after VM shutdown") + fs.StringSliceVar(&sf.IgnoredPreflightErrors, "ignore-preflight-checks", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks.") } diff --git a/pkg/preflight/checkers/checks.go b/pkg/preflight/checkers/checks.go index 5e89e8ac8..3b11c810b 100644 --- a/pkg/preflight/checkers/checks.go +++ b/pkg/preflight/checkers/checks.go @@ -71,27 +71,28 @@ func (efc ExistingFileChecker) Type() string { } type BinInPathChecker struct { - bin string + // By default, this slice only contains one item. If it does contain more than one; + // at least one of them needs to be present in $PATH + binaryNames []string } func (bipc BinInPathChecker) Check() error { - _, err := exec.LookPath(bipc.bin) - if err != nil { - return fmt.Errorf("Bin %s is not in your PATH", bipc.bin) + for _, binary := range bipc.binaryNames { + _, err := exec.LookPath(binary) + if err == nil { + return nil + } } - return nil + + return fmt.Errorf("None of the following binaries %v seem to be in your PATH. Please install this tool before continuing.", bipc.binaryNames) } func (bipc BinInPathChecker) Name() string { - return "" + return fmt.Sprintf("BinaryInPath-%s", bipc.binaryNames[0]) } func (bipc BinInPathChecker) Type() string { - return "" -} - -type AvailablePathChecker struct { - path string + return "BinaryInPath" } func StartCmdChecks(vm *api.VM, ignoredPreflightErrors sets.String) error { @@ -112,12 +113,17 @@ func StartCmdChecks(vm *api.VM, ignoredPreflightErrors sets.String) error { // Binary name of the runtime is just the runtime name in string, "docker" or "containerd" // So it is OK for us to check only one of them, as people may installing only containerd but not docker - runtimeBinaryName := providers.RuntimeName.String() - checks = append(checks, BinInPathChecker{bin: runtimeBinaryName}) + runtimeBinaryNames := []string{providers.RuntimeName.String()} + if runtimeBinaryNames[0] == "containerd" { + // Also look for docker-containerd in case we're set to use containerd. + // In Debian 10 (at least), the docker.io package only installs containerd under the prefixed name + runtimeBinaryNames = append(runtimeBinaryNames, "docker-containerd") + } + checks = append(checks, BinInPathChecker{binaryNames: runtimeBinaryNames}) // Check common binaries for _, dependency := range constants.BinaryDependencies { - checks = append(checks, BinInPathChecker{bin: dependency}) + checks = append(checks, BinInPathChecker{binaryNames: []string{dependency}}) } return runChecks(checks, ignoredPreflightErrors) } From 401bdc04f631ccc32325f01eec0b5db933d6c910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20K=C3=A4ldstr=C3=B6m?= Date: Tue, 28 Jan 2020 21:59:52 +0200 Subject: [PATCH 3/3] autogenerated --- docs/cli/ignite/ignite_run.md | 29 +++++++++++++++-------------- docs/cli/ignite/ignite_start.md | 7 ++++--- docs/cli/ignite/ignite_vm_run.md | 29 +++++++++++++++-------------- docs/cli/ignite/ignite_vm_start.md | 7 ++++--- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/docs/cli/ignite/ignite_run.md b/docs/cli/ignite/ignite_run.md index 926caa84e..7232a6eb1 100644 --- a/docs/cli/ignite/ignite_run.md +++ b/docs/cli/ignite/ignite_run.md @@ -27,20 +27,21 @@ ignite run [flags] ### Options ``` - --config string Specify a path to a file with the API resources you want to pass - -f, --copy-files strings Copy files/directories from the host to the created VM - --cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1) - -d, --debug Debug mode, keep container after VM shutdown - -h, --help help for run - -i, --interactive Attach to the VM after starting - --kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp") - -k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:4.19.47) - --memory size Amount of RAM to allocate for the VM (default 512.0 MB) - -n, --name string Specify the name - -p, --ports strings Map host ports to VM ports - -s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB) - --ssh[=] Enable SSH for the VM. If is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM) - -v, --volumes volume Expose block devices from the host inside the VM + --config string Specify a path to a file with the API resources you want to pass + -f, --copy-files strings Copy files/directories from the host to the created VM + --cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1) + -d, --debug Debug mode, keep container after VM shutdown + -h, --help help for run + --ignore-preflight-checks strings A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks. + -i, --interactive Attach to the VM after starting + --kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp") + -k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:4.19.47) + --memory size Amount of RAM to allocate for the VM (default 512.0 MB) + -n, --name string Specify the name + -p, --ports strings Map host ports to VM ports + -s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB) + --ssh[=] Enable SSH for the VM. If is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM) + -v, --volumes volume Expose block devices from the host inside the VM ``` ### Options inherited from parent commands diff --git a/docs/cli/ignite/ignite_start.md b/docs/cli/ignite/ignite_start.md index cc733e482..46449d714 100644 --- a/docs/cli/ignite/ignite_start.md +++ b/docs/cli/ignite/ignite_start.md @@ -17,9 +17,10 @@ ignite start [flags] ### Options ``` - -d, --debug Debug mode, keep container after VM shutdown - -h, --help help for start - -i, --interactive Attach to the VM after starting + -d, --debug Debug mode, keep container after VM shutdown + -h, --help help for start + --ignore-preflight-checks strings A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks. + -i, --interactive Attach to the VM after starting ``` ### Options inherited from parent commands diff --git a/docs/cli/ignite/ignite_vm_run.md b/docs/cli/ignite/ignite_vm_run.md index 362ad270d..889502144 100644 --- a/docs/cli/ignite/ignite_vm_run.md +++ b/docs/cli/ignite/ignite_vm_run.md @@ -27,20 +27,21 @@ ignite vm run [flags] ### Options ``` - --config string Specify a path to a file with the API resources you want to pass - -f, --copy-files strings Copy files/directories from the host to the created VM - --cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1) - -d, --debug Debug mode, keep container after VM shutdown - -h, --help help for run - -i, --interactive Attach to the VM after starting - --kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp") - -k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:4.19.47) - --memory size Amount of RAM to allocate for the VM (default 512.0 MB) - -n, --name string Specify the name - -p, --ports strings Map host ports to VM ports - -s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB) - --ssh[=] Enable SSH for the VM. If is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM) - -v, --volumes volume Expose block devices from the host inside the VM + --config string Specify a path to a file with the API resources you want to pass + -f, --copy-files strings Copy files/directories from the host to the created VM + --cpus uint VM vCPU count, 1 or even numbers between 1 and 32 (default 1) + -d, --debug Debug mode, keep container after VM shutdown + -h, --help help for run + --ignore-preflight-checks strings A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks. + -i, --interactive Attach to the VM after starting + --kernel-args string Set the command line for the kernel (default "console=ttyS0 reboot=k panic=1 pci=off ip=dhcp") + -k, --kernel-image oci-image Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules (default weaveworks/ignite-kernel:4.19.47) + --memory size Amount of RAM to allocate for the VM (default 512.0 MB) + -n, --name string Specify the name + -p, --ports strings Map host ports to VM ports + -s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB) + --ssh[=] Enable SSH for the VM. If is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM) + -v, --volumes volume Expose block devices from the host inside the VM ``` ### Options inherited from parent commands diff --git a/docs/cli/ignite/ignite_vm_start.md b/docs/cli/ignite/ignite_vm_start.md index 4043da94d..6eac3a2b5 100644 --- a/docs/cli/ignite/ignite_vm_start.md +++ b/docs/cli/ignite/ignite_vm_start.md @@ -17,9 +17,10 @@ ignite vm start [flags] ### Options ``` - -d, --debug Debug mode, keep container after VM shutdown - -h, --help help for start - -i, --interactive Attach to the VM after starting + -d, --debug Debug mode, keep container after VM shutdown + -h, --help help for start + --ignore-preflight-checks strings A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks. + -i, --interactive Attach to the VM after starting ``` ### Options inherited from parent commands