Skip to content

Commit 2142efc

Browse files
committed
swap condition and cache check
1 parent 2205cf7 commit 2142efc

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pkg/controllers/nodeclass/validation.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,6 @@ func NewValidationReconciler(ec2api sdk.EC2API, amiProvider amifamily.Provider,
6969

7070
// nolint:gocyclo
7171
func (v *Validation) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass) (reconcile.Result, error) {
72-
if val, ok := v.cache.Get(v.cacheKey(nodeClass)); ok {
73-
// We still update the status condition even if it's cached since we may have had a conflict error previously
74-
if val == "" {
75-
nodeClass.StatusConditions().SetTrue(v1.ConditionTypeValidationSucceeded)
76-
} else {
77-
nodeClass.StatusConditions().SetFalse(
78-
v1.ConditionTypeValidationSucceeded,
79-
val.(string),
80-
ValidationConditionMessages[val.(string)],
81-
)
82-
}
83-
return reconcile.Result{}, nil
84-
}
85-
8672
for _, cond := range []string{
8773
v1.ConditionTypeAMIsReady,
8874
v1.ConditionTypeInstanceProfileReady,
@@ -100,6 +86,20 @@ func (v *Validation) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass)
10086
return reconcile.Result{}, nil
10187
}
10288

89+
if val, ok := v.cache.Get(v.cacheKey(nodeClass)); ok {
90+
// We still update the status condition even if it's cached since we may have had a conflict error previously
91+
if val == "" {
92+
nodeClass.StatusConditions().SetTrue(v1.ConditionTypeValidationSucceeded)
93+
} else {
94+
nodeClass.StatusConditions().SetFalse(
95+
v1.ConditionTypeValidationSucceeded,
96+
val.(string),
97+
ValidationConditionMessages[val.(string)],
98+
)
99+
}
100+
return reconcile.Result{}, nil
101+
}
102+
103103
nodeClaim := &karpv1.NodeClaim{
104104
Spec: karpv1.NodeClaimSpec{
105105
NodeClassRef: &karpv1.NodeClassReference{

0 commit comments

Comments
 (0)