Skip to content

Commit

Permalink
Bump helm to v2.17.0 (#3611)
Browse files Browse the repository at this point in the history
* bump helm to v2.17.0

Author:    shonge <[email protected]>

* fix helm v2.10+ set boolean

* fix TidbClusterHelmSetBoolean

* add preload tidb-binlog image

* fix typo

Co-authored-by: DanielZhangQD <[email protected]>
  • Loading branch information
shonge and DanielZhangQD authored Dec 25, 2020
1 parent be3806c commit 997286b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 33 deletions.
4 changes: 2 additions & 2 deletions ci/deploy_tidb_operator_staging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def call(BUILD_BRANCH) {
writeFile file: 'values.yaml', text: "${values}"
sh """
# ensure helm
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz
tar -zxvf helm-v2.9.1-linux-amd64.tar.gz
wget https://storage.googleapis.com/kubernetes-helm/helm-v2.17.0-linux-amd64.tar.gz
tar -zxvf helm-v2.17.0-linux-amd64.tar.gz
chmod +x linux-amd64/helm
# deploy to staging
Expand Down
2 changes: 1 addition & 1 deletion hack/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOCS_BIN=$OUTPUT_BIN/gen-crd-api-reference-docs
# Don't upgrade to 2.15.x/2.16.x until this issue
# (https://github.com/helm/helm/issues/6361) has been fixed.
#
HELM_VERSION=${HELM_VERSION:-2.9.1}
HELM_VERSION=${HELM_VERSION:-2.17.0}
KIND_VERSION=${KIND_VERSION:-0.8.1}
DOCS_VERSION=${DOCS_VERSION:-0.2.1}
KIND_BIN=$OUTPUT_BIN/kind
Expand Down
81 changes: 53 additions & 28 deletions tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,24 @@ func (tc *TidbClusterConfig) TidbClusterHelmSetString(m map[string]string) strin
return strings.Join(arr, ",")
}

func (tc *TidbClusterConfig) TidbClusterHelmSetBoolean(m map[string]bool) string {
set := map[string]bool{
"enablePVReclaim": tc.EnablePVReclaim,
"monitor.create": tc.Monitor,
"enableConfigMapRollout": tc.EnableConfigMapRollout,
}

for k, v := range m {
set[k] = v
}

arr := make([]string, 0, len(set))
for k, v := range set {
arr = append(arr, fmt.Sprintf("%s=%v", k, v))
}
return strings.Join(arr, ",")
}

func (oi *OperatorConfig) OperatorHelmSetBoolean() string {
set := map[string]bool{
"admissionWebhook.create": oi.WebhookEnabled,
Expand Down Expand Up @@ -732,8 +750,8 @@ func (oa *operatorActions) DeployTidbCluster(info *TidbClusterConfig) error {
return fmt.Errorf("failed to create secret of cluster [%s]: %v", info.ClusterName, err)
}

cmd := fmt.Sprintf("helm install %s --name %s --namespace %s --set-string %s",
oa.tidbClusterChartPath(info.OperatorTag), info.ClusterName, info.Namespace, info.TidbClusterHelmSetString(nil))
cmd := fmt.Sprintf("helm install %s --name %s --namespace %s --set-string %s --set %s",
oa.tidbClusterChartPath(info.OperatorTag), info.ClusterName, info.Namespace, info.TidbClusterHelmSetString(nil), info.TidbClusterHelmSetBoolean(nil))

svFilePath, err := info.BuildSubValues(oa.tidbClusterChartPath(info.OperatorTag))
if err != nil {
Expand Down Expand Up @@ -1161,7 +1179,7 @@ func (oa *operatorActions) ScaleTidbCluster(info *TidbClusterConfig) error {
oa.EmitEvent(info, fmt.Sprintf("ScaleTidbCluster to pd: %s, tikv: %s, tidb: %s",
info.Args["pd.replicas"], info.Args["tikv.replicas"], info.Args["tidb.replicas"]))

cmd, err := oa.getHelmUpgradeClusterCmd(info, nil)
cmd, err := oa.getHelmUpgradeClusterCmd(info, nil, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -1257,7 +1275,7 @@ func (oa *operatorActions) setPartitionAnnotation(namespace, tcName, component s
func (oa *operatorActions) UpgradeTidbCluster(info *TidbClusterConfig) error {
oa.EmitEvent(info, "UpgradeTidbCluster")

cmd, err := oa.getHelmUpgradeClusterCmd(info, nil)
cmd, err := oa.getHelmUpgradeClusterCmd(info, nil, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -2694,17 +2712,18 @@ func (oa *operatorActions) DeployScheduledBackup(info *TidbClusterConfig) error
klog.Infof("begin to deploy scheduled backup")

cron := "'*/1 * * * *'"
sets := map[string]string{
setString := map[string]string{
"clusterName": info.ClusterName,
"scheduledBackup.create": "true",
"scheduledBackup.user": "root",
"scheduledBackup.password": info.Password,
"scheduledBackup.schedule": cron,
"scheduledBackup.storage": "10Gi",
"scheduledBackup.secretName": info.BackupSecretName,
}

cmd, err := oa.getHelmUpgradeClusterCmd(info, sets)
setBoolean := map[string]bool{
"scheduledBackup.create": true,
}
cmd, err := oa.getHelmUpgradeClusterCmd(info, setString, setBoolean)
if err != nil {
return err
}
Expand All @@ -2720,12 +2739,15 @@ func (oa *operatorActions) DeployScheduledBackup(info *TidbClusterConfig) error
func (oa *operatorActions) disableScheduledBackup(info *TidbClusterConfig) error {
klog.Infof("disabling scheduled backup")

sets := map[string]string{
"clusterName": info.ClusterName,
"scheduledBackup.create": "false",
setString := map[string]string{
"clusterName": info.ClusterName,
}

cmd, err := oa.getHelmUpgradeClusterCmd(info, sets)
setBoolean := map[string]bool{
"scheduledBackup.create": false,
}

cmd, err := oa.getHelmUpgradeClusterCmd(info, setString, setBoolean)
if err != nil {
return err
}
Expand Down Expand Up @@ -2930,23 +2952,26 @@ func (oa *operatorActions) DeployIncrementalBackup(from *TidbClusterConfig, to *
// https://github.com/pingcap/tidb-operator/pull/693
isv1 := from.OperatorTag == "v1.0.0"

sets := map[string]string{
"binlog.pump.create": "true",
setString := map[string]string{
"binlog.pump.storage": "1Gi",
"binlog.pump.image": fmt.Sprintf("pingcap/tidb-binlog:%v", from.ClusterVersion),
}

setBoolean := map[string]bool{
"binlog.pump.create": true,
}

if withDrainer {
sets["binlog.drainer.create"] = "true"
sets["binlog.drainer.image"] = fmt.Sprintf("pingcap/tidb-binlog:%v", from.ClusterVersion)
setBoolean["binlog.drainer.create"] = true
setString["binlog.drainer.image"] = fmt.Sprintf("pingcap/tidb-binlog:%v", from.ClusterVersion)
if isv1 {
sets["binlog.pump.create"] = "true"
sets["binlog.drainer.destDBType"] = "mysql"
sets["binlog.drainer.mysql.host"] = fmt.Sprintf("%s-tidb.%s", to.ClusterName, to.Namespace)
sets["binlog.drainer.mysql.user"] = "root"
sets["binlog.drainer.mysql.password"] = to.Password
sets["binlog.drainer.mysql.port"] = "4000"
sets["binlog.drainer.ignoreSchemas"] = ""
setBoolean["binlog.pump.create"] = true
setString["binlog.drainer.destDBType"] = "mysql"
setString["binlog.drainer.mysql.host"] = fmt.Sprintf("%s-tidb.%s", to.ClusterName, to.Namespace)
setString["binlog.drainer.mysql.user"] = "root"
setString["binlog.drainer.mysql.password"] = to.Password
setString["binlog.drainer.mysql.port"] = "4000"
setString["binlog.drainer.ignoreSchemas"] = ""
} else {
from.drainerConfig = []string{
`detect-interval = 10`,
Expand All @@ -2968,10 +2993,10 @@ func (oa *operatorActions) DeployIncrementalBackup(from *TidbClusterConfig, to *
}

if ts != "" {
sets["binlog.drainer.initialCommitTs"] = ts
setString["binlog.drainer.initialCommitTs"] = ts
}

cmd, err := oa.getHelmUpgradeClusterCmd(from, sets)
cmd, err := oa.getHelmUpgradeClusterCmd(from, setString, setBoolean)
if err != nil {
return err
}
Expand Down Expand Up @@ -3387,9 +3412,9 @@ func (oa *operatorActions) eventWorker() {
}
}

func (oa *operatorActions) getHelmUpgradeClusterCmd(info *TidbClusterConfig, set map[string]string) (string, error) {
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s",
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), info.TidbClusterHelmSetString(set))
func (oa *operatorActions) getHelmUpgradeClusterCmd(info *TidbClusterConfig, setString map[string]string, setBoolean map[string]bool) (string, error) {
cmd := fmt.Sprintf("helm upgrade %s %s --set-string %s --set %s",
info.ClusterName, oa.tidbClusterChartPath(info.OperatorTag), info.TidbClusterHelmSetString(setString), info.TidbClusterHelmSetBoolean(setBoolean))
svFilePath, err := info.BuildSubValues(oa.tidbClusterChartPath(info.OperatorTag))
if err != nil {
return "", err
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/util/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func ListImages() []string {
images = append(images, fmt.Sprintf("pingcap/pd:%s", v))
images = append(images, fmt.Sprintf("pingcap/tidb:%s", v))
images = append(images, fmt.Sprintf("pingcap/tikv:%s", v))
images = append(images, fmt.Sprintf("pingcap/tidb-binlog:%s", v))
}
images = append(images, fmt.Sprintf("%s:%s", PrometheusImage, PrometheusVersion))
images = append(images, fmt.Sprintf("%s:%s", TiDBMonitorReloaderImage, TiDBMonitorReloaderVersion))
Expand Down
2 changes: 1 addition & 1 deletion tests/images/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:buster-slim

ENV KUBECTL_VERSION=v1.12.2
ENV HELM_VERSION=v2.9.1
ENV HELM_VERSION=v2.17.0

# python is required by gcloud
RUN apt-get update && \
Expand Down
2 changes: 1 addition & 1 deletion tests/images/stability-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.10

ENV KUBECTL_VERSION=v1.12.2
ENV HELM_VERSION=v2.9.1
ENV HELM_VERSION=v2.17.0

RUN apk update && apk add --no-cache ca-certificates curl git openssl bash mysql-client
RUN curl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
Expand Down

0 comments on commit 997286b

Please sign in to comment.