Skip to content

Commit 6560f88

Browse files
authored
Merge pull request #2163 from okozachenko1203/feat/support-server-group-scheduler-hints
✨ support server group and scheduler hint additional properties
2 parents f660352 + bb6cf4d commit 6560f88

28 files changed

+1347
-66
lines changed

api/v1alpha1/openstackserver_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ type OpenStackServerSpec struct {
104104
// be injected into the server instance.
105105
// +optional
106106
UserDataRef *corev1.LocalObjectReference `json:"userDataRef,omitempty"`
107+
108+
// SchedulerHintAdditionalProperties are arbitrary key/value pairs that provide additional hints
109+
// to the OpenStack scheduler. These hints can influence how instances are placed on the infrastructure,
110+
// such as specifying certain host aggregates or availability zones.
111+
// +optional
112+
// +listType=map
113+
// +listMapKey=name
114+
SchedulerHintAdditionalProperties []infrav1.SchedulerHintAdditionalProperty `json:"schedulerHintAdditionalProperties,omitempty"`
107115
}
108116

109117
// OpenStackServerStatus defines the observed state of OpenStackServer.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/openstackmachine_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func restorev1beta1MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infr
190190
dst.ServerGroup = previous.ServerGroup
191191
dst.Image = previous.Image
192192
dst.FloatingIPPoolRef = previous.FloatingIPPoolRef
193+
dst.SchedulerHintAdditionalProperties = previous.SchedulerHintAdditionalProperties
193194

194195
if len(dst.SecurityGroups) == len(previous.SecurityGroups) {
195196
for i := range dst.SecurityGroups {

api/v1alpha6/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/openstackmachine_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func restorev1beta1MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *infr
191191
}
192192
}
193193
dst.FloatingIPPoolRef = previous.FloatingIPPoolRef
194+
dst.SchedulerHintAdditionalProperties = previous.SchedulerHintAdditionalProperties
194195

195196
if dst.RootVolume != nil && previous.RootVolume != nil {
196197
restorev1beta1BlockDeviceVolume(

api/v1alpha7/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/openstackmachine_types.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,64 @@ const (
3333
IPClaimMachineFinalizer = "openstackmachine.infrastructure.cluster.x-k8s.io/ip-claim"
3434
)
3535

36+
// SchedulerHintValueType is the type that represents allowed values for the Type field.
37+
// +kubebuilder:validation:Enum=Bool;String;Number
38+
type SchedulerHintValueType string
39+
40+
// Constants representing the allowed types for SchedulerHintAdditionalValue.
41+
const (
42+
SchedulerHintTypeBool SchedulerHintValueType = "Bool"
43+
SchedulerHintTypeString SchedulerHintValueType = "String"
44+
SchedulerHintTypeNumber SchedulerHintValueType = "Number"
45+
)
46+
47+
// SchedulerHintAdditionalValue represents the value of a scheduler hint property.
48+
// The value can be of various types: Bool, String, or Number.
49+
// The Type field indicates the type of the value being used.
50+
// +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"
51+
// +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"
52+
// +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"
53+
// +union.
54+
type SchedulerHintAdditionalValue struct {
55+
// Type represents the type of the value.
56+
// Valid values are Bool, String, and Number.
57+
// +kubebuilder:validation:Required
58+
// +unionDiscriminator
59+
Type SchedulerHintValueType `json:"type"`
60+
61+
// Bool is the boolean value of the scheduler hint, used when Type is "Bool".
62+
// This field is required if type is 'Bool', and must not be set otherwise.
63+
// +unionMember,optional
64+
Bool *bool `json:"bool,omitempty"`
65+
66+
// Number is the integer value of the scheduler hint, used when Type is "Number".
67+
// This field is required if type is 'Number', and must not be set otherwise.
68+
// +unionMember,optional
69+
Number *int `json:"number,omitempty"`
70+
71+
// String is the string value of the scheduler hint, used when Type is "String".
72+
// This field is required if type is 'String', and must not be set otherwise.
73+
// +unionMember,optional
74+
// +kubebuilder:validation:MinLength:=1
75+
// +kubebuilder:validation:MaxLength:=255
76+
String *string `json:"string,omitempty"`
77+
}
78+
79+
// SchedulerHintAdditionalProperty represents a single additional property for a scheduler hint.
80+
// It includes a Name to identify the property and a Value that can be of various types.
81+
type SchedulerHintAdditionalProperty struct {
82+
// Name is the name of the scheduler hint property.
83+
// It is a unique identifier for the property.
84+
// +kubebuilder:validation:MinLength:=1
85+
// +kubebuilder:validation:Required
86+
Name string `json:"name"`
87+
88+
// Value is the value of the scheduler hint property, which can be of various types
89+
// (e.g., bool, string, int). The type is indicated by the Value.Type field.
90+
// +kubebuilder:validation:Required
91+
Value SchedulerHintAdditionalValue `json:"value"`
92+
}
93+
3694
// OpenStackMachineSpec defines the desired state of OpenStackMachine.
3795
type OpenStackMachineSpec struct {
3896
// ProviderID is the unique identifier as specified by the cloud provider.
@@ -98,6 +156,14 @@ type OpenStackMachineSpec struct {
98156
// will be assigned to the OpenStackMachine.
99157
// +optional
100158
FloatingIPPoolRef *corev1.TypedLocalObjectReference `json:"floatingIPPoolRef,omitempty"`
159+
160+
// SchedulerHintAdditionalProperties are arbitrary key/value pairs that provide additional hints
161+
// to the OpenStack scheduler. These hints can influence how instances are placed on the infrastructure,
162+
// such as specifying certain host aggregates or availability zones.
163+
// +optional
164+
// +listType=map
165+
// +listMapKey=name
166+
SchedulerHintAdditionalProperties []SchedulerHintAdditionalProperty `json:"schedulerHintAdditionalProperties,omitempty"`
101167
}
102168

103169
type ServerMetadata struct {

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)