Skip to content

Commit

Permalink
Merge pull request #138 from digitalocean/awg/fix-node-name-issue
Browse files Browse the repository at this point in the history
Return the correct node names in the node labels and taints check
  • Loading branch information
adamwg authored Mar 16, 2022
2 parents 7769a03 + 91df975 commit efcb2aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions checks/doks/node_labels_taints.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (*nodeLabelsTaintsCheck) Description() string {
func (c *nodeLabelsTaintsCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error) {
var diagnostics []checks.Diagnostic
for _, node := range objects.Nodes.Items {
node := node
var customLabels, customTaints []string
for labelKey := range node.Labels {
if !isKubernetesLabel(labelKey) && !isDOKSLabel(labelKey) {
Expand Down
22 changes: 18 additions & 4 deletions checks/doks/node_labels_taints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestNodeLabels(t *testing.T) {
Kind: checks.Node,
Details: "Custom node labels: [example.com/another-label example.com/custom-label]",
Object: &metav1.ObjectMeta{
Name: "bad-node",
Labels: map[string]string{
"doks.digitalocean.com/foo": "bar",
"doks.digitalocean.com/baz": "xyzzy",
Expand All @@ -98,11 +99,24 @@ func TestNodeLabels(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
objects := &kube.Objects{
Nodes: &corev1.NodeList{
Items: []corev1.Node{{
ObjectMeta: metav1.ObjectMeta{
Labels: test.nodeLabels,
Items: []corev1.Node{
{
ObjectMeta: metav1.ObjectMeta{
Name: "good-node",
},
},
}},
{
ObjectMeta: metav1.ObjectMeta{
Name: "bad-node",
Labels: test.nodeLabels,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "another-good-node",
},
},
},
},
}

Expand Down

0 comments on commit efcb2aa

Please sign in to comment.