Skip to content

Commit 471a9cd

Browse files
committed
Refactor node matching logic in nodegroup_controller.go
1 parent aeb8e3e commit 471a9cd

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

controllers/nodegroup_controller.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"strings"
2122

2223
corev1 "k8s.io/api/core/v1"
2324
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -181,8 +182,19 @@ func (r *NodeGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
181182
}
182183

183184
for _, node := range nodes.Items {
184-
if stringIn(node.Name, nodeGroup.Spec.NodeGroupNames) {
185-
matchingStrings = append(matchingStrings, node.Name)
185+
nodeNameParts := strings.Split(node.Name, "-")
186+
{
187+
found := false
188+
for _, part := range nodeNameParts {
189+
if stringIn(part, nodeGroup.Spec.NodeGroupNames) {
190+
matchingStrings = append(matchingStrings, node.Name)
191+
found = true
192+
break
193+
}
194+
}
195+
if found {
196+
break
197+
}
186198
}
187199
}
188200

0 commit comments

Comments
 (0)