Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-29858: Only extract node role from properly formatted node-role label #28585

Merged
merged 1 commit into from Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/monitortests/node/watchnodes/node.go
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