From 606bab428898a329473c5fecd9c604d7a8cc42b6 Mon Sep 17 00:00:00 2001 From: CecileRobertMichon Date: Thu, 22 Feb 2018 15:19:13 -0800 Subject: [PATCH 1/4] fix quotation in etcd daemon args --- parts/k8s/kubernetesmastercustomdata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parts/k8s/kubernetesmastercustomdata.yml b/parts/k8s/kubernetesmastercustomdata.yml index a7f385b028..379f8db0df 100644 --- a/parts/k8s/kubernetesmastercustomdata.yml +++ b/parts/k8s/kubernetesmastercustomdata.yml @@ -352,7 +352,7 @@ runcmd: - ensure_etcd_ready - /opt/azure/containers/setup-etcd.sh > /opt/azure/containers/setup-etcd.log 2>&1 - apt-mark hold walinuxagent {{GetKubernetesMasterPreprovisionYaml}} -- /bin/echo DAEMON_ARGS=--name "{{WrapAsVerbatim "variables('masterVMNames')[copyIndex(variables('masterOffset'))]"}}" --peer-client-cert-auth --peer-trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --peer-cert-file={{WrapAsVerbatim "variables('etcdPeerCertFilepath')[copyIndex(variables('masterOffset'))]"}} --peer-key-file={{WrapAsVerbatim "variables('etcdPeerKeyFilepath')[copyIndex(variables('masterOffset'))]"}} --initial-advertise-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --client-cert-auth --trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --cert-file={{WrapAsVariable "etcdServerCertFilepath"}} --key-file={{WrapAsVariable "etcdServerKeyFilepath"}} --advertise-client-urls "{{WrapAsVerbatim "variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-client-urls "{{WrapAsVerbatim "concat(variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))], ',https://127.0.0.1:', variables('masterEtcdClientPort'))"}}" --initial-cluster-token "k8s-etcd-cluster" --initial-cluster "{{WrapAsVerbatim "variables('masterEtcdClusterStates')[div(variables('masterCount'), 2)]"}} --data-dir "/var/lib/etcddisk"" --initial-cluster-state "new" | tee -a /etc/default/etcd +- /bin/echo DAEMON_ARGS=--name "{{WrapAsVerbatim "variables('masterVMNames')[copyIndex(variables('masterOffset'))]"}}" --peer-client-cert-auth --peer-trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --peer-cert-file={{WrapAsVerbatim "variables('etcdPeerCertFilepath')[copyIndex(variables('masterOffset'))]"}} --peer-key-file={{WrapAsVerbatim "variables('etcdPeerKeyFilepath')[copyIndex(variables('masterOffset'))]"}} --initial-advertise-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --client-cert-auth --trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --cert-file={{WrapAsVariable "etcdServerCertFilepath"}} --key-file={{WrapAsVariable "etcdServerKeyFilepath"}} --advertise-client-urls "{{WrapAsVerbatim "variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-client-urls "{{WrapAsVerbatim "concat(variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))], ',https://127.0.0.1:', variables('masterEtcdClientPort'))"}}" --initial-cluster-token "k8s-etcd-cluster" --initial-cluster {{WrapAsVerbatim "variables('masterEtcdClusterStates')[div(variables('masterCount'), 2)]"}} --data-dir "/var/lib/etcddisk" --initial-cluster-state "new" | tee -a /etc/default/etcd - /opt/azure/containers/mountetcd.sh - /bin/chown -R etcd:etcd /var/lib/etcddisk - systemctl stop etcd From cae393715df78e49334d554b8b1a9286a34956e0 Mon Sep 17 00:00:00 2001 From: CecileRobertMichon Date: Thu, 22 Feb 2018 15:19:19 -0800 Subject: [PATCH 2/4] Revert "fix quotation in etcd daemon args" This reverts commit 606bab428898a329473c5fecd9c604d7a8cc42b6. --- parts/k8s/kubernetesmastercustomdata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parts/k8s/kubernetesmastercustomdata.yml b/parts/k8s/kubernetesmastercustomdata.yml index 379f8db0df..a7f385b028 100644 --- a/parts/k8s/kubernetesmastercustomdata.yml +++ b/parts/k8s/kubernetesmastercustomdata.yml @@ -352,7 +352,7 @@ runcmd: - ensure_etcd_ready - /opt/azure/containers/setup-etcd.sh > /opt/azure/containers/setup-etcd.log 2>&1 - apt-mark hold walinuxagent {{GetKubernetesMasterPreprovisionYaml}} -- /bin/echo DAEMON_ARGS=--name "{{WrapAsVerbatim "variables('masterVMNames')[copyIndex(variables('masterOffset'))]"}}" --peer-client-cert-auth --peer-trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --peer-cert-file={{WrapAsVerbatim "variables('etcdPeerCertFilepath')[copyIndex(variables('masterOffset'))]"}} --peer-key-file={{WrapAsVerbatim "variables('etcdPeerKeyFilepath')[copyIndex(variables('masterOffset'))]"}} --initial-advertise-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --client-cert-auth --trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --cert-file={{WrapAsVariable "etcdServerCertFilepath"}} --key-file={{WrapAsVariable "etcdServerKeyFilepath"}} --advertise-client-urls "{{WrapAsVerbatim "variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-client-urls "{{WrapAsVerbatim "concat(variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))], ',https://127.0.0.1:', variables('masterEtcdClientPort'))"}}" --initial-cluster-token "k8s-etcd-cluster" --initial-cluster {{WrapAsVerbatim "variables('masterEtcdClusterStates')[div(variables('masterCount'), 2)]"}} --data-dir "/var/lib/etcddisk" --initial-cluster-state "new" | tee -a /etc/default/etcd +- /bin/echo DAEMON_ARGS=--name "{{WrapAsVerbatim "variables('masterVMNames')[copyIndex(variables('masterOffset'))]"}}" --peer-client-cert-auth --peer-trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --peer-cert-file={{WrapAsVerbatim "variables('etcdPeerCertFilepath')[copyIndex(variables('masterOffset'))]"}} --peer-key-file={{WrapAsVerbatim "variables('etcdPeerKeyFilepath')[copyIndex(variables('masterOffset'))]"}} --initial-advertise-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --client-cert-auth --trusted-ca-file={{WrapAsVariable "etcdCaFilepath"}} --cert-file={{WrapAsVariable "etcdServerCertFilepath"}} --key-file={{WrapAsVariable "etcdServerKeyFilepath"}} --advertise-client-urls "{{WrapAsVerbatim "variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-client-urls "{{WrapAsVerbatim "concat(variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))], ',https://127.0.0.1:', variables('masterEtcdClientPort'))"}}" --initial-cluster-token "k8s-etcd-cluster" --initial-cluster "{{WrapAsVerbatim "variables('masterEtcdClusterStates')[div(variables('masterCount'), 2)]"}} --data-dir "/var/lib/etcddisk"" --initial-cluster-state "new" | tee -a /etc/default/etcd - /opt/azure/containers/mountetcd.sh - /bin/chown -R etcd:etcd /var/lib/etcddisk - systemctl stop etcd From e66db74eccf7724a7fa2e5715d68b0c93e42957e Mon Sep 17 00:00:00 2001 From: CecileRobertMichon Date: Mon, 26 Feb 2018 17:35:11 -0800 Subject: [PATCH 3/4] trim v in orch ver / rel --- pkg/api/common/helper.go | 3 +++ pkg/api/vlabs/validate_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/api/common/helper.go b/pkg/api/common/helper.go index ef7d9d5a32..4e9580db14 100644 --- a/pkg/api/common/helper.go +++ b/pkg/api/common/helper.go @@ -98,6 +98,9 @@ func GetValidPatchVersion(orchType, orchVer string) string { // RationalizeReleaseAndVersion return a version when it can be rationalized from the input, otherwise "" func RationalizeReleaseAndVersion(orchType, orchRel, orchVer string) (version string) { + // ignore "v" prefix in orchestrator version and release: "v1.8.0" is equivalent to "1.8.0", "v1.9" is equivalent to "1.9" + orchVer = strings.TrimPrefix(orchVer, "v") + orchRel = strings.TrimPrefix(orchRel, "v") supportedVersions, defaultVersion := GetSupportedVersions(orchType) if supportedVersions == nil { return "" diff --git a/pkg/api/vlabs/validate_test.go b/pkg/api/vlabs/validate_test.go index d336385c69..f964df9ecb 100644 --- a/pkg/api/vlabs/validate_test.go +++ b/pkg/api/vlabs/validate_test.go @@ -63,6 +63,16 @@ func Test_OrchestratorProfile_Validate(t *testing.T) { if err := o.Validate(true); err != nil { t.Errorf("should not have failed on old patch version during update valdiation") } + + o = &OrchestratorProfile{ + OrchestratorType: "Kubernetes", + OrchestratorVersion: "v1.9.0", + } + + if err := o.Validate(false); err != nil { + t.Errorf("should not have failed on version with v prefix") + } + } func Test_KubernetesConfig_Validate(t *testing.T) { From 41beef4c37cebea753c9a0231bcafb8d4fea58b9 Mon Sep 17 00:00:00 2001 From: CecileRobertMichon Date: Mon, 26 Feb 2018 17:38:54 -0800 Subject: [PATCH 4/4] add unit tests --- pkg/api/common/helper_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/api/common/helper_test.go b/pkg/api/common/helper_test.go index 15a46fda58..688ca83fda 100644 --- a/pkg/api/common/helper_test.go +++ b/pkg/api/common/helper_test.go @@ -80,4 +80,13 @@ func Test_RationalizeReleaseAndVersion(t *testing.T) { t.Errorf("It is not 1.5.8") } + version = RationalizeReleaseAndVersion(Kubernetes, "", "v1.8.8") + if version != KubernetesVersion1Dot8Dot8 { + t.Errorf("It is not Kubernetes version %s", KubernetesVersion1Dot8Dot8) + } + + version = RationalizeReleaseAndVersion(Kubernetes, "v1.9", "") + if version != KubernetesVersion1Dot9Dot3 { + t.Errorf("It is not Kubernetes version %s", KubernetesVersion1Dot9Dot3) + } }