Skip to content

Commit

Permalink
Rework Flavor Configuraiton (#40)
Browse files Browse the repository at this point in the history
Make flavors behave the same as external networks and images by having
an idiomatic selector.  Separate out the metadata to keep selection and
mutation distinct.  Allow flavors to be mutated to skirt around naughty
operators who lie.
  • Loading branch information
spjmurray committed Jul 26, 2024
1 parent 17d2c2e commit 8efdd18
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 273 deletions.
4 changes: 2 additions & 2 deletions charts/region/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn's Region Controller

type: application

version: v0.1.26
appVersion: v0.1.26
version: v0.1.27
appVersion: v0.1.27

icon: https://raw.githubusercontent.com/unikorn-cloud/assets/main/images/logos/dark-on-light/icon.png

Expand Down
69 changes: 35 additions & 34 deletions charts/region/crds/region.unikorn-cloud.org_regions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,12 @@ spec:
Flavors defines how flavors are filtered and reported to
clients. If not defined, then all flavors are exported.
properties:
exclude:
description: Exclude inhibits the export of flavors from
the region service.
items:
properties:
id:
description: ID flavor ID is the immutable Openstack
identifier for the flavor.
type: string
required:
- id
type: object
type: array
include:
metadata:
description: |-
Include allows or augments flavors that can be exported by the region
service as defined by the "selectionPolicy" property. This explcitly
allows a flavor to be used, and or allows metadata to be mapped to the
flavor e.g. CPU/GPU information that isn't supported by OpenStack.
Metadata allows flavors to be explicitly augmented with additional metadata.
This acknowledges the fact that OpenStack is inadequate acting as a source
of truth for machine topology, and needs external input to describe things
like add on peripherals.
items:
properties:
baremetal:
Expand All @@ -99,6 +86,12 @@ spec:
cpu:
description: CPU defines additional CPU metadata.
properties:
count:
description: |-
Count allows you to override the number of CPUs. Usually this wouldn't
be necessary, but alas some operators may not set this correctly for baremetal
flavors to make horizon display overcommit correctly...
type: integer
family:
description: |-
Family is a free-form string that can communicate the CPU family to clients
Expand Down Expand Up @@ -143,28 +136,36 @@ spec:
- vendor
type: object
id:
description: |-
ID is the immutable Openstack identifier for the flavor.
While most flavor metadata (CPUs/Memory) should be immutable, the name is
not, and may change due to sales and marketing people.
description: ID is the immutable Openstack identifier
for the flavor.
type: string
memory:
anyOf:
- type: integer
- type: string
description: Memory allows the memory amount to
be overridden.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- id
type: object
type: array
selectionPolicy:
selector:
description: |-
SelectionPolicy defines the default set of flavors to export. "All" exports
all flavors, the "include" property defines additional metadata to
merge with matching flavors and the "exclude" inhibits export. "None" is a
more secure policy that only exports those flavors defined in the "include"
property, the "exclude" property is ignored as it's redundant.
enum:
- All
- None
type: string
required:
- selectionPolicy
Selector allows flavors to be manually selected for inclusion. The selected
set is a boolean intersection of all defined filters in the selector.
Note that there are some internal rules that will fiter out flavors such as
if the flavor does not have enough resource to function correctly.
properties:
ids:
description: |-
IDs is an explicit list of allowed flavors IDs. If not specified,
then all flavors are considered.
items:
type: string
type: array
type: object
type: object
serverGroupPolicy:
description: |-
Expand Down
36 changes: 15 additions & 21 deletions charts/region/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,19 @@
"properties": {
"flavors": {
"type": "object",
"required": [
"selectionPolicy"
],
"properties": {
"exclude": {
"type": "array",
"items": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"selector": {
"type": "object",
"properties": {
"ids": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"include": {
"metadata": {
"type": "array",
"items": {
"type": "object",
Expand All @@ -248,12 +242,19 @@
},
"cpu": {
"properties": {
"count": {
"type": "integer"
},
"family": {
"type": "string"
}
},
"type": "object"
},
"memory": {
"type": "string",
"pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"
},
"gpu": {
"type": "object",
"required": [
Expand All @@ -267,14 +268,7 @@
"type": "integer"
},
"memory": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"type": "string",
"pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$"
},
"model": {
Expand Down
26 changes: 8 additions & 18 deletions charts/region/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,22 @@ organization: unikorn-cloud
# serverGroupPolicy: soft-anti-affinity
# # Flavor selection and configuration.
# flavors:
# # The selection policy can be "All" or "None"
# selectionPolicy: All
# # Include specific flavors when the policy is "None". In all cases
# # allows additional metadata to be exposed by the API that Openstack
# # cannot act as a source of truth for.
# include:
# # Include specific flavors.
# selector:
# ids:
# - 60ab8c22-ac61-467d-8680-03d0ecca23c9
# # Mutate flavors or provide extra information.
# metadata:
# - id: 60ab8c22-ac61-467d-8680-03d0ecca23c9
# cpu:
# count: 8
# family: Intel Xeon Platinum 8160T (Skylake)
# memory: 256Gi
# gpu:
# vendor: NVIDIA
# model: H100
# memory: 192Gi
# count: 2
# # Eclude specific flavors when the policy is "All".
# exclude:
# - id: d04d82d9-faa6-4b3b-9247-28b8a158b7ed
# # Flavors containing any of the specified extra specs will be discarded.
# flavorExtraSpecsExclude:
# - resources:CUSTOM_BAREMETAL
# # Define properties on flavors and how to extract the number of GPUs from them.
# gpuDescriptors:
# - property: resources:PGPU
# expression: ^(\d+)$
# - property: resources:VGPU
# expression: ^(\d+)$
# # Image service configuration.
# image:
# # Image selection, the result is a boolean intersection of chosen options.
Expand Down
48 changes: 25 additions & 23 deletions pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,43 +114,45 @@ const (
)

type OpenstackFlavorsSpec struct {
// SelectionPolicy defines the default set of flavors to export. "All" exports
// all flavors, the "include" property defines additional metadata to
// merge with matching flavors and the "exclude" inhibits export. "None" is a
// more secure policy that only exports those flavors defined in the "include"
// property, the "exclude" property is ignored as it's redundant.
SelectionPolicy OpenstackFlavorSelectionPolicy `json:"selectionPolicy"`
// Include allows or augments flavors that can be exported by the region
// service as defined by the "selectionPolicy" property. This explcitly
// allows a flavor to be used, and or allows metadata to be mapped to the
// flavor e.g. CPU/GPU information that isn't supported by OpenStack.
Include []OpenstackFlavorInclude `json:"include,omitempty"`
// Exclude inhibits the export of flavors from the region service.
Exclude []OpenstackFlavorExclude `json:"exclude,omitempty"`
}

type OpenstackFlavorInclude struct {
// Selector allows flavors to be manually selected for inclusion. The selected
// set is a boolean intersection of all defined filters in the selector.
// Note that there are some internal rules that will fiter out flavors such as
// if the flavor does not have enough resource to function correctly.
Selector *FlavorSelector `json:"selector,omitempty"`
// Metadata allows flavors to be explicitly augmented with additional metadata.
// This acknowledges the fact that OpenStack is inadequate acting as a source
// of truth for machine topology, and needs external input to describe things
// like add on peripherals.
Metadata []FlavorMetadata `json:"metadata,omitempty"`
}

type FlavorSelector struct {
// IDs is an explicit list of allowed flavors IDs. If not specified,
// then all flavors are considered.
IDs []string `json:"ids,omitempty"`
}

type FlavorMetadata struct {
// ID is the immutable Openstack identifier for the flavor.
// While most flavor metadata (CPUs/Memory) should be immutable, the name is
// not, and may change due to sales and marketing people.
ID string `json:"id"`
// Baremetal indicates that this is a baremetal flavor, as opposed to a
// virtualized one in case this affects image selection or even how instances
// are provisioned.
Baremetal bool `json:"baremetal,omitempty"`
// CPU defines additional CPU metadata.
CPU *CPUSpec `json:"cpu,omitempty"`
// Memory allows the memory amount to be overridden.
Memory *resource.Quantity `json:"memory,omitempty"`
// GPU defines additional GPU metadata. When provided it will enable selection
// of images based on GPU vendor and model.
GPU *GPUSpec `json:"gpu,omitempty"`
}

type OpenstackFlavorExclude struct {
// ID flavor ID is the immutable Openstack identifier for the flavor.
ID string `json:"id"`
}

type CPUSpec struct {
// Count allows you to override the number of CPUs. Usually this wouldn't
// be necessary, but alas some operators may not set this correctly for baremetal
// flavors to make horizon display overcommit correctly...
Count *int `json:"count,omitempty"`
// Family is a free-form string that can communicate the CPU family to clients
// e.g. "Xeon Platinum 8160T (Skylake)", and allows users to make scheduling
// decisions based on CPU architecture and performance etc.
Expand Down
Loading

0 comments on commit 8efdd18

Please sign in to comment.