etcd clusters must negotiate to reach v3 mode, wait
Otherwise we can start making calls to the cluster while it is still in
v2 mode.
@@ -8,6 +8,7 @@ import (
"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/pkg/osutil"
"github.com/coreos/etcd/pkg/types"
+ "github.com/coreos/go-semver/semver"
"github.com/golang/glog"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
@@ -74,6 +75,11 @@ func RunEtcd(etcdServerConfig *configapi.EtcdConfig) {
select {
case <-e.Server.ReadyNotify():
+ // embedded servers must negotiate to reach v3 mode, this ensures we loop until that happens
+ glog.V(4).Infof("Waiting for etcd to reach cluster version 3.0.0")
+ for min := semver.Must(semver.NewVersion("3.0.0")); e.Server.ClusterVersion() == nil || e.Server.ClusterVersion().LessThan(*min); {
+ time.Sleep(25 * time.Millisecond)
+ }
glog.Infof("Started etcd at %s", etcdServerConfig.Address)
case <-time.After(60 * time.Second):
glog.Warning("etcd took too long to start, stopped")
