Commit 4a37e056 authored by leigh schrandt's avatar leigh schrandt

[kubeadm] Update test-case, fix nil-pointer bug, and improve error message

parent 99a11436
...@@ -313,7 +313,7 @@ func EtcdSupportedVersion(versionString string) (*version.Version, error) { ...@@ -313,7 +313,7 @@ func EtcdSupportedVersion(versionString string) (*version.Version, error) {
} }
return etcdVersion, nil return etcdVersion, nil
} }
return nil, fmt.Errorf("Unsupported or unknown kubernetes version") return nil, fmt.Errorf("Unsupported or unknown kubernetes version(%v)", kubernetesVersion)
} }
// GetStaticPodDirectory returns the location on the disk where the Static Pod should be present // GetStaticPodDirectory returns the location on the disk where the Static Pod should be present
......
...@@ -124,7 +124,7 @@ func TestEtcdSupportedVersion(t *testing.T) { ...@@ -124,7 +124,7 @@ func TestEtcdSupportedVersion(t *testing.T) {
{ {
kubernetesVersion: "1.99.0", kubernetesVersion: "1.99.0",
expectedVersion: nil, expectedVersion: nil,
expectedError: fmt.Errorf("Unsupported or unknown kubernetes version"), expectedError: fmt.Errorf("Unsupported or unknown kubernetes version(1.99.0)"),
}, },
{ {
kubernetesVersion: "1.9.0", kubernetesVersion: "1.9.0",
......
...@@ -222,11 +222,11 @@ func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathM ...@@ -222,11 +222,11 @@ func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathM
// Need to check currently used version and version from constants, if differs then upgrade // Need to check currently used version and version from constants, if differs then upgrade
desiredEtcdVersion, err := constants.EtcdSupportedVersion(cfg.KubernetesVersion) desiredEtcdVersion, err := constants.EtcdSupportedVersion(cfg.KubernetesVersion)
if err != nil { if err != nil {
return true, fmt.Errorf("failed to parse the desired etcd version(%s): %v", desiredEtcdVersion.String(), err) return true, fmt.Errorf("failed to retrieve an etcd version for the target kubernetes version: %v", err)
} }
currentEtcdVersion, err := version.ParseSemantic(etcdStatus.Version) currentEtcdVersion, err := version.ParseSemantic(etcdStatus.Version)
if err != nil { if err != nil {
return true, fmt.Errorf("failed to parse the current etcd version(%s): %v", currentEtcdVersion.String(), err) return true, fmt.Errorf("failed to parse the current etcd version(%s): %v", etcdStatus.Version, err)
} }
// Comparing current etcd version with desired to catch the same version or downgrade condition and fail on them. // Comparing current etcd version with desired to catch the same version or downgrade condition and fail on them.
......
...@@ -368,7 +368,7 @@ func TestStaticPodControlPlane(t *testing.T) { ...@@ -368,7 +368,7 @@ func TestStaticPodControlPlane(t *testing.T) {
} }
defer os.RemoveAll(tmpEtcdDataDir) defer os.RemoveAll(tmpEtcdDataDir)
oldcfg, err := getConfig("v1.7.0", tempCertsDir) oldcfg, err := getConfig("v1.9.0", tempCertsDir, tmpEtcdDataDir)
if err != nil { if err != nil {
t.Fatalf("couldn't create config: %v", err) t.Fatalf("couldn't create config: %v", err)
} }
...@@ -410,7 +410,7 @@ func TestStaticPodControlPlane(t *testing.T) { ...@@ -410,7 +410,7 @@ func TestStaticPodControlPlane(t *testing.T) {
t.Fatalf("couldn't read temp file: %v", err) t.Fatalf("couldn't read temp file: %v", err)
} }
newcfg, err := getConfig("v1.8.0", tempCertsDir) newcfg, err := getConfig("v1.10.0", tempCertsDir, tmpEtcdDataDir)
if err != nil { if err != nil {
t.Fatalf("couldn't create config: %v", err) t.Fatalf("couldn't create config: %v", err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment