Skip to content

Commit 2c8d41b

Browse files
committed
fix lint error
1 parent 8412559 commit 2c8d41b

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ 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+
6065
// EKSConfigReconciler reconciles a EKSConfig object.
6166
type EKSConfigReconciler struct {
6267
client.Client
@@ -229,7 +234,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
229234

230235
// For AL2023, requeue to ensure we retry when control plane is ready
231236
// For AL2, follow upstream behavior and return nil
232-
if config.Spec.NodeType == "al2023" {
237+
if config.Spec.NodeType == NodeTypeAL2023 {
233238
log.Info("AL2023 detected, returning requeue after 30 seconds")
234239
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
235240
}
@@ -244,16 +249,16 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
244249
}
245250

246251
// Check if control plane is ready (skip in test environments for AL2023)
247-
if config.Spec.NodeType == "al2023" && !conditions.IsTrue(controlPlane, ekscontrolplanev1.EKSControlPlaneReadyCondition) {
248-
// In test environments, skip the control plane readiness check for AL2023
249-
if os.Getenv("TEST_ENV") == "true" {
250-
// Skipping control plane readiness check for AL2023 in test environment
251-
} else {
252+
if config.Spec.NodeType == NodeTypeAL2023 && !conditions.IsTrue(controlPlane, ekscontrolplanev1.EKSControlPlaneReadyCondition) {
253+
// Skip control plane readiness check for AL2023 in test environment
254+
if os.Getenv("TEST_ENV") != "true" {
255+
log.Info("AL2023 detected, waiting for control plane to be ready")
252256
conditions.MarkFalse(config, eksbootstrapv1.DataSecretAvailableCondition,
253257
eksbootstrapv1.DataSecretGenerationFailedReason,
254258
clusterv1.ConditionSeverityInfo, "Control plane is not ready yet")
255259
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
256260
}
261+
log.Info("Skipping control plane readiness check for AL2023 in test environment")
257262
}
258263
log.Info("Control plane is ready, proceeding with userdata generation")
259264

@@ -304,7 +309,7 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
304309
}
305310

306311
// Set AMI family type and AL2023-specific fields if needed
307-
if config.Spec.NodeType == "al2023" {
312+
if config.Spec.NodeType == NodeTypeAL2023 {
308313
log.Info("Processing AL2023 node type")
309314
nodeInput.AMIFamilyType = userdata.AMIFamilyAL2023
310315

bootstrap/eks/controllers/eksconfig_controller_reconciler_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -367,32 +367,6 @@ func newCluster(name string) *clusterv1.Cluster {
367367
return cluster
368368
}
369369

370-
// newClusterWithoutControlPlaneInitialized returns a CAPI cluster object without setting ControlPlaneInitializedCondition.
371-
func newClusterWithoutControlPlaneInitialized(name string) *clusterv1.Cluster {
372-
cluster := &clusterv1.Cluster{
373-
TypeMeta: metav1.TypeMeta{
374-
Kind: "Cluster",
375-
APIVersion: clusterv1.GroupVersion.String(),
376-
},
377-
ObjectMeta: metav1.ObjectMeta{
378-
Namespace: "default",
379-
Name: name,
380-
},
381-
Spec: clusterv1.ClusterSpec{
382-
ControlPlaneRef: &corev1.ObjectReference{
383-
Name: name,
384-
Kind: "AWSManagedControlPlane",
385-
Namespace: "default",
386-
},
387-
},
388-
Status: clusterv1.ClusterStatus{
389-
InfrastructureReady: true,
390-
},
391-
}
392-
// Don't set ControlPlaneInitializedCondition
393-
return cluster
394-
}
395-
396370
func dump(desc string, o interface{}) string {
397371
dat, _ := yaml.Marshal(o)
398372
return fmt.Sprintf("%s:\n%s", desc, string(dat))

0 commit comments

Comments
 (0)