Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/verify-longhorn-migration-headroom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func qualify(servers []server, nodes []node, requireV2 bool) error {
}
role, isStatic := static[name]
if controlPlaneName.MatchString(name) {
role, isStatic = "control-plane", true
role, isStatic = "controlplane", true
}
if isStatic {
if s.Labels["ksail.owned"] != "true" || s.Labels["ksail.cluster.name"] != "prod" || s.Labels["ksail.node.type"] != role || s.Labels["ksail.node.index"] != name[strings.LastIndex(name, "-")+1:] || s.Labels["hcloud/node-group"] != "" || n.Metadata.Labels["storage.platform.devantler.tech/migration-pool"] != "" {
Expand All @@ -155,7 +155,7 @@ func qualify(servers []server, nodes []node, requireV2 bool) error {
}
counts[match[1]]++
}
if counts["static"] != 6 || counts["control-plane"] != 3 || counts["worker"] != 3 || counts["v1"] != 2 || counts["v2"] > 1 || (requireV2 && counts["v2"] != 1) {
if counts["static"] != 6 || counts["controlplane"] != 3 || counts["worker"] != 3 || counts["v1"] != 2 || counts["v2"] > 1 || (requireV2 && counts["v2"] != 1) {
return errors.New("the required migration roster is incomplete")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-longhorn-migration-headroom/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func roster(t *testing.T, v2 bool) ([]server, []node) {
id := int64(100 + i)
labels := map[string]string{"ksail.owned": "true", "ksail.cluster.name": "prod", "ksail.node.type": "worker"}
if i < 3 {
labels["ksail.node.type"] = "control-plane"
labels["ksail.node.type"] = "controlplane"
}
if i < 6 {
labels["ksail.node.index"] = name[strings.LastIndex(name, "-")+1:]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import "testing"

// KSail v7.210.0 NodeLabels and the Talos server-creation path use the
// provider role "controlplane", independently of Kubernetes' role-label spelling.
func TestPublishedProviderControlPlaneOwnership(t *testing.T) {
servers, nodes := roster(t, true)
if err := qualify(servers, nodes, true); err != nil {
t.Fatalf("the published provider ownership contract was refused: %v", err)
}
}

func TestProviderRoleAliasesDoNotEstablishOwnership(t *testing.T) {
for _, tc := range []struct{ name, role string }{
{"Kubernetes role spelling", "control-plane"},
{"different case", "controlPlane"},
{"worker role", "worker"},
{"missing role", ""},
} {
t.Run(tc.name, func(t *testing.T) {
servers, nodes := roster(t, true)
servers[0].Labels["ksail.node.type"] = tc.role
if err := qualify(servers, nodes, true); err == nil {
t.Fatal("a role outside the published ownership contract qualified")
}
})
}
}
Loading