Skip to content

Commit

Permalink
Merge pull request openshift#28585 from stbenjam/rosa-nodes
Browse files Browse the repository at this point in the history
OCPBUGS-29858: Only extract node role from properly formatted node-role label
  • Loading branch information
openshift-merge-bot[bot] committed Feb 26, 2024
2 parents 96d2578 + 7fd01a1 commit 330feda
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/monitortests/node/watchnodes/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"time"

"github.com/sirupsen/logrus"

"github.com/openshift/origin/pkg/monitor/monitorapi"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -205,11 +207,16 @@ func startNodeMonitoring(ctx context.Context, m monitorapi.RecorderWriter, clien
}

func nodeRoles(node *corev1.Node) string {
const roleLabel = "node-role.kubernetes.io"
const roleLabel = "node-role.kubernetes.io/"
var roles []string
for label := range node.Labels {
if strings.Contains(label, roleLabel) {
roles = append(roles, label[len(roleLabel)+1:])
role := label[len(roleLabel):]
if role == "" {
logrus.Warningf("ignoring blank role label %s", roleLabel)
continue
}
roles = append(roles, role)
}
}

Expand Down

0 comments on commit 330feda

Please sign in to comment.