Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Restart the server using the recommended etcd version
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman authored and justinsb committed Feb 4, 2023
1 parent d3c7c31 commit a8dc65c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 13 additions & 2 deletions etcd-manager/pkg/etcd/etcdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"sigs.k8s.io/etcdadm/etcd-manager/pkg/backup"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/contextutil"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/dns"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/etcdversions"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/legacy"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/pki"
"sigs.k8s.io/etcdadm/etcd-manager/pkg/privateapi"
Expand Down Expand Up @@ -604,12 +605,22 @@ func (s *EtcdServer) startEtcdProcess(state *protoetcd.EtcdState) error {
return err
}

binDir, err := BindirForEtcdVersion(state.EtcdVersion, "etcd")
etcdVersion := state.EtcdVersion
// Use the recommended etcd version
{
startWith := etcdversions.EtcdVersionForAdoption(etcdVersion)
if startWith != "" && startWith != etcdVersion {
klog.Warningf("starting server from etcd %q, will start with %q", etcdVersion, startWith)
etcdVersion = startWith
}
}
p.EtcdVersion = etcdVersion

binDir, err := BindirForEtcdVersion(etcdVersion, "etcd")
if err != nil {
return err
}
p.BinDir = binDir
p.EtcdVersion = state.EtcdVersion

if state.NewCluster {
p.CreateNewCluster = true
Expand Down
8 changes: 4 additions & 4 deletions etcd-manager/test/integration/resize_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestResizeCluster(t *testing.T) {
t.Fatalf("unable to set test key: %v", err)
}

n1.AssertVersion(t, etcdVersion)
n1.AssertVersion(t, etcdversions.EtcdVersionForAdoption(etcdVersion))
}

n2 := h.NewNode("127.0.0.2")
Expand Down Expand Up @@ -107,9 +107,9 @@ func TestResizeCluster(t *testing.T) {
t.Fatalf("unexpected test key value after upgrade: %q", v)
}

n1.AssertVersion(t, etcdVersion)
n2.AssertVersion(t, etcdVersion)
n3.AssertVersion(t, etcdVersion)
n1.AssertVersion(t, etcdversions.EtcdVersionForAdoption(etcdVersion))
n2.AssertVersion(t, etcdversions.EtcdVersionForAdoption(etcdVersion))
n3.AssertVersion(t, etcdversions.EtcdVersionForAdoption(etcdVersion))
}

cancel()
Expand Down

0 comments on commit a8dc65c

Please sign in to comment.