Skip to content

Commit 93a12a8

Browse files
authored
Merge pull request #631 from eshulman2/cdrive
Add config drive field to server controller
2 parents 04cd561 + 464aaf5 commit 93a12a8

13 files changed

Lines changed: 75 additions & 1 deletion

File tree

api/v1alpha1/server_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ type ServerResourceSpec struct {
187187
// +listType=atomic
188188
// +optional
189189
Metadata []ServerMetadata `json:"metadata,omitempty"`
190+
191+
// configDrive specifies whether to attach a config drive to the server.
192+
// When true, configuration data will be available via a special drive
193+
// instead of the metadata service.
194+
// +optional
195+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="configDrive is immutable"
196+
ConfigDrive *bool `json:"configDrive,omitempty"`
190197
}
191198

192199
// ServerMetadata represents a key-value pair for server metadata.
@@ -288,6 +295,10 @@ type ServerResourceStatus struct {
288295
// +listType=atomic
289296
// +optional
290297
Metadata []ServerMetadataStatus `json:"metadata,omitempty"`
298+
299+
// configDrive indicates whether the server was booted with a config drive.
300+
// +optional
301+
ConfigDrive bool `json:"configDrive,omitempty"`
291302
}
292303

293304
// ServerMetadataStatus represents a key-value pair for server metadata in status.

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/models-schema/zz_generated.openapi.go

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

config/crd/bases/openstack.k-orc.cloud_servers.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ spec:
202202
x-kubernetes-validations:
203203
- message: availabilityZone is immutable
204204
rule: self == oldSelf
205+
configDrive:
206+
description: |-
207+
configDrive specifies whether to attach a config drive to the server.
208+
When true, configuration data will be available via a special drive
209+
instead of the metadata service.
210+
type: boolean
211+
x-kubernetes-validations:
212+
- message: configDrive is immutable
213+
rule: self == oldSelf
205214
flavorRef:
206215
description: flavorRef references the flavor to use for the server
207216
instance.
@@ -455,6 +464,10 @@ spec:
455464
server is located.
456465
maxLength: 1024
457466
type: string
467+
configDrive:
468+
description: configDrive indicates whether the server was booted
469+
with a config drive.
470+
type: boolean
458471
hostID:
459472
description: hostID is the host where the server is located in
460473
the cloud.

config/samples/openstack_v1alpha1_server.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ spec:
2525
value: development
2626
- key: owner
2727
value: sample
28+
configDrive: true

internal/controllers/server/actuator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ func (actuator serverActuator) CreateResource(ctx context.Context, obj *orcv1alp
263263
Tags: tags,
264264
Metadata: metadata,
265265
AvailabilityZone: resource.AvailabilityZone,
266+
ConfigDrive: resource.ConfigDrive,
266267
}
267268

268269
/* keypairs.CreateOptsExt was merged into servers.CreateOpts in gopher cloud V3

internal/controllers/server/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ func (serverStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osRes
7171
WithHostID(osResource.HostID).
7272
WithAvailabilityZone(osResource.AvailabilityZone).
7373
WithServerGroups(ptr.Deref(osResource.ServerGroups, []string{})...).
74-
WithTags(ptr.Deref(osResource.Tags, []string{})...)
74+
WithTags(ptr.Deref(osResource.Tags, []string{})...).
75+
WithConfigDrive(osResource.ConfigDrive)
7576

7677
if imageID, ok := osResource.Image["id"]; ok {
7778
status.WithImageID(fmt.Sprintf("%s", imageID))

internal/controllers/server/tests/server-create-full/00-assert.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ status:
7171
value: test
7272
- key: owner
7373
value: kuttl
74+
configDrive: true

internal/controllers/server/tests/server-create-full/00-create-resource.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ spec:
5353
value: test
5454
- key: owner
5555
value: kuttl
56+
configDrive: true

pkg/clients/applyconfiguration/api/v1alpha1/serverresourcespec.go

Lines changed: 9 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)