@@ -15,10 +15,14 @@ limitations under the License.
15
15
package nodeclass_test
16
16
17
17
import (
18
+ "fmt"
19
+
18
20
"github.com/awslabs/operatorpkg/status"
19
21
"github.com/samber/lo"
20
22
coreoptions "sigs.k8s.io/karpenter/pkg/operator/options"
21
23
24
+ "github.com/aws/aws-sdk-go-v2/service/eks"
25
+ ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
22
26
v1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1"
23
27
"github.com/aws/karpenter-provider-aws/pkg/test"
24
28
@@ -76,4 +80,35 @@ var _ = Describe("NodeClass Status Condition Controller", func() {
76
80
Expect (nodeClass .StatusConditions ().Get (status .ConditionReady ).IsFalse ()).To (BeTrue ())
77
81
Expect (nodeClass .StatusConditions ().Get (status .ConditionReady ).Message ).To (Equal ("ValidationSucceeded=False, SecurityGroupsReady=False" ))
78
82
})
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
+ })
79
114
})
0 commit comments