From f2c69a342185f71e6be36cd93dfbe6910b7a4ffc Mon Sep 17 00:00:00 2001 From: Hongchao Deng Date: Thu, 25 Aug 2016 15:12:17 -0700 Subject: [PATCH] implement cluster creation --- cluster.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/cluster.go b/cluster.go index c83de47..dad6f83 100644 --- a/cluster.go +++ b/cluster.go @@ -113,20 +113,12 @@ func (c *Cluster) create(spec *Spec) { members := MemberSet{} c.spec = spec // we want to make use of member's utility methods. - for i := 0; i < c.spec.Size; i++ { - etcdName := fmt.Sprintf("%s-%04d", c.name, i) - members.Add(&Member{Name: etcdName}) + etcdName := fmt.Sprintf("%s-%04d", c.name, 0) + members.Add(&Member{Name: etcdName}) + if err := c.createPodAndService(members, members[etcdName], "new"); err != nil { + panic(fmt.Sprintf("(TODO: we need to clean up already created ones.)\nError: %v", err)) } - - // TODO: parallelize it - for i := 0; i < c.spec.Size; i++ { - etcdName := fmt.Sprintf("%s-%04d", c.name, i) - if err := c.createPodAndService(members, members[etcdName], "new"); err != nil { - panic(fmt.Sprintf("(TODO: we need to clean up already created ones.)\nError: %v", err)) - } - c.idCounter++ - } - + c.idCounter++ fmt.Println("created cluster:", members) }