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

add ss2 in dctest #2729

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
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
8 changes: 7 additions & 1 deletion dctest/cke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ func testCKE() {
err = json.Unmarshal(stdout, &ssMachines)
Expect(err).ShouldNot(HaveOccurred(), "data=%s", stdout)

availableNodes := len(csMachines) + len(ssMachines)
stdout, stderr, err = execAt(bootServers[0], "sabactl", "machines", "get", "--role=ss2")
Expect(err).ShouldNot(HaveOccurred(), "stdout=%s, stderr=%s", stdout, stderr)
var ss2Machines []sabakan.Machine
err = json.Unmarshal(stdout, &ss2Machines)
Expect(err).ShouldNot(HaveOccurred(), "data=%s", stdout)

availableNodes := len(csMachines) + len(ssMachines) + len(ss2Machines)
Expect(availableNodes).NotTo(Equal(0))

By("getting systemd unit statuses by serf members")
Expand Down
9 changes: 9 additions & 0 deletions dctest/menu-ss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
rack:
- cs: 2
ss: 1
ss2: 1
- cs: 2
ss: 1
- cs: 2
Expand Down Expand Up @@ -60,3 +61,11 @@ spec:
memory: 10G
disk-count: 10
tpm: true
---
kind: Node
type: ss2
spec:
cpu: 4
memory: 10G
disk-count: 10
tpm: true
9 changes: 9 additions & 0 deletions dctest/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
rack:
- cs: 2
ss: 1
ss2: 1
- cs: 2
- cs: 1
- cs: 1
Expand Down Expand Up @@ -58,3 +59,11 @@ spec:
memory: 10G
disk-count: 4
tpm: true
---
kind: Node
type: ss2
spec:
cpu: 2
memory: 10G
disk-count: 4
tpm: true
8 changes: 7 additions & 1 deletion dctest/sabakan_state_setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ func testSabakanStateSetter() {
err = json.Unmarshal(stdout, &ssMachines)
Expect(err).ShouldNot(HaveOccurred(), "data=%s", stdout)

availableNodes := len(csMachines) + len(ssMachines)
stdout, stderr, err = execAt(bootServers[0], "sabactl", "machines", "get", "--role=ss2")
Expect(err).ShouldNot(HaveOccurred(), "stdout=%s, stderr=%s", stdout, stderr)
var ss2Machines []sabakan.Machine
err = json.Unmarshal(stdout, &ss2Machines)
Expect(err).ShouldNot(HaveOccurred(), "data=%s", stdout)

availableNodes := len(csMachines) + len(ssMachines) + len(ss2Machines)
Expect(availableNodes).NotTo(Equal(0))

By("checking all serf members are active")
Expand Down
2 changes: 1 addition & 1 deletion ignitions/common/files/etc/hostname
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rack{{ .Spec.Rack }}-{{ .Spec.Role }}{{ .Spec.IndexInRack }}
rack{{ .Spec.Rack }}-{{ .Spec.Role }}-{{ .Spec.IndexInRack }}
5 changes: 5 additions & 0 deletions menu/assets/bird_rack-tor1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ protocol bgp '{{$rackName}}-{{$ss.Name}}' from bgpnode {
neighbor {{$ss.Node1Address}} as {{$asnRack}};
}
{{end -}}
{{range $ss2 := .Rack.SS2List -}}
protocol bgp '{{$rackName}}-{{$ss2.Name}}' from bgpnode {
neighbor {{$ss2.Node2Address}} as {{$asnRack}};
}
{{end -}}
5 changes: 5 additions & 0 deletions menu/assets/bird_rack-tor2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ protocol bgp '{{$rackName}}-{{$ss.Name}}' from bgpnode {
neighbor {{$ss.Node2Address}} as {{$asnRack}};
}
{{end -}}
{{range $ss2 := .Rack.SS2List -}}
protocol bgp '{{$rackName}}-{{$ss2.Name}}' from bgpnode {
neighbor {{$ss2.Node2Address}} as {{$asnRack}};
}
{{end -}}
1 change: 1 addition & 0 deletions menu/assets/machines.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ racks:
workers:
cs: {{len $rack.CSList }}
ss: {{len $rack.SSList }}
ss2: {{len $rack.SS2List }}
boot:
bastion: {{$rack.BootNode.BastionAddress}}
{{end -}}
22 changes: 20 additions & 2 deletions menu/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type rack struct {
bootNode *bootNode
csList []*node
ssList []*node
ss2List []*node
node0Network *net.IPNet
node1Network *net.IPNet
node2Network *net.IPNet
Expand Down Expand Up @@ -274,7 +275,7 @@ func NewCluster(menu *menu) (*Cluster, error) {
}

for csIdx := 0; csIdx < rackMenu.Cs; csIdx++ {
name := fmt.Sprintf("cs%d", csIdx+1)
name := fmt.Sprintf("cs-%d", csIdx+1)
fullName := fmt.Sprintf("%s-%s", rack.name, name)
node := &node{
name: name,
Expand All @@ -291,7 +292,7 @@ func NewCluster(menu *menu) (*Cluster, error) {
}

for ssIdx := 0; ssIdx < rackMenu.Ss; ssIdx++ {
name := fmt.Sprintf("ss%d", ssIdx+1)
name := fmt.Sprintf("ss-%d", ssIdx+1)
fullName := fmt.Sprintf("%s-%s", rack.name, name)
node := &node{
name: name,
Expand All @@ -307,6 +308,23 @@ func NewCluster(menu *menu) (*Cluster, error) {
rack.ssList = append(rack.ssList, node)
}

for ss2Idx := 0; ss2Idx < rackMenu.Ss2; ss2Idx++ {
name := fmt.Sprintf("ss2-%d", ss2Idx+1)
fullName := fmt.Sprintf("%s-%s", rack.name, name)
node := &node{
name: name,
fullName: fullName,
spec: nodeSpecs[nodeTypeSS2],
serial: fmt.Sprintf("%x", sha1.Sum([]byte(fullName))),
node0Address: addToIP(node0Network.IP, offsetNodenetServers+ss2Idx+rackMenu.Cs+rackMenu.Ss, 32),
node1Address: addToIPNet(node1Network, offsetNodenetServers+ss2Idx+rackMenu.Cs+rackMenu.Ss),
node2Address: addToIPNet(node2Network, offsetNodenetServers+ss2Idx+rackMenu.Cs+rackMenu.Ss),
tor1Address: rack.bootNode.tor1Address,
tor2Address: rack.bootNode.tor2Address,
}
rack.ss2List = append(rack.ss2List, node)
}

rack.tor1 = &tor{
name: fmt.Sprintf("rack%d-tor%d", rackIdx, 1),
nodeAddress: addToIPNet(rack.node1Network, offsetNodenetToR),
Expand Down
24 changes: 24 additions & 0 deletions menu/cluster_conf_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type RackArgs struct {
BootNode NodeArgs
CSList []*NodeArgs
SSList []*NodeArgs
SS2List []*NodeArgs
}

type NodeArgs struct {
Expand Down Expand Up @@ -244,6 +245,19 @@ func (c *Cluster) generateSeedYaml(inputDir, outputDir string) error {
}
}
}
for _, ss2 := range rack.ss2List {
if ss2.spec.CloudInitTemplate != "" {
args := &SeedYamlArgs{
Name: fmt.Sprintf("%s-%s", rack.name, ss2.name),
Rack: rackArgs,
}
err := exportFile(filepath.Join(inputDir, ss2.spec.CloudInitTemplate),
filepath.Join(outputDir, fmt.Sprintf("seed_%s-%s.yml", rack.name, ss2.name)), args)
if err != nil {
return err
}
}
}
}

return nil
Expand Down Expand Up @@ -332,6 +346,9 @@ func (c *Cluster) generateSabakanData(outputDir string) error {
for _, ss := range rack.ssList {
ms = append(ms, sabakanMachine(ss.serial, rack.index, "ss"))
}
for _, ss2 := range rack.ss2List {
ms = append(ms, sabakanMachine(ss2.serial, rack.index, "ss2"))
}
}

sabakanDir := filepath.Join(outputDir, sabakanDir)
Expand Down Expand Up @@ -413,6 +430,13 @@ func newRackArgs(rack *rack) *RackArgs {
Node2Address: ss.node2Address.IP.String(),
})
}
for _, ss2 := range rack.ss2List {
args.SS2List = append(args.SS2List, &NodeArgs{
Name: ss2.name,
Node1Address: ss2.node1Address.IP.String(),
Node2Address: ss2.node2Address.IP.String(),
})
}

return args
}
Expand Down
3 changes: 3 additions & 0 deletions menu/cluster_yaml_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ func (c *Cluster) appendNodes(spec *types.ClusterSpec, sabakanDir string) {
for _, ss := range rack.ssList {
spec.Nodes = append(spec.Nodes, createWorkerNode(rack, ss, ss.spec))
}
for _, ss2 := range rack.ss2List {
spec.Nodes = append(spec.Nodes, createWorkerNode(rack, ss2, ss2.spec))
}
}

spec.Nodes = append(spec.Nodes, createChronyNode())
Expand Down
14 changes: 14 additions & 0 deletions menu/example/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
ss: 0
- cs: 2
ss: 2
ss2: 1
---
kind: Image
name: ubuntu-cloud-image
Expand Down Expand Up @@ -86,3 +87,16 @@ spec:
- device-class: hdd
count: 3
size: 100G
---
kind: Node
type: ss2
spec:
cpu: 1
memory: 1G
data:
- docker-image
tpm: true
disks:
- device-class: ssd
count: 4
size: 50G
6 changes: 4 additions & 2 deletions menu/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ type inventorySpec struct {
}

type rackMenu struct {
Cs int `json:"cs"`
Ss int `json:"ss"`
Cs int `json:"cs"`
Ss int `json:"ss"`
Ss2 int `json:"ss2"`
}

type nodeMenu struct {
Expand Down Expand Up @@ -247,6 +248,7 @@ const (
nodeTypeBoot = nodeType("boot")
nodeTypeCS = nodeType("cs")
nodeTypeSS = nodeType("ss")
nodeTypeSS2 = nodeType("ss2")
)

type menu struct {
Expand Down
4 changes: 2 additions & 2 deletions menu/testdata/bird_rack0-tor1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ template bgp bgpnode {
protocol bgp 'boot-0' from bgpnode {
neighbor 10.69.0.67 as 64600;
}
protocol bgp 'rack0-cs1' from bgpnode {
protocol bgp 'rack0-cs-1' from bgpnode {
neighbor 10.69.0.68 as 64600;
}
protocol bgp 'rack0-cs2' from bgpnode {
protocol bgp 'rack0-cs-2' from bgpnode {
neighbor 10.69.0.69 as 64600;
}
4 changes: 2 additions & 2 deletions menu/testdata/bird_rack0-tor2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ template bgp bgpnode {
protocol bgp 'boot-0' from bgpnode {
neighbor 10.69.0.131 as 64600;
}
protocol bgp 'rack0-cs1' from bgpnode {
protocol bgp 'rack0-cs-1' from bgpnode {
neighbor 10.69.0.132 as 64600;
}
protocol bgp 'rack0-cs2' from bgpnode {
protocol bgp 'rack0-cs-2' from bgpnode {
neighbor 10.69.0.133 as 64600;
}
11 changes: 7 additions & 4 deletions menu/testdata/bird_rack1-tor1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ template bgp bgpnode {
protocol bgp 'boot-1' from bgpnode {
neighbor 10.69.1.3 as 64601;
}
protocol bgp 'rack1-cs1' from bgpnode {
protocol bgp 'rack1-cs-1' from bgpnode {
neighbor 10.69.1.4 as 64601;
}
protocol bgp 'rack1-cs2' from bgpnode {
protocol bgp 'rack1-cs-2' from bgpnode {
neighbor 10.69.1.5 as 64601;
}
protocol bgp 'rack1-ss1' from bgpnode {
protocol bgp 'rack1-ss-1' from bgpnode {
neighbor 10.69.1.6 as 64601;
}
protocol bgp 'rack1-ss2' from bgpnode {
protocol bgp 'rack1-ss-2' from bgpnode {
neighbor 10.69.1.7 as 64601;
}
protocol bgp 'rack1-ss2-1' from bgpnode {
neighbor 10.69.1.72 as 64601;
}
11 changes: 7 additions & 4 deletions menu/testdata/bird_rack1-tor2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ template bgp bgpnode {
protocol bgp 'boot-1' from bgpnode {
neighbor 10.69.1.67 as 64601;
}
protocol bgp 'rack1-cs1' from bgpnode {
protocol bgp 'rack1-cs-1' from bgpnode {
neighbor 10.69.1.68 as 64601;
}
protocol bgp 'rack1-cs2' from bgpnode {
protocol bgp 'rack1-cs-2' from bgpnode {
neighbor 10.69.1.69 as 64601;
}
protocol bgp 'rack1-ss1' from bgpnode {
protocol bgp 'rack1-ss-1' from bgpnode {
neighbor 10.69.1.70 as 64601;
}
protocol bgp 'rack1-ss2' from bgpnode {
protocol bgp 'rack1-ss-2' from bgpnode {
neighbor 10.69.1.71 as 64601;
}
protocol bgp 'rack1-ss2-1' from bgpnode {
neighbor 10.69.1.72 as 64601;
}
Loading