Skip to content

Commit 6b94143

Browse files
committed
Fix(ignition): Default version only if not storageType UnencryptedUserData
1 parent cfdcb14 commit 6b94143

7 files changed

+25
-14
lines changed

api/v1beta2/awsmachine_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,10 @@ type CloudInit struct {
286286
// For more information on Ignition configuration, see https://coreos.github.io/butane/specs/
287287
type Ignition struct {
288288
// Version defines which version of Ignition will be used to generate bootstrap data.
289+
// Defaults to `2.3` if storageType is set to `ClusterObjectStore`.
290+
// It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version.
289291
//
290292
// +optional
291-
// +kubebuilder:default="2.3"
292293
// +kubebuilder:validation:Enum="2.3";"3.0";"3.1";"3.2";"3.3";"3.4"
293294
Version string `json:"version,omitempty"`
294295

api/v1beta2/awsmachine_webhook.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ func (*awsMachineWebhook) Default(_ context.Context, obj runtime.Object) error {
451451
r.Spec.CloudInit.SecureSecretsBackend = SecretBackendSecretsManager
452452
}
453453

454-
if r.ignitionEnabled() && r.Spec.Ignition.Version == "" {
454+
// Defaults the version field if StorageType is not set to `UnencryptedUserData`.
455+
// When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself.
456+
if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != IgnitionStorageTypeOptionUnencryptedUserData {
455457
r.Spec.Ignition.Version = DefaultIgnitionVersion
456458
}
457459
if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,10 @@ spec:
10011001
type: array
10021002
type: object
10031003
version:
1004-
default: "2.3"
1005-
description: Version defines which version of Ignition will be
1006-
used to generate bootstrap data.
1004+
description: |-
1005+
Version defines which version of Ignition will be used to generate bootstrap data.
1006+
Defaults to `2.3` if storageType is set to `ClusterObjectStore`.
1007+
It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version.
10071008
enum:
10081009
- "2.3"
10091010
- "3.0"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,10 @@ spec:
822822
type: array
823823
type: object
824824
version:
825-
default: "2.3"
826-
description: Version defines which version of Ignition will be
827-
used to generate bootstrap data.
825+
description: |-
826+
Version defines which version of Ignition will be used to generate bootstrap data.
827+
Defaults to `2.3` if storageType is set to `ClusterObjectStore`.
828+
It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version.
828829
enum:
829830
- "2.3"
830831
- "3.0"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,10 @@ spec:
741741
type: array
742742
type: object
743743
version:
744-
default: "2.3"
745-
description: Version defines which version of Ignition
746-
will be used to generate bootstrap data.
744+
description: |-
745+
Version defines which version of Ignition will be used to generate bootstrap data.
746+
Defaults to `2.3` if storageType is set to `ClusterObjectStore`.
747+
It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version.
747748
enum:
748749
- "2.3"
749750
- "3.0"

exp/api/v1beta2/awsmachinepool_webhook.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ func (*AWSMachinePoolWebhook) Default(ctx context.Context, obj runtime.Object) e
314314
r.Spec.DefaultInstanceWarmup.Duration = 300 * time.Second
315315
}
316316

317-
if r.ignitionEnabled() && r.Spec.Ignition.Version == "" {
317+
// Defaults the version field if StorageType is not set to `UnencryptedUserData`.
318+
// When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself.
319+
if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != infrav1.IgnitionStorageTypeOptionUnencryptedUserData {
318320
r.Spec.Ignition.Version = infrav1.DefaultIgnitionVersion
319321
}
320322
if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" {

pkg/cloud/services/ec2/launchtemplate.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ func (s *Service) ReconcileLaunchTemplate(
9292
}
9393

9494
var ignitionStorageType = infrav1.DefaultMachinePoolIgnitionStorageType
95-
var ignitionVersion = infrav1.DefaultIgnitionVersion
9695
if ignition := ignitionScope.Ignition(); ignition != nil {
9796
ignitionStorageType = ignition.StorageType
98-
ignitionVersion = ignition.Version
9997
}
10098

10199
var userDataForLaunchTemplate []byte
102100
if bootstrapDataFormat == "ignition" && ignitionStorageType == infrav1.IgnitionStorageTypeOptionClusterObjectStore {
101+
var ignitionVersion = infrav1.DefaultIgnitionVersion
102+
if ignition := ignitionScope.Ignition(); ignition != nil {
103+
ignitionVersion = ignition.Version
104+
}
105+
103106
if s3Scope.Bucket() == nil {
104107
return errors.New("using Ignition with `AWSMachinePool.spec.ignition.storageType=ClusterObjectStore` " +
105108
"requires a cluster wide object storage configured at `AWSCluster.spec.s3Bucket`")

0 commit comments

Comments
 (0)