Skip to content

Commit dedb9a7

Browse files
committed
Fix node_test
Code refactor for NodeTypeAL2023 enum
1 parent e8aa2cd commit dedb9a7

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

bootstrap/eks/api/v1beta2/eksconfig_types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ import (
2222
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2323
)
2424

25+
// +kubebuilder:validation:Enum=al2023
26+
type NodeType string
27+
28+
const (
29+
// NodeTypeAL2023 represents the AL2023 node type.
30+
NodeTypeAL2023 NodeType = "al2023"
31+
)
32+
2533
// EKSConfigSpec defines the desired state of Amazon EKS Bootstrap Configuration.
2634
type EKSConfigSpec struct {
2735
// NodeType specifies the type of node (e.g., "al2023")
2836
// +optional
29-
NodeType string `json:"nodeType,omitempty"`
37+
NodeType NodeType `json:"nodeType,omitempty"`
3038
// KubeletExtraArgs passes the specified kubelet args into the Amazon EKS machine bootstrap script
3139
// +optional
3240
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ import (
5757
"sigs.k8s.io/cluster-api/util/predicates"
5858
)
5959

60-
const (
61-
// NodeTypeAL2023 represents the AL2023 node type.
62-
NodeTypeAL2023 = "al2023"
63-
)
64-
6560
// EKSConfigReconciler reconciles a EKSConfig object.
6661
type EKSConfigReconciler struct {
6762
client.Client
@@ -233,7 +228,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
233228

234229
// For AL2023, requeue to ensure we retry when control plane is ready
235230
// For AL2, follow upstream behavior and return nil
236-
if config.Spec.NodeType == NodeTypeAL2023 {
231+
if config.Spec.NodeType == eksbootstrapv1.NodeTypeAL2023 {
237232
log.Info("AL2023 detected, returning requeue after 30 seconds")
238233
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
239234
}
@@ -248,7 +243,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
248243
}
249244

250245
// Check if control plane is ready (skip in test environments for AL2023)
251-
if config.Spec.NodeType == NodeTypeAL2023 && !conditions.IsTrue(controlPlane, ekscontrolplanev1.EKSControlPlaneReadyCondition) {
246+
if config.Spec.NodeType == eksbootstrapv1.NodeTypeAL2023 && !conditions.IsTrue(controlPlane, ekscontrolplanev1.EKSControlPlaneReadyCondition) {
252247
// Skip control plane readiness check for AL2023 in test environment
253248
if os.Getenv("TEST_ENV") != "true" {
254249
log.Info("AL2023 detected, waiting for control plane to be ready")
@@ -309,7 +304,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
309304
}
310305

311306
// Set AMI family type and AL2023-specific fields if needed
312-
if config.Spec.NodeType == NodeTypeAL2023 {
307+
if config.Spec.NodeType == eksbootstrapv1.NodeTypeAL2023 {
313308
log.Info("Processing AL2023 node type")
314309
nodeInput.AMIFamilyType = userdata.AMIFamilyAL2023
315310

bootstrap/eks/internal/userdata/node_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ func TestGenerateAL2023UserData(t *testing.T) {
498498
expectErr: false,
499499
verifyOutput: func(output string) bool {
500500
return strings.Contains(output, "name: test-cluster") &&
501-
strings.Contains(output, "maxPods: 110") &&
501+
strings.Contains(output, "maxPods: 58") &&
502502
strings.Contains(output, "nodegroup=test-nodegroup")
503503
},
504504
},

config/crd/bases/bootstrap.cluster.x-k8s.io_eksconfigs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ spec:
382382
type: array
383383
nodeType:
384384
description: NodeType specifies the type of node (e.g., "al2023")
385+
enum:
386+
- al2023
385387
type: string
386388
ntp:
387389
description: NTP specifies NTP configuration

config/crd/bases/bootstrap.cluster.x-k8s.io_eksconfigtemplates.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ spec:
320320
type: array
321321
nodeType:
322322
description: NodeType specifies the type of node (e.g., "al2023")
323+
enum:
324+
- al2023
323325
type: string
324326
ntp:
325327
description: NTP specifies NTP configuration

0 commit comments

Comments
 (0)