Skip to content

Commit

Permalink
fix observed generation diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
rschalo committed Dec 10, 2024
1 parent ecf13a4 commit 58c0771
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion pkg/cloudprovider/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ var _ = Describe("CloudProvider", func() {
ExpectApplied(ctx, env.Client, nodePool, nodeClass, nodeClaim)
nodeClass.Spec.Tags = map[string]string{"kubernetes.io/cluster/thewrongcluster": "owned"}
ExpectApplied(ctx, env.Client, nodeClass)

_, err := cloudProvider.Create(ctx, nodeClaim)
Expect(err).To(HaveOccurred())
Expect(corecloudprovider.IsNodeClassNotReadyError(err)).To(BeTrue())
Expand Down
18 changes: 10 additions & 8 deletions pkg/controllers/nodeclass/status/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ package status
import (
"context"
"fmt"
"strings"
"regexp"

"github.com/awslabs/operatorpkg/status"
"github.com/samber/lo"

"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand All @@ -30,14 +29,17 @@ import (
type Validation struct{}

func (n Validation) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass) (reconcile.Result, error) {
if _, found := lo.FindKeyBy(nodeClass.Spec.Tags, func(key string, _ string) bool {
return strings.HasPrefix(key, "kubernetes.io/cluster/")
if _, found := lo.Find(v1.RestrictedTagPatterns, func(exp *regexp.Regexp) bool {
for key := range nodeClass.Spec.Tags {
if exp.MatchString(key) {
return true
}
}
return false
}); found {
nodeClass.StatusConditions().SetFalse(status.ConditionReady, "NodeClassNotReady", "tag validation bypassed")
nodeClass.StatusConditions().SetFalse(v1.ConditionTypeValidationSucceeded, "NodeClassNotReady", "tag validation bypassed")
return reconcile.Result{}, fmt.Errorf("tag validation bypassed")
}
if ok := nodeClass.StatusConditions().SetTrue(v1.ConditionTypeValidationSucceeded); !ok {
return reconcile.Result{Requeue: true}, nil
}
nodeClass.StatusConditions().SetTrue(v1.ConditionTypeValidationSucceeded)
return reconcile.Result{}, nil
}

0 comments on commit 58c0771

Please sign in to comment.