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

Fix volatile key definitions #519

Merged
merged 2 commits into from
Feb 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 60 additions & 0 deletions doc/config_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,36 @@ Comma-separated list of the last used IP addresses of the network device.
The original MTU that was used when moving a physical device into an instance.
```

```{config:option} volatile.<name>.last_state.pci.driver instance-volatile
:shortdesc: "PCI original host driver"
:type: "string"
The original host driver for the PCI device.
```

```{config:option} volatile.<name>.last_state.pci.parent instance-volatile
:shortdesc: "PCI parent host device"
:type: "string"
The parent host device used when allocating a PCI device to an instance.
```

```{config:option} volatile.<name>.last_state.pci.slot.name instance-volatile
:shortdesc: "PCI parent slot name"
:type: "string"
The parent host device PCI slot name.
```

```{config:option} volatile.<name>.last_state.usb.bus instance-volatile
:shortdesc: "USB bus address"
:type: "string"
The original USB bus address.
```

```{config:option} volatile.<name>.last_state.usb.device instance-volatile
:shortdesc: "USB device identifier"
:type: "string"
The original USB device identifier.
```

```{config:option} volatile.<name>.last_state.vdpa.name instance-volatile
:shortdesc: "VDPA device name"
:type: "string"
Expand All @@ -834,6 +864,12 @@ The original MAC used when moving a VF into an instance.
The ID used when moving a VF into an instance.
```

```{config:option} volatile.<name>.last_state.vf.parent instance-volatile
:shortdesc: "SR-IOV parent host device"
:type: "string"
The parent host device used when allocating a VF into an instance.
```

```{config:option} volatile.<name>.last_state.vf.spoofcheck instance-volatile
:shortdesc: "SR-IOV virtual function original spoof check setting"
:type: "string"
Expand All @@ -846,6 +882,24 @@ The original spoof check setting used when moving a VF into an instance.
The original VLAN used when moving a VF into an instance.
```

```{config:option} volatile.<name>.mig.uuid instance-volatile
:shortdesc: "MIG instance UUID"
:type: "string"
The NVIDIA MIG instance UUID.
```

```{config:option} volatile.<name>.name instance-volatile
:shortdesc: "Network interface name inside of the instance"
:type: "string"
The network interface name inside of the instance when no `name` property is set on the device itself.
```

```{config:option} volatile.<name>.vgpu.uuid instance-volatile
:shortdesc: "virtual GPU instance UUID"
:type: "string"
The NVIDIA virtual GPU instance UUID.
```

```{config:option} volatile.apply_nvram instance-volatile
:shortdesc: "Whether to regenerate VM NVRAM the next time the instance starts"
:type: "bool"
Expand Down Expand Up @@ -906,6 +960,12 @@ The cluster member that the instance lived on before evacuation.

```

```{config:option} volatile.last_state.ready instance-volatile
:shortdesc: "Instance marked itself as ready"
:type: "string"

