Skip to content

Commit

Permalink
Merge pull request #80833 from neolit123/1.16-update-version
Browse files Browse the repository at this point in the history
kubeadm: update the version constants for 1.16
  • Loading branch information
k8s-ci-robot committed Aug 1, 2019
2 parents b91d64b + 8aa69ea commit f5c9d38
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
2 changes: 2 additions & 0 deletions cmd/kubeadm/app/cmd/upgrade/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ go_test(
embed = [":go_default_library"],
deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//cmd/kubeadm/app/constants:go_default_library",
"//cmd/kubeadm/app/phases/upgrade:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
],
)

Expand Down
17 changes: 8 additions & 9 deletions cmd/kubeadm/app/cmd/upgrade/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ import (
"testing"

kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
)

const (
validConfig = `apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: 1.13.0
`
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
)

func TestGetK8sVersionFromUserInput(t *testing.T) {
currentVersion := "v" + constants.CurrentKubernetesVersion.String()
validConfig := "apiVersion: kubeadm.k8s.io/v1beta2\n" +
"kind: ClusterConfiguration\n" +
"kubernetesVersion: " + currentVersion

var tcases = []struct {
name string
isVersionMandatory bool
Expand Down Expand Up @@ -62,7 +61,7 @@ func TestGetK8sVersionFromUserInput(t *testing.T) {
name: "Valid config, but no version specified",
isVersionMandatory: true,
clusterConfig: validConfig,
expectedVersion: "v1.13.0",
expectedVersion: currentVersion,
},
{
name: "Valid config and different version specified",
Expand Down Expand Up @@ -105,7 +104,7 @@ func TestGetK8sVersionFromUserInput(t *testing.T) {
t.Errorf("Unexpected error: %+v", err)
}
if userVersion != tt.expectedVersion {
t.Errorf("Expected '%s', but got '%s'", tt.expectedVersion, userVersion)
t.Errorf("Expected %q, but got %q", tt.expectedVersion, userVersion)
}
})
}
Expand Down
41 changes: 37 additions & 4 deletions cmd/kubeadm/app/cmd/upgrade/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,48 @@ package upgrade

import (
"io/ioutil"
"os"
"testing"
)

const (
testUpgradeDiffConfig = `testdata/diff_controlplane_config.yaml`
testUpgradeDiffManifest = `testdata/diff_dummy_manifest.yaml`
"github.com/pkg/errors"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
)

func createTestRunDiffFile(contents []byte) (string, error) {
file, err := ioutil.TempFile("", "kubeadm-upgrade-diff-config-*.yaml")
if err != nil {
return "", errors.Wrap(err, "failed to create temporary test file")
}
if _, err := file.Write([]byte(contents)); err != nil {
return "", errors.Wrap(err, "failed to write to temporary test file")
}
if err := file.Close(); err != nil {
return "", errors.Wrap(err, "failed to close temporary test file")
}
return file.Name(), nil
}

func TestRunDiff(t *testing.T) {
currentVersion := "v" + constants.CurrentKubernetesVersion.String()

// create a temporary file with valid ClusterConfiguration
testUpgradeDiffConfigContents := []byte("apiVersion: kubeadm.k8s.io/v1beta2\n" +
"kind: ClusterConfiguration\n" +
"kubernetesVersion: " + currentVersion)
testUpgradeDiffConfig, err := createTestRunDiffFile(testUpgradeDiffConfigContents)
if err != nil {
t.Fatal(err)
}
defer os.Remove(testUpgradeDiffConfig)

// create a temporary manifest file with dummy contents
testUpgradeDiffManifestContents := []byte("some-contents")
testUpgradeDiffManifest, err := createTestRunDiffFile(testUpgradeDiffManifestContents)
if err != nil {
t.Fatal(err)
}
defer os.Remove(testUpgradeDiffManifest)

flags := &diffFlags{
cfgPath: "",
out: ioutil.Discard,
Expand Down

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions cmd/kubeadm/app/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,13 @@ var (
ControlPlaneComponents = []string{KubeAPIServer, KubeControllerManager, KubeScheduler}

// MinimumControlPlaneVersion specifies the minimum control plane version kubeadm can deploy
MinimumControlPlaneVersion = version.MustParseSemantic("v1.13.0")
MinimumControlPlaneVersion = version.MustParseSemantic("v1.15.0")

// MinimumKubeletVersion specifies the minimum version of kubelet which kubeadm supports
MinimumKubeletVersion = version.MustParseSemantic("v1.13.0")
MinimumKubeletVersion = version.MustParseSemantic("v1.15.0")

// CurrentKubernetesVersion specifies current Kubernetes version supported by kubeadm
CurrentKubernetesVersion = version.MustParseSemantic("v1.14.0")
CurrentKubernetesVersion = version.MustParseSemantic("v1.16.0")

// SupportedEtcdVersion lists officially supported etcd versions with corresponding Kubernetes releases
SupportedEtcdVersion = map[uint8]string{
Expand Down
13 changes: 6 additions & 7 deletions cmd/kubeadm/app/phases/upgrade/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ func TestEnforceVersionPolicies(t *testing.T) {
{
name: "downgrading two minor versions in one go is not supported",
vg: &fakeVersionGetter{
clusterVersion: "v1.15.3",
kubeletVersion: "v1.15.3",
kubeadmVersion: "v1.15.0",
clusterVersion: constants.CurrentKubernetesVersion.WithMinor(constants.CurrentKubernetesVersion.Minor() + 2).String(),
kubeletVersion: constants.CurrentKubernetesVersion.WithMinor(constants.CurrentKubernetesVersion.Minor() + 2).String(),
kubeadmVersion: constants.CurrentKubernetesVersion.String(),
},
newK8sVersion: constants.MinimumControlPlaneVersion.WithPatch(3).String(),
newK8sVersion: constants.CurrentKubernetesVersion.String(),
expectedMandatoryErrs: 1, // can't downgrade two minor versions
expectedSkippableErrs: 1, // can't upgrade old k8s with newer kubeadm
},
{
name: "kubeadm version must be higher than the new kube version. However, patch version skews may be forced",
Expand Down Expand Up @@ -213,10 +212,10 @@ func TestEnforceVersionPolicies(t *testing.T) {
}

if len(actualSkewErrs.Skippable) != rt.expectedSkippableErrs {
t.Errorf("failed TestEnforceVersionPolicies\n\texpected skippable errors: %d\n\tgot skippable errors: %d %v", rt.expectedSkippableErrs, len(actualSkewErrs.Skippable), *rt.vg)
t.Errorf("failed TestEnforceVersionPolicies\n\texpected skippable errors: %d\n\tgot skippable errors: %d\n%#v\n%#v", rt.expectedSkippableErrs, len(actualSkewErrs.Skippable), *rt.vg, actualSkewErrs)
}
if len(actualSkewErrs.Mandatory) != rt.expectedMandatoryErrs {
t.Errorf("failed TestEnforceVersionPolicies\n\texpected mandatory errors: %d\n\tgot mandatory errors: %d %v", rt.expectedMandatoryErrs, len(actualSkewErrs.Mandatory), *rt.vg)
t.Errorf("failed TestEnforceVersionPolicies\n\texpected mandatory errors: %d\n\tgot mandatory errors: %d\n%#v\n%#v", rt.expectedMandatoryErrs, len(actualSkewErrs.Mandatory), *rt.vg, actualSkewErrs)
}
})
}
Expand Down

0 comments on commit f5c9d38

Please sign in to comment.