From 521f8e2801f6afd98b991376a96fa85956ab1111 Mon Sep 17 00:00:00 2001 From: shonge Date: Fri, 5 Jun 2020 21:34:28 +0800 Subject: [PATCH 1/8] support memory storage for etcd in kind --- hack/e2e.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/hack/e2e.sh b/hack/e2e.sh index 4a3c636ba5..e28fcea8ff 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -64,6 +64,7 @@ Environments: GCR_IO_MIRROR configure mirror for gcr.io QUAY_IO_MIRROR configure mirror for quay.io KIND_DATA_HOSTPATH (kind only) the host path of data directory for kind cluster, defaults: none + ETCD_STORAGE_TYPE (kind only) the etcd storage type [disk, memory], default: disk GCP_PROJECT (gke only) the GCP project to run in GCP_CREDENTIALS (gke only) the GCP service account to use GCP_REGION (gke only) the GCP region, if specified a regional cluster is creaetd @@ -187,6 +188,7 @@ SKIP_TEST=${SKIP_TEST:-} SKIP_DUMP=${SKIP_DUMP:-} REUSE_CLUSTER=${REUSE_CLUSTER:-} KIND_DATA_HOSTPATH=${KIND_DATA_HOSTPATH:-none} +ETCD_STORAGE_TYPE=${ETCD_STORAGE_TYPE:-disk} GCP_PROJECT=${GCP_PROJECT:-} GCP_CREDENTIALS=${GCP_CREDENTIALS:-} GCP_REGION=${GCP_REGION:-} @@ -219,6 +221,7 @@ echo "SKIP_DOWN: $SKIP_DOWN" echo "SKIP_TEST: $SKIP_TEST" echo "SKIP_DUMP: $SKIP_DUMP" echo "KIND_DATA_HOSTPATH: $KIND_DATA_HOSTPATH" +echo "ETCD_STORAGE_TYPE: $ETCD_STORAGE_TYPE" echo "GCP_PROJECT: $GCP_PROJECT" echo "GCP_CREDENTIALS: $GCP_CREDENTIALS" echo "GCP_REGION: $GCP_REGION" @@ -366,19 +369,52 @@ EOF nodes: - role: control-plane EOF - if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then - if [ ! -d "$KIND_DATA_HOSTPATH" ]; then - echo "error: '$KIND_DATA_HOSTPATH' is not a directory" - exit 1 - fi - local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" - test -d $hostWorkerPath || mkdir $hostWorkerPath - cat <> $tmpfile + # check $ETCD_STORAGE_TYPE in [disk, memory] + if [[$ETCD_STORAGE_TYPE == "disk" || $ETCD_STORAGE_TYPE == "memory"]]; then + # check $KIND_DATA_HOSTPATH + if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then + if [ ! -d "$KIND_DATA_HOSTPATH" ]; then + echo "error: '$KIND_DATA_HOSTPATH' is not a directory" + exit 1 + fi + local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" + test -d $hostWorkerPath || mkdir $hostWorkerPath + # set custom KIND_DATA_HOSTPATH and ETCD_STORAGE_TYPE in disk + if [[ "$ETCD_STORAGE_TYPE" == "disk" ]]; then + cat <> $tmpfile + extraMounts: + - containerPath: /mnt/disks/ + hostPath: "$hostWorkerPath" + propagation: HostToContainer +EOF + # set custom KIND_DATA_HOSTPATH and ETCD_STORAGE_TYPE in memory + elif [[ "$ETCD_STORAGE_TYPE" == "memory" ]]; then + mkdir /tmp/etcd + mount -t tmpfs /tmp/etcd + cat <> $tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" propagation: HostToContainer + - containerPath: /var/lib/etcd + hostPath: /tmp/etcd +EOF + fi + else + # set ETCD_STORAGE_TYPE in memory + if [[ "$ETCD_STORAGE_TYPE" == "memory" ]]; then + mkdir /tmp/etcd + mount -t tmpfs /tmp/etcd + cat <> $tmpfile + extraMounts: + - containerPath: /var/lib/etcd + hostPath: /tmp/etcd EOF + fi + fi + else + echo "error: '$ETCD_STORAGE_TYPE' is incorrect, must be [disk, memory]" + exit 1 fi # workers for ((i = 1; i <= $KUBE_WORKERS; i++)) { From efed0f706a9ae48393b25026a7437f416826c4b9 Mon Sep 17 00:00:00 2001 From: shonge Date: Fri, 5 Jun 2020 21:44:23 +0800 Subject: [PATCH 2/8] export ETCD_STORAGE_TYPE=memory in e2e_kind.groovy --- ci/e2e_kind.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/e2e_kind.groovy b/ci/e2e_kind.groovy index f7824e5fa0..5e07f3ca9f 100644 --- a/ci/e2e_kind.groovy +++ b/ci/e2e_kind.groovy @@ -199,6 +199,7 @@ pipeline { export DELETE_NAMESPACE_ON_FAILURE=${params.DELETE_NAMESPACE_ON_FAILURE} export ARTIFACTS=${ARTIFACTS} export GINKGO_NO_COLOR=y + export ETCD_STORAGE_TYPE=memory echo "info: begin to run e2e" ./hack/e2e.sh -- ${params.E2E_ARGS} """ From 80ae5b4bf364ba44cebcc7a8e214f94d44d355e7 Mon Sep 17 00:00:00 2001 From: shonge Date: Fri, 5 Jun 2020 22:02:00 +0800 Subject: [PATCH 3/8] fix a bug --- hack/e2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/e2e.sh b/hack/e2e.sh index e28fcea8ff..1952961cb5 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -370,7 +370,7 @@ nodes: - role: control-plane EOF # check $ETCD_STORAGE_TYPE in [disk, memory] - if [[$ETCD_STORAGE_TYPE == "disk" || $ETCD_STORAGE_TYPE == "memory"]]; then + if [[ "$ETCD_STORAGE_TYPE" == "disk" || $ETCD_STORAGE_TYPE == "memory" ]]; then # check $KIND_DATA_HOSTPATH if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then if [ ! -d "$KIND_DATA_HOSTPATH" ]; then From 1f9dc65777ddf22d5cd98272ba36ff08b646a549 Mon Sep 17 00:00:00 2001 From: shonge Date: Mon, 8 Jun 2020 20:57:06 +0800 Subject: [PATCH 4/8] use KIND_ETCD_DATADIR instead of ETCD_STORAGE_TYPE --- ci/e2e_kind.groovy | 1 - ci/pingcap_tidb_operator_build_kind.groovy | 7 ++- hack/e2e.sh | 58 +++++++++++----------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/ci/e2e_kind.groovy b/ci/e2e_kind.groovy index 5e07f3ca9f..f7824e5fa0 100644 --- a/ci/e2e_kind.groovy +++ b/ci/e2e_kind.groovy @@ -199,7 +199,6 @@ pipeline { export DELETE_NAMESPACE_ON_FAILURE=${params.DELETE_NAMESPACE_ON_FAILURE} export ARTIFACTS=${ARTIFACTS} export GINKGO_NO_COLOR=y - export ETCD_STORAGE_TYPE=memory echo "info: begin to run e2e" ./hack/e2e.sh -- ${params.E2E_ARGS} """ diff --git a/ci/pingcap_tidb_operator_build_kind.groovy b/ci/pingcap_tidb_operator_build_kind.groovy index 7e6e293e1c..dfa90bd21a 100644 --- a/ci/pingcap_tidb_operator_build_kind.groovy +++ b/ci/pingcap_tidb_operator_build_kind.groovy @@ -63,6 +63,8 @@ spec: # legacy docker path for cr.io/k8s-testimages/kubekins-e2e - name: docker-graph mountPath: /docker-graph + - name: etcd-data-dir + mountPath: /mnt/tmpfs/etcd volumes: - name: modules hostPath: @@ -76,6 +78,9 @@ spec: emptyDir: {} - name: docker-graph emptyDir: {} + - name: etcd-data-dir + emptyDir: + medium: Memory tolerations: - effect: NoSchedule key: tidb-operator @@ -301,7 +306,7 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { } } - def GLOBALS = "SKIP_BUILD=y SKIP_IMAGE_BUILD=y DOCKER_REPO=hub.pingcap.net/tidb-operator-e2e IMAGE_TAG=${GITHASH} DELETE_NAMESPACE_ON_FAILURE=true GINKGO_NO_COLOR=y" + def GLOBALS = "KIND_ETCD_DATADIR=/mnt/tmpfs/etcd SKIP_BUILD=y SKIP_IMAGE_BUILD=y DOCKER_REPO=hub.pingcap.net/tidb-operator-e2e IMAGE_TAG=${GITHASH} DELETE_NAMESPACE_ON_FAILURE=true GINKGO_NO_COLOR=y" def builds = [:] // We must not enable operator killer for Kubernetes before 1.15 in // which webhook configuration does not support objectSelector. Webhook diff --git a/hack/e2e.sh b/hack/e2e.sh index 1952961cb5..aedfcec9b0 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -64,7 +64,7 @@ Environments: GCR_IO_MIRROR configure mirror for gcr.io QUAY_IO_MIRROR configure mirror for quay.io KIND_DATA_HOSTPATH (kind only) the host path of data directory for kind cluster, defaults: none - ETCD_STORAGE_TYPE (kind only) the etcd storage type [disk, memory], default: disk + KIND_ETCD_DATADIR (kind only) the host path of etcd data directory for kind cluster, defaults: none GCP_PROJECT (gke only) the GCP project to run in GCP_CREDENTIALS (gke only) the GCP service account to use GCP_REGION (gke only) the GCP region, if specified a regional cluster is creaetd @@ -188,7 +188,7 @@ SKIP_TEST=${SKIP_TEST:-} SKIP_DUMP=${SKIP_DUMP:-} REUSE_CLUSTER=${REUSE_CLUSTER:-} KIND_DATA_HOSTPATH=${KIND_DATA_HOSTPATH:-none} -ETCD_STORAGE_TYPE=${ETCD_STORAGE_TYPE:-disk} +KIND_ETCD_DATADIR=${KIND_ETCD_DATADIR:-none} GCP_PROJECT=${GCP_PROJECT:-} GCP_CREDENTIALS=${GCP_CREDENTIALS:-} GCP_REGION=${GCP_REGION:-} @@ -221,7 +221,7 @@ echo "SKIP_DOWN: $SKIP_DOWN" echo "SKIP_TEST: $SKIP_TEST" echo "SKIP_DUMP: $SKIP_DUMP" echo "KIND_DATA_HOSTPATH: $KIND_DATA_HOSTPATH" -echo "ETCD_STORAGE_TYPE: $ETCD_STORAGE_TYPE" +echo "KIND_ETCD_DATADIR: $KIND_ETCD_DATADIR" echo "GCP_PROJECT: $GCP_PROJECT" echo "GCP_CREDENTIALS: $GCP_CREDENTIALS" echo "GCP_REGION: $GCP_REGION" @@ -369,52 +369,52 @@ EOF nodes: - role: control-plane EOF - # check $ETCD_STORAGE_TYPE in [disk, memory] - if [[ "$ETCD_STORAGE_TYPE" == "disk" || $ETCD_STORAGE_TYPE == "memory" ]]; then + # check $KIND_ETCD_DATADIR + if [[ "$KIND_ETCD_DATADIR" != "none" ]]; then # check $KIND_DATA_HOSTPATH if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then if [ ! -d "$KIND_DATA_HOSTPATH" ]; then echo "error: '$KIND_DATA_HOSTPATH' is not a directory" exit 1 fi + if [ ! -d "$KIND_ETCD_DATADIR" ]; then + echo "error: '$KIND_ETCD_DATADIR' is not a directory" + exit 1 + fi local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath - # set custom KIND_DATA_HOSTPATH and ETCD_STORAGE_TYPE in disk - if [[ "$ETCD_STORAGE_TYPE" == "disk" ]]; then - cat <> $tmpfile - extraMounts: - - containerPath: /mnt/disks/ - hostPath: "$hostWorkerPath" - propagation: HostToContainer -EOF - # set custom KIND_DATA_HOSTPATH and ETCD_STORAGE_TYPE in memory - elif [[ "$ETCD_STORAGE_TYPE" == "memory" ]]; then - mkdir /tmp/etcd - mount -t tmpfs /tmp/etcd - cat <> $tmpfile + # set custom KIND_DATA_HOSTPATH and KIND_ETCD_DATADIR + cat <> $tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" propagation: HostToContainer - containerPath: /var/lib/etcd - hostPath: /tmp/etcd + hostPath: "$KIND_ETCD_DATADIR" EOF - fi else - # set ETCD_STORAGE_TYPE in memory - if [[ "$ETCD_STORAGE_TYPE" == "memory" ]]; then - mkdir /tmp/etcd - mount -t tmpfs /tmp/etcd - cat <> $tmpfile + # set custom KIND_ETCD_DATADIR + cat <> $tmpfile extraMounts: - containerPath: /var/lib/etcd - hostPath: /tmp/etcd + hostPath: "$KIND_ETCD_DATADIR" EOF - fi fi else - echo "error: '$ETCD_STORAGE_TYPE' is incorrect, must be [disk, memory]" - exit 1 + if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then + if [ ! -d "$KIND_DATA_HOSTPATH" ]; then + echo "error: '$KIND_DATA_HOSTPATH' is not a directory" + exit 1 + fi + local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" + test -d $hostWorkerPath || mkdir $hostWorkerPath + # set custom KIND_DATA_HOSTPATH + cat <> $tmpfile + extraMounts: + - containerPath: /mnt/disks/ + hostPath: "$hostWorkerPath" + propagation: HostToContainer +EOF fi # workers for ((i = 1; i <= $KUBE_WORKERS; i++)) { From 166d55802ede665240cb94956ca64030eaf95e69 Mon Sep 17 00:00:00 2001 From: shonge Date: Mon, 8 Jun 2020 21:04:21 +0800 Subject: [PATCH 5/8] fix typos --- ci/pingcap_tidb_operator_build_kind.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/pingcap_tidb_operator_build_kind.groovy b/ci/pingcap_tidb_operator_build_kind.groovy index dfa90bd21a..5adb70bee2 100644 --- a/ci/pingcap_tidb_operator_build_kind.groovy +++ b/ci/pingcap_tidb_operator_build_kind.groovy @@ -63,8 +63,9 @@ spec: # legacy docker path for cr.io/k8s-testimages/kubekins-e2e - name: docker-graph mountPath: /docker-graph - - name: etcd-data-dir - mountPath: /mnt/tmpfs/etcd + # use memory storage for etcd hostpath in kind cluster + - name: etcd-data-dir + mountPath: /mnt/tmpfs/etcd volumes: - name: modules hostPath: From 3ae083bcafbfc707d85734eb7aa2c7c00abfbc04 Mon Sep 17 00:00:00 2001 From: shonge Date: Mon, 8 Jun 2020 21:21:00 +0800 Subject: [PATCH 6/8] fix bugs --- hack/e2e.sh | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/hack/e2e.sh b/hack/e2e.sh index aedfcec9b0..eb859fc8d0 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -29,13 +29,11 @@ source "${ROOT}/hack/lib.sh" # check bash version BASH_MAJOR_VERSION=$(echo "$BASH_VERSION" | cut -d '.' -f 1) # we need bash version >= 4 -if [ $BASH_MAJOR_VERSION -lt 4 ] -then - echo "error: e2e.sh could not work with bash version earlier than 4 for now, please upgrade your bash" - exit 1 +if [ $BASH_MAJOR_VERSION -lt 4 ]; then + echo "error: e2e.sh could not work with bash version earlier than 4 for now, please upgrade your bash" + exit 1 fi - function usage() { cat <<'EOF' This script is entrypoint to run e2e tests. @@ -163,7 +161,7 @@ EOF while getopts "h?" opt; do case "$opt" in - h|\?) + h | \?) usage exit 0 ;; @@ -270,9 +268,9 @@ function e2e::__restart_docker() { local MAX_WAIT=5 while true; do # docker ps -q should only work if the daemon is ready - docker ps -q > /dev/null 2>&1 && break + docker ps -q >/dev/null 2>&1 && break if [[ ${WAIT_N} -lt ${MAX_WAIT} ]]; then - WAIT_N=$((WAIT_N+1)) + WAIT_N=$((WAIT_N + 1)) echo "info; Waiting for docker to be ready, sleeping for ${WAIT_N} seconds." sleep ${WAIT_N} else @@ -285,7 +283,7 @@ function e2e::__restart_docker() { function e2e::__configure_docker_mirror_for_dind() { echo "info: configure docker.io mirror '$DOCKER_IO_MIRROR' for DinD" -cat < /etc/docker/daemon.json.tmp + cat </etc/docker/daemon.json.tmp { "registry-mirrors": ["$DOCKER_IO_MIRROR"] } @@ -301,7 +299,7 @@ EOF function e2e::create_kindconfig() { local tmpfile=${1} - cat < $tmpfile + cat <$tmpfile kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 kubeadmConfigPatches: @@ -341,31 +339,31 @@ kubeadmConfigPatches: v: "4" EOF if [ -n "$DOCKER_IO_MIRROR" -o -n "$GCR_IO_MIRROR" -o -n "$QUAY_IO_MIRROR" ]; then -cat <> $tmpfile + cat <>$tmpfile containerdConfigPatches: - |- EOF if [ -n "$DOCKER_IO_MIRROR" ]; then -cat <> $tmpfile + cat <>$tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = ["$DOCKER_IO_MIRROR"] EOF fi if [ -n "$GCR_IO_MIRROR" ]; then -cat <> $tmpfile + cat <>$tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"] endpoint = ["$GCR_IO_MIRROR"] EOF fi if [ -n "$QUAY_IO_MIRROR" ]; then -cat <> $tmpfile + cat <>$tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."quay.io"] endpoint = ["$QUAY_IO_MIRROR"] EOF fi fi # control-plane - cat <> $tmpfile + cat <>$tmpfile nodes: - role: control-plane EOF @@ -384,7 +382,7 @@ EOF local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath # set custom KIND_DATA_HOSTPATH and KIND_ETCD_DATADIR - cat <> $tmpfile + cat <>$tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" @@ -394,13 +392,13 @@ EOF EOF else # set custom KIND_ETCD_DATADIR - cat <> $tmpfile + cat <>$tmpfile extraMounts: - containerPath: /var/lib/etcd hostPath: "$KIND_ETCD_DATADIR" EOF fi - else + else if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then if [ ! -d "$KIND_DATA_HOSTPATH" ]; then echo "error: '$KIND_DATA_HOSTPATH' is not a directory" @@ -409,16 +407,17 @@ EOF local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath # set custom KIND_DATA_HOSTPATH - cat <> $tmpfile + cat <>$tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" propagation: HostToContainer EOF + fi fi # workers for ((i = 1; i <= $KUBE_WORKERS; i++)) { - cat <> $tmpfile + cat <>$tmpfile - role: worker EOF if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then @@ -428,7 +427,7 @@ EOF fi local hostWorkerPath="${KIND_DATA_HOSTPATH}/worker${i}" test -d $hostWorkerPath || mkdir $hostWorkerPath - cat <> $tmpfile + cat <>$tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" From 84b878e0412f1c9874af501efb4a41bb4bb01009 Mon Sep 17 00:00:00 2001 From: shonge Date: Tue, 9 Jun 2020 10:39:24 +0800 Subject: [PATCH 7/8] Revert "fix bugs" This reverts commit 3ae083bcafbfc707d85734eb7aa2c7c00abfbc04. --- hack/e2e.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/hack/e2e.sh b/hack/e2e.sh index eb859fc8d0..aedfcec9b0 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -29,11 +29,13 @@ source "${ROOT}/hack/lib.sh" # check bash version BASH_MAJOR_VERSION=$(echo "$BASH_VERSION" | cut -d '.' -f 1) # we need bash version >= 4 -if [ $BASH_MAJOR_VERSION -lt 4 ]; then - echo "error: e2e.sh could not work with bash version earlier than 4 for now, please upgrade your bash" - exit 1 +if [ $BASH_MAJOR_VERSION -lt 4 ] +then + echo "error: e2e.sh could not work with bash version earlier than 4 for now, please upgrade your bash" + exit 1 fi + function usage() { cat <<'EOF' This script is entrypoint to run e2e tests. @@ -161,7 +163,7 @@ EOF while getopts "h?" opt; do case "$opt" in - h | \?) + h|\?) usage exit 0 ;; @@ -268,9 +270,9 @@ function e2e::__restart_docker() { local MAX_WAIT=5 while true; do # docker ps -q should only work if the daemon is ready - docker ps -q >/dev/null 2>&1 && break + docker ps -q > /dev/null 2>&1 && break if [[ ${WAIT_N} -lt ${MAX_WAIT} ]]; then - WAIT_N=$((WAIT_N + 1)) + WAIT_N=$((WAIT_N+1)) echo "info; Waiting for docker to be ready, sleeping for ${WAIT_N} seconds." sleep ${WAIT_N} else @@ -283,7 +285,7 @@ function e2e::__restart_docker() { function e2e::__configure_docker_mirror_for_dind() { echo "info: configure docker.io mirror '$DOCKER_IO_MIRROR' for DinD" - cat </etc/docker/daemon.json.tmp +cat < /etc/docker/daemon.json.tmp { "registry-mirrors": ["$DOCKER_IO_MIRROR"] } @@ -299,7 +301,7 @@ EOF function e2e::create_kindconfig() { local tmpfile=${1} - cat <$tmpfile + cat < $tmpfile kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 kubeadmConfigPatches: @@ -339,31 +341,31 @@ kubeadmConfigPatches: v: "4" EOF if [ -n "$DOCKER_IO_MIRROR" -o -n "$GCR_IO_MIRROR" -o -n "$QUAY_IO_MIRROR" ]; then - cat <>$tmpfile +cat <> $tmpfile containerdConfigPatches: - |- EOF if [ -n "$DOCKER_IO_MIRROR" ]; then - cat <>$tmpfile +cat <> $tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = ["$DOCKER_IO_MIRROR"] EOF fi if [ -n "$GCR_IO_MIRROR" ]; then - cat <>$tmpfile +cat <> $tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"] endpoint = ["$GCR_IO_MIRROR"] EOF fi if [ -n "$QUAY_IO_MIRROR" ]; then - cat <>$tmpfile +cat <> $tmpfile [plugins."io.containerd.grpc.v1.cri".registry.mirrors."quay.io"] endpoint = ["$QUAY_IO_MIRROR"] EOF fi fi # control-plane - cat <>$tmpfile + cat <> $tmpfile nodes: - role: control-plane EOF @@ -382,7 +384,7 @@ EOF local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath # set custom KIND_DATA_HOSTPATH and KIND_ETCD_DATADIR - cat <>$tmpfile + cat <> $tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" @@ -392,13 +394,13 @@ EOF EOF else # set custom KIND_ETCD_DATADIR - cat <>$tmpfile + cat <> $tmpfile extraMounts: - containerPath: /var/lib/etcd hostPath: "$KIND_ETCD_DATADIR" EOF fi - else + else if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then if [ ! -d "$KIND_DATA_HOSTPATH" ]; then echo "error: '$KIND_DATA_HOSTPATH' is not a directory" @@ -407,17 +409,16 @@ EOF local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath # set custom KIND_DATA_HOSTPATH - cat <>$tmpfile + cat <> $tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" propagation: HostToContainer EOF - fi fi # workers for ((i = 1; i <= $KUBE_WORKERS; i++)) { - cat <>$tmpfile + cat <> $tmpfile - role: worker EOF if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then @@ -427,7 +428,7 @@ EOF fi local hostWorkerPath="${KIND_DATA_HOSTPATH}/worker${i}" test -d $hostWorkerPath || mkdir $hostWorkerPath - cat <>$tmpfile + cat <> $tmpfile extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" From a4d6581e9d1402bc363150791bb4ca740ce36d4f Mon Sep 17 00:00:00 2001 From: shonge Date: Tue, 9 Jun 2020 11:10:03 +0800 Subject: [PATCH 8/8] revert format and simplified extraMounts --- hack/e2e.sh | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/hack/e2e.sh b/hack/e2e.sh index aedfcec9b0..6f13e134ec 100755 --- a/hack/e2e.sh +++ b/hack/e2e.sh @@ -369,52 +369,33 @@ EOF nodes: - role: control-plane EOF - # check $KIND_ETCD_DATADIR - if [[ "$KIND_ETCD_DATADIR" != "none" ]]; then - # check $KIND_DATA_HOSTPATH + if [[ "$KIND_DATA_HOSTPATH" != "none" || "$KIND_ETCD_DATADIR" != "none" ]]; then + cat <> $tmpfile + extraMounts: +EOF if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then if [ ! -d "$KIND_DATA_HOSTPATH" ]; then echo "error: '$KIND_DATA_HOSTPATH' is not a directory" exit 1 fi - if [ ! -d "$KIND_ETCD_DATADIR" ]; then - echo "error: '$KIND_ETCD_DATADIR' is not a directory" - exit 1 - fi local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" test -d $hostWorkerPath || mkdir $hostWorkerPath - # set custom KIND_DATA_HOSTPATH and KIND_ETCD_DATADIR cat <> $tmpfile - extraMounts: - containerPath: /mnt/disks/ hostPath: "$hostWorkerPath" propagation: HostToContainer - - containerPath: /var/lib/etcd - hostPath: "$KIND_ETCD_DATADIR" -EOF - else - # set custom KIND_ETCD_DATADIR - cat <> $tmpfile - extraMounts: - - containerPath: /var/lib/etcd - hostPath: "$KIND_ETCD_DATADIR" EOF fi - else - if [[ "$KIND_DATA_HOSTPATH" != "none" ]]; then - if [ ! -d "$KIND_DATA_HOSTPATH" ]; then - echo "error: '$KIND_DATA_HOSTPATH' is not a directory" + if [[ "$KIND_ETCD_DATADIR" != "none" ]]; then + if [ ! -d "$KIND_ETCD_DATADIR" ]; then + echo "error: '$KIND_ETCD_DATADIR' is not a directory" exit 1 fi - local hostWorkerPath="${KIND_DATA_HOSTPATH}/control-plane" - test -d $hostWorkerPath || mkdir $hostWorkerPath - # set custom KIND_DATA_HOSTPATH cat <> $tmpfile - extraMounts: - - containerPath: /mnt/disks/ - hostPath: "$hostWorkerPath" - propagation: HostToContainer + - containerPath: /var/lib/etcd + hostPath: "$KIND_ETCD_DATADIR" EOF + fi fi # workers for ((i = 1; i <= $KUBE_WORKERS; i++)) {