Ejemplo n.º 1
0
func checkEtcdVersion(cluster platform.Cluster, m platform.Machine, expected string) error {
	const (
		retries   = 5
		retryWait = 3 * time.Second
	)
	var err error
	var b []byte

	for i := 0; i < retries; i++ {
		cmd := cluster.NewCommand("curl", "-L", fmt.Sprintf("http://%v:2379/version", m.IP()))
		b, err = cmd.Output()
		if err != nil {
			plog.Infof("retrying version check, hit failure %v", err)
			time.Sleep(retryWait)
			continue
		}
		break
	}
	if err != nil {
		return fmt.Errorf("curling version: %v", err)
	}

	plog.Infof("got version: %s", b)

	if string(b) != expected {
		return fmt.Errorf("expected %v, got %s", expected, b)
	}
	return nil
}
Ejemplo n.º 2
0
func checkEtcdVersion(cluster platform.Cluster, m platform.Machine, expected string) error {
	var b []byte

	checker := func() error {
		out, err := m.SSH(fmt.Sprintf("curl -s -L http://%s:2379/version", m.IP()))
		if err != nil {
			return fmt.Errorf("curl failed: %v", out)
		}

		b = out

		return nil
	}

	if err := util.Retry(15, 10*time.Second, checker); err != nil {
		return err
	}

	plog.Infof("got version: %s", b)

	if string(b) != expected {
		return fmt.Errorf("expected %v, got %s", expected, b)
	}

	return nil
}
Ejemplo n.º 3
0
func checkEtcdVersion(cluster platform.Cluster, m platform.Machine, expected string) error {
	var b []byte
	var err error

	checker := func() error {
		cmd := cluster.NewCommand("curl", "-L", fmt.Sprintf("http://%v:2379/version", m.IP()))
		b, err = cmd.Output()
		if err != nil {
			return fmt.Errorf("curl failed: %v", err)
		}

		return nil
	}

	if err := util.Retry(15, 10*time.Second, checker); err != nil {
		return err
	}

	plog.Infof("got version: %s", b)

	if string(b) != expected {
		return fmt.Errorf("expected %v, got %s", expected, b)
	}

	return nil
}
Ejemplo n.º 4
0
// run etcd on each cluster machine
func startEtcd2(m platform.Machine) error {
	etcdStart := "sudo systemctl start etcd2.service"
	_, err := m.SSH(etcdStart)
	if err != nil {
		return fmt.Errorf("start etcd2.service on %v failed: %s", m.IP(), err)
	}
	return nil
}
Ejemplo n.º 5
0
func doStart(m platform.Machine, version int, block bool) error {
	// start etcd instance
	var etcdStart string
	if version == 1 {
		etcdStart = "sudo systemctl start etcd.service"
	} else if version == 2 {
		etcdStart = "sudo systemctl start etcd2.service"
	} else {
		return fmt.Errorf("etcd version unspecified")
	}

	if !block {
		etcdStart += " --no-block"
	}

	_, err := m.SSH(etcdStart)
	if err != nil {
		return fmt.Errorf("SSH cmd to %v failed: %s", m.IP(), err)
	}

	return nil
}