Skip to content

Commit

Permalink
Add register-date and retire-date labels
Browse files Browse the repository at this point in the history
  • Loading branch information
zoetrope committed Sep 8, 2023
1 parent c798e29 commit d121081
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sabakan/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func MachineToNode(m *Machine, tmpl *cke.Node) *cke.Node {
n.Labels["cke.cybozu.com/rack"] = strconv.Itoa(m.Spec.Rack)
n.Labels["cke.cybozu.com/index-in-rack"] = strconv.Itoa(m.Spec.IndexInRack)
n.Labels["cke.cybozu.com/role"] = m.Spec.Role
n.Labels["cke.cybozu.com/retire-date"] = m.Spec.RetireDate.Format("2006-01")
n.Labels["cke.cybozu.com/register-date"] = m.Spec.RegisterDate.Format("2006-01")
n.Labels["node-role.kubernetes.io/"+m.Spec.Role] = "true"
if n.ControlPlane {
n.Labels["node-role.kubernetes.io/master"] = "true"
Expand Down
6 changes: 6 additions & 0 deletions sabakan/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func testMachineToNode(t *testing.T) {
if res1.Labels["node-role.kubernetes.io/control-plane"] != "true" {
t.Error(`res1.Lables["node-role.kubernetes.io/control-plane"] != "true", actual:`, res1.Labels)
}
if res1.Labels[domain+"/register-date"] != testPast250.Format("2006-01") {
t.Error(`res1.Labels["cke.cybozu.com/register-date"] != machine.Spec.RegisterDate.Format("2006-01"), actual:`, res1.Labels)
}
if res1.Labels[domain+"/retire-date"] != testBaseTS.Format("2006-01") {
t.Error(`res1.Labels["cke.cybozu.com/register-date"] != machine.Spec.RetireDate.Format("2006-01"), actual:`, res1.Labels)
}
if !containsTaint(res1.Taints, corev1.Taint{Key: "foo", Effect: corev1.TaintEffectNoSchedule}) {
t.Error(`res1.Taints do not have corev1.Taint{Key"foo", Effect: corev1.TaintEffectNoSchedule}, actual:`, res1.Taints)
}
Expand Down

0 comments on commit d121081

Please sign in to comment.