```

```{config:option} volatile.uuid instance-volatile
:shortdesc: "Instance UUID"
:type: "string"
Expand Down
181 changes: 126 additions & 55 deletions internal/instance/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,14 @@ var InstanceConfigKeysAny = map[string]func(value string) error{
// type: string
// shortdesc: Instance state as of last host shutdown
"volatile.last_state.power": validate.IsAny,

// gendoc:generate(entity=instance, group=volatile, key=volatile.last_state.ready)
//
// ---
// type: string
// shortdesc: Instance marked itself as ready
"volatile.last_state.ready": validate.IsBool,
"volatile.apply_quota": validate.IsAny,

// gendoc:generate(entity=instance, group=volatile, key=volatile.uuid)
// The instance UUID is globally unique across all servers and projects.
// ---
Expand Down Expand Up @@ -511,6 +517,7 @@ var InstanceConfigKeysContainer = map[string]func(value string) error{
// condition: container
// shortdesc: Prevents the instance from being swapped to disk
"limits.memory.swap.priority": validate.Optional(validate.IsPriority),

// gendoc:generate(entity=instance, group=resource-limits, key=limits.processes)
// If left empty, no limit is set.
// ---
Expand Down Expand Up @@ -696,6 +703,7 @@ var InstanceConfigKeysContainer = map[string]func(value string) error{
// shortdesc: List of syscalls to allow
"security.syscalls.allow": validate.IsAny,

// Legacy configuration keys (old names).
"security.syscalls.blacklist_default": validate.Optional(validate.IsBool),
"security.syscalls.blacklist_compat": validate.Optional(validate.IsBool),
"security.syscalls.blacklist": validate.IsAny,
Expand Down Expand Up @@ -1032,51 +1040,66 @@ func ConfigKeyChecker(key string, instanceType api.InstanceType) (func(value str
}

if strings.HasPrefix(key, ConfigVolatilePrefix) {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.hwaddr)
// The original MAC that was used when moving a physical device into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.apply_quota)
// The disk quota is applied the next time the instance starts.
// ---
// type: string
// shortdesc: Network device original MAC
// shortdesc: Disk quota
if strings.HasSuffix(key, ".apply_quota") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.hwaddr)
// The network device MAC address is used when no `hwaddr` property is set on the device itself.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.ceph_rbd)
//
// ---
// type: string
// shortdesc: Network device MAC address
// shortdesc: RBD device path for Ceph disk devices
if strings.HasSuffix(key, ".ceph_rbd") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.hwaddr)
// The original MAC used when moving a VF into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.host_name)
//
// ---
// type: string
// shortdesc: SR-IOV virtual function original MAC
// shortdesc: Network device name on the host
if strings.HasSuffix(key, ".host_name") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.hwaddr)
// The network device MAC address is used when no `hwaddr` property is set on the device itself.
// ---
// type: string
// shortdesc: Network device MAC address
if strings.HasSuffix(key, ".hwaddr") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vdpa.name)
// The VDPA device name used when moving a VDPA device file descriptor into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.mig.uuid)
// The NVIDIA MIG instance UUID.
// ---
// type: string
// shortdesc: VDPA device name
if strings.HasSuffix(key, ".name") {
// shortdesc: MIG instance UUID
if strings.HasSuffix(key, ".mig.uuid") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.host_name)
//
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.name)
// The network interface name inside of the instance when no `name` property is set on the device itself.
// ---
// type: string
// shortdesc: Network device name on the host
if strings.HasSuffix(key, ".host_name") {
// shortdesc: Network interface name inside of the instance
if strings.HasSuffix(key, ".name") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.mtu)
// The original MTU that was used when moving a physical device into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.vgpu.uuid)
// The NVIDIA virtual GPU instance UUID.
// ---
// type: string
// shortdesc: Network device original MTU
if strings.HasSuffix(key, ".mtu") {
// shortdesc: virtual GPU instance UUID
if strings.HasSuffix(key, ".vgpu.uuid") {
return validate.IsAny, nil
}

Expand All @@ -1085,86 +1108,134 @@ func ConfigKeyChecker(key string, instanceType api.InstanceType) (func(value str
// ---
// type: string
// shortdesc: Whether the network device physical device was created
if strings.HasSuffix(key, ".created") {
if strings.HasSuffix(key, ".last_state.created") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.id)
// The ID used when moving a VF into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.hwaddr)
// The original MAC that was used when moving a physical device into an instance.
// ---
// type: string
// shortdesc: SR-IOV virtual function ID
if strings.HasSuffix(key, ".id") {
// shortdesc: Network device original MAC
if strings.HasSuffix(key, ".last_state.hwaddr") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.vlan)
// The original VLAN used when moving a VF into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.ip_addresses)
// Comma-separated list of the last used IP addresses of the network device.
// ---
// type: string
// shortdesc: SR-IOV virtual function original VLAN
if strings.HasSuffix(key, ".vlan") {
// shortdesc: Last used IP addresses
if strings.HasSuffix(key, ".last_state.ip_addresses") {
return validate.IsListOf(validate.IsNetworkAddress), nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.mtu)
// The original MTU that was used when moving a physical device into an instance.
// ---
// type: string
// shortdesc: Network device original MTU
if strings.HasSuffix(key, ".last_state.mtu") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.spoofcheck)
// The original spoof check setting used when moving a VF into an instance.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.pci.driver)
// The original host driver for the PCI device.
// ---
// type: string
// shortdesc: SR-IOV virtual function original spoof check setting
if strings.HasSuffix(key, ".spoofcheck") {
// shortdesc: PCI original host driver
if strings.HasSuffix(key, ".last_state.pci.driver") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".last_state.vf.parent") {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.pci.parent)
// The parent host device used when allocating a PCI device to an instance.
// ---
// type: string
// shortdesc: PCI parent host device
if strings.HasSuffix(key, ".last_state.pci.parent") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.ip_addresses)
// Comma-separated list of the last used IP addresses of the network device.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.pci.slot.name)
// The parent host device PCI slot name.
// ---
// type: string
// shortdesc: Last used IP addresses
if strings.HasSuffix(key, ".last_state.ip_addresses") {
return validate.IsListOf(validate.IsNetworkAddress), nil
// shortdesc: PCI parent slot name
if strings.HasSuffix(key, ".last_state.pci.slot.name") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.apply_quota)
// The disk quota is applied the next time the instance starts.
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.usb.bus)
// The original USB bus address.
// ---
// type: string
// shortdesc: Disk quota
if strings.HasSuffix(key, ".apply_quota") {
// shortdesc: USB bus address
if strings.HasSuffix(key, ".last_state.usb.bus") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.ceph_rbd)
//
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.usb.device)
// The original USB device identifier.
// ---
// type: string
// shortdesc: RBD device path for Ceph disk devices
if strings.HasSuffix(key, ".ceph_rbd") {
// shortdesc: USB device identifier
if strings.HasSuffix(key, ".last_state.usb.device") {
return validate.IsAny, nil
}

// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vdpa.name)
// The VDPA device name used when moving a VDPA device file descriptor into an instance.
// ---
// type: string
// shortdesc: VDPA device name
if strings.HasSuffix(key, ".last_state.vdpa.name") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".driver") {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.hwaddr)
// The original MAC used when moving a VF into an instance.
// ---
// type: string
// shortdesc: SR-IOV virtual function original MAC
if strings.HasSuffix(key, ".last_state.vf.hwaddr") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".bus") {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.id)
// The ID used when moving a VF into an instance.
// ---
// type: string
// shortdesc: SR-IOV virtual function ID
if strings.HasSuffix(key, ".last_state.vf.id") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".device") {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.parent)
// The parent host device used when allocating a VF into an instance.
// ---
// type: string
// shortdesc: SR-IOV parent host device
if strings.HasSuffix(key, ".last_state.vf.parent") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".uuid") {
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.spoofcheck)
// The original spoof check setting used when moving a VF into an instance.
// ---
// type: string
// shortdesc: SR-IOV virtual function original spoof check setting
if strings.HasSuffix(key, ".last_state.vf.spoofcheck") {
return validate.IsAny, nil
}

if strings.HasSuffix(key, ".last_state.ready") {
return validate.IsBool, nil
// gendoc:generate(entity=instance, group=volatile, key=volatile.<name>.last_state.vf.vlan)
// The original VLAN used when moving a VF into an instance.
// ---
// type: string
// shortdesc: SR-IOV virtual function original VLAN
if strings.HasSuffix(key, ".last_state.vf.vlan") {
return validate.IsAny, nil
}
}

Expand Down