From b559a95eb2ba4a83746898a9ce405649ca724582 Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Wed, 26 Jul 2017 13:54:36 +0200 Subject: [PATCH] Remove v2 data when upgrading to 3.1.* version --- cluster/images/etcd/migrate-if-needed.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cluster/images/etcd/migrate-if-needed.sh b/cluster/images/etcd/migrate-if-needed.sh index 04c57157a0e..33e5aafb932 100755 --- a/cluster/images/etcd/migrate-if-needed.sh +++ b/cluster/images/etcd/migrate-if-needed.sh @@ -215,6 +215,25 @@ for step in ${SUPPORTED_VERSIONS}; do CURRENT_STORAGE="etcd3" echo "${CURRENT_VERSION}/${CURRENT_STORAGE}" > "${DATA_DIRECTORY}/${VERSION_FILE}" fi + if [ "$(echo ${CURRENT_VERSION} | cut -c1-4)" = "3.1." -a "${CURRENT_VERSION}" = "${step}" -a "${CURRENT_STORAGE}" = "etcd3" ]; then + # If we are upgrading to 3.1.* release, if the cluster was migrated + # from v2 version, the v2 data may still be around. So now is the + # time to actually remove them. + echo "Remove stale v2 data" + START_VERSION="${step}" + START_STORAGE="etcd3" + ETCDCTL_CMD="${ETCDCTL:-/usr/local/bin/etcdctl-${START_VERSION}}" + if ! start_etcd; then + echo "Starting etcd ${step} in v3 mode failed" + exit 1 + fi + ${ETCDCTL_CMD} rm --recursive "/registry" + # Kill etcd and wait until this is down. + stop_etcd + echo "Successfully remove v2 data" + # Also remove backup from v2->v3 migration. + rm -rf "${BACKUP_DIR}" + fi if [ "${CURRENT_VERSION}" = "${TARGET_VERSION}" -a "${CURRENT_STORAGE}" = "${TARGET_STORAGE}" ]; then break fi