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

Don't fail preflight when only docker-containerd is available #512

Merged
merged 3 commits into from
Jan 29, 2020
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
1 change: 1 addition & 0 deletions cmd/ignite/cmd/vmcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
29 changes: 15 additions & 14 deletions docs/cli/ignite/ignite_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ ignite run <OCI image> [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[=<path>] Enable SSH for the VM. If <path> 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[=<path>] Enable SSH for the VM. If <path> 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
Expand Down
7 changes: 4 additions & 3 deletions docs/cli/ignite/ignite_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ ignite start <vm> [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
Expand Down
29 changes: 15 additions & 14 deletions docs/cli/ignite/ignite_vm_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ ignite vm run <OCI image> [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[=<path>] Enable SSH for the VM. If <path> 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[=<path>] Enable SSH for the VM. If <path> 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
Expand Down
7 changes: 4 additions & 3 deletions docs/cli/ignite/ignite_vm_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ ignite vm start <vm> [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
Expand Down
34 changes: 20 additions & 14 deletions pkg/preflight/checkers/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/runtime/containerd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down