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

introduce requirements.nesting for images #650

Merged
merged 3 commits into from
Mar 24, 2024
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
4 changes: 4 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2400,3 +2400,7 @@ This adds `balanced` as a new value for `limits.cpu.nodes`.
When set to `balanced`, Incus will attempt to select the least busy NUMA
node at startup time for the instance, trying to keep the load spread
across NUMA nodes on the system.

## `image_restriction_nesting`

This extension adds a new image restriction, `requirements.nesting` which when `true` indicates that an image cannot be run without nesting.
1 change: 1 addition & 0 deletions doc/image-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ Key | Type | Default | Descrip
:-- | :--- | :------ | :----------
`requirements.cdrom_agent` | bool | - | If set to `true`, indicates that the VM requires an `agent:config` disk be added.
`requirements.cgroup` | string | - | If set to `v1`, indicates that the image requires the host to run cgroup v1.
`requirements.nesting` | bool | - | If set to `true`, indicates that the image cannot work without nesting enabled.
`requirements.privileged` | bool | - | If set to `false`, indicates that the image cannot work as a privileged container.
`requirements.secureboot` | bool | - | If set to `false`, indicates that the image cannot boot under secure boot.
15 changes: 15 additions & 0 deletions internal/server/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,21 @@ func (d *lxc) onStart(_ map[string]string) error {
return nil
}

// validateStartup checks any constraints that would prevent start up from succeeding under normal circumstances.
func (d *lxc) validateStartup(stateful bool, statusCode api.StatusCode) error {
err := d.common.validateStartup(stateful, statusCode)
if err != nil {
return err
}

// Ensure nesting is turned on for images that require nesting.
if util.IsTrue(d.localConfig["image.requirements.nesting"]) && util.IsFalseOrEmpty(d.expandedConfig["security.nesting"]) {
adamcstephens marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("The image used by this instance requires nesting. Please set security.nesting=true on the instance")
}

return nil
}

// Stop functions.
func (d *lxc) Stop(stateful bool) error {
d.logger.Debug("Stop started", logger.Ctx{"stateful": stateful})
Expand Down
1 change: 1 addition & 0 deletions internal/version/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ var APIExtensions = []string{
"oidc_claim",
"device_usb_serial",
"numa_cpu_balanced",
"image_restriction_nesting",
}

// APIExtensionsCount returns the number of available API extensions.
Expand Down
Loading