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

This commit is contained in:
leigh schrandt 2018-04-16 07:57:29 -06:00
parent 99a1143676
commit 4a37e05665
4 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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",

View File

@ -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.

View File

@ -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) {
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)
} }