Skip to content

Commit

Permalink
Merge pull request #2163 from okozachenko1203/feat/support-server-gro…
Browse files Browse the repository at this point in the history
…up-scheduler-hints

✨ support server group and scheduler hint additional properties
  • Loading branch information
k8s-ci-robot authored Sep 23, 2024
2 parents f660352 + bb6cf4d commit 6560f88
Show file tree
Hide file tree
Showing 28 changed files with 1,347 additions and 66 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha1/openstackserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ type OpenStackServerSpec struct {
// be injected into the server instance.
// +optional
UserDataRef *corev1.LocalObjectReference `json:"userDataRef,omitempty"`

// SchedulerHintAdditionalProperties are arbitrary key/value pairs that provide additional hints
// to the OpenStack scheduler. These hints can influence how instances are placed on the infrastructure,
// such as specifying certain host aggregates or availability zones.
// +optional
// +listType=map
// +listMapKey=name
SchedulerHintAdditionalProperties []infrav1.SchedulerHintAdditionalProperty `json:"schedulerHintAdditionalProperties,omitempty"`
}

// OpenStackServerStatus defines the observed state of OpenStackServer.
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1alpha6/openstackmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func restorev1beta1MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infr
dst.ServerGroup = previous.ServerGroup
dst.Image = previous.Image
dst.FloatingIPPoolRef = previous.FloatingIPPoolRef
dst.SchedulerHintAdditionalProperties = previous.SchedulerHintAdditionalProperties

if len(dst.SecurityGroups) == len(previous.SecurityGroups) {
for i := range dst.SecurityGroups {
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha6/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1alpha7/openstackmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func restorev1beta1MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infr
}
}
dst.FloatingIPPoolRef = previous.FloatingIPPoolRef
dst.SchedulerHintAdditionalProperties = previous.SchedulerHintAdditionalProperties

if dst.RootVolume != nil && previous.RootVolume != nil {
restorev1beta1BlockDeviceVolume(
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha7/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions api/v1beta1/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,64 @@ const (
IPClaimMachineFinalizer = "openstackmachine.infrastructure.cluster.x-k8s.io/ip-claim"
)

// SchedulerHintValueType is the type that represents allowed values for the Type field.
// +kubebuilder:validation:Enum=Bool;String;Number
type SchedulerHintValueType string

// Constants representing the allowed types for SchedulerHintAdditionalValue.
const (
SchedulerHintTypeBool SchedulerHintValueType = "Bool"
SchedulerHintTypeString SchedulerHintValueType = "String"
SchedulerHintTypeNumber SchedulerHintValueType = "Number"
)

// SchedulerHintAdditionalValue represents the value of a scheduler hint property.
// The value can be of various types: Bool, String, or Number.
// The Type field indicates the type of the value being used.
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Bool' ? has(self.bool) : !has(self.bool)",message="bool is required when type is Bool, and forbidden otherwise"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Number' ? has(self.number) : !has(self.number)",message="number is required when type is Number, and forbidden otherwise"
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'String' ? has(self.string) : !has(self.string)",message="string is required when type is String, and forbidden otherwise"
// +union.
type SchedulerHintAdditionalValue struct {
// Type represents the type of the value.
// Valid values are Bool, String, and Number.
// +kubebuilder:validation:Required
// +unionDiscriminator
Type SchedulerHintValueType `json:"type"`

// Bool is the boolean value of the scheduler hint, used when Type is "Bool".
// This field is required if type is 'Bool', and must not be set otherwise.
// +unionMember,optional
Bool *bool `json:"bool,omitempty"`

// Number is the integer value of the scheduler hint, used when Type is "Number".
// This field is required if type is 'Number', and must not be set otherwise.
// +unionMember,optional
Number *int `json:"number,omitempty"`

// String is the string value of the scheduler hint, used when Type is "String".
// This field is required if type is 'String', and must not be set otherwise.
// +unionMember,optional
// +kubebuilder:validation:MinLength:=1
// +kubebuilder:validation:MaxLength:=255
String *string `json:"string,omitempty"`
}

// SchedulerHintAdditionalProperty represents a single additional property for a scheduler hint.
// It includes a Name to identify the property and a Value that can be of various types.
type SchedulerHintAdditionalProperty struct {
// Name is the name of the scheduler hint property.
// It is a unique identifier for the property.
// +kubebuilder:validation:MinLength:=1
// +kubebuilder:validation:Required
Name string `json:"name"`

// Value is the value of the scheduler hint property, which can be of various types
// (e.g., bool, string, int). The type is indicated by the Value.Type field.
// +kubebuilder:validation:Required
Value SchedulerHintAdditionalValue `json:"value"`
}

// OpenStackMachineSpec defines the desired state of OpenStackMachine.
type OpenStackMachineSpec struct {
// ProviderID is the unique identifier as specified by the cloud provider.
Expand Down Expand Up @@ -98,6 +156,14 @@ type OpenStackMachineSpec struct {
// will be assigned to the OpenStackMachine.
// +optional
FloatingIPPoolRef *corev1.TypedLocalObjectReference `json:"floatingIPPoolRef,omitempty"`

// SchedulerHintAdditionalProperties are arbitrary key/value pairs that provide additional hints
// to the OpenStack scheduler. These hints can influence how instances are placed on the infrastructure,
// such as specifying certain host aggregates or availability zones.
// +optional
// +listType=map
// +listMapKey=name
SchedulerHintAdditionalProperties []SchedulerHintAdditionalProperty `json:"schedulerHintAdditionalProperties,omitempty"`
}

type ServerMetadata struct {
Expand Down
53 changes: 53 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6560f88

Please sign in to comment.