Skip to content

Commit ce96cdd

Browse files
committed
Reproduce nodeclass readiness stuck issue in test
1 parent 4bb10c5 commit ce96cdd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pkg/controllers/nodeclass/readiness_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ limitations under the License.
1515
package nodeclass_test
1616

1717
import (
18+
"fmt"
19+
1820
"github.com/awslabs/operatorpkg/status"
1921
"github.com/samber/lo"
2022
coreoptions "sigs.k8s.io/karpenter/pkg/operator/options"
2123

24+
"github.com/aws/aws-sdk-go-v2/service/eks"
25+
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
2226
v1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1"
2327
"github.com/aws/karpenter-provider-aws/pkg/test"
2428

@@ -76,4 +80,35 @@ var _ = Describe("NodeClass Status Condition Controller", func() {
7680
Expect(nodeClass.StatusConditions().Get(status.ConditionReady).IsFalse()).To(BeTrue())
7781
Expect(nodeClass.StatusConditions().Get(status.ConditionReady).Message).To(Equal("ValidationSucceeded=False, SecurityGroupsReady=False"))
7882
})
83+
It("should recover from temporary DescribeCluster failure", func() {
84+
// First reconcile with API error
85+
awsEnv.EKSAPI.DescribeClusterBehavior.Error.Set(fmt.Errorf("temporary AWS API error"))
86+
87+
nodeClass.Spec.AMIFamily = lo.ToPtr(v1.AMIFamilyAL2023)
88+
89+
ExpectApplied(ctx, env.Client, nodeClass)
90+
91+
ExpectObjectReconcileFailed(ctx, env.Client, controller, nodeClass)
92+
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
93+
94+
Expect(nodeClass.StatusConditions().Get(status.ConditionReady).IsFalse()).To(BeTrue())
95+
Expect(nodeClass.StatusConditions().Get(status.ConditionReady).Message).To(ContainSubstring("Failed to detect the cluster CIDR"))
96+
97+
// Clear the error and reconcile again
98+
awsEnv.EKSAPI.DescribeClusterBehavior.Error.Set(nil)
99+
awsEnv.EKSAPI.DescribeClusterBehavior.Output.Set(&eks.DescribeClusterOutput{
100+
Cluster: &ekstypes.Cluster{
101+
Version: lo.ToPtr("1.29"),
102+
KubernetesNetworkConfig: &ekstypes.KubernetesNetworkConfigResponse{
103+
ServiceIpv4Cidr: lo.ToPtr("10.100.0.0/16"),
104+
},
105+
},
106+
})
107+
108+
ExpectObjectReconciled(ctx, env.Client, controller, nodeClass)
109+
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
110+
111+
// Verify conditions are now ready
112+
Expect(nodeClass.StatusConditions().Get(status.ConditionReady).IsTrue()).To(BeTrue())
113+
})
79114
})

0 commit comments

Comments
 (0)