Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

using a proper machine index to avoid port collision #233

Merged
merged 1 commit into from
Jan 25, 2020
Merged
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
6 changes: 5 additions & 1 deletion pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ func (c *Cluster) machine(spec *config.Machine, i int) *Machine {
}

func (c *Cluster) forEachMachine(do func(*Machine, int) error) error {
machineIndex := 0
for _, template := range c.spec.Machines {
for i := 0; i < template.Count; i++ {
// machine name indexed with i
machine := c.machine(&template.Spec, i)
if err := do(machine, i); err != nil {
// but to prevent port collision, we use machineIndex for the real machine creation
if err := do(machine, machineIndex); err != nil {
return err
}
machineIndex++
}
}
return nil
Expand Down