mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	Correctly support custom etcd migration
This commit is contained in:
		| @@ -57,6 +57,12 @@ if [ "${TARGET_STORAGE}" != "etcd2" -a "${TARGET_STORAGE}" != "etcd3" ]; then | |||||||
|   exit 1 |   exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | # Correctly support upgrade and rollback to non-default version. | ||||||
|  | if [ "${DO_NOT_MOVE_BINARIES:-}" != "true" ]; then | ||||||
|  |   cp "/usr/local/bin/etcd-${TARGET_VERSION}" "/usr/local/bin/etcd" | ||||||
|  |   cp "/usr/local/bin/etcdctl-${TARGET_VERSION}" "/usr/local/bin/etcdctl" | ||||||
|  | fi | ||||||
|  |  | ||||||
| # NOTE: SUPPORTED_VERSION has to match release binaries present in the | # NOTE: SUPPORTED_VERSION has to match release binaries present in the | ||||||
| # etcd image (to make this script work correctly). | # etcd image (to make this script work correctly). | ||||||
| # We cannot use array since sh doesn't support it. | # We cannot use array since sh doesn't support it. | ||||||
| @@ -156,9 +162,9 @@ for step in ${SUPPORTED_VERSIONS}; do | |||||||
|     fi |     fi | ||||||
|     # Kill etcd and wait until this is down. |     # Kill etcd and wait until this is down. | ||||||
|     stop_etcd |     stop_etcd | ||||||
|   fi |  | ||||||
|     CURRENT_VERSION=${step} |     CURRENT_VERSION=${step} | ||||||
|     echo "${CURRENT_VERSION}/${CURRENT_STORAGE}" > "${DATA_DIRECTORY}/${VERSION_FILE}" |     echo "${CURRENT_VERSION}/${CURRENT_STORAGE}" > "${DATA_DIRECTORY}/${VERSION_FILE}" | ||||||
|  |   fi | ||||||
|   if [ "$(echo ${CURRENT_VERSION} | cut -c1-2)" = "3." -a "${CURRENT_STORAGE}" = "etcd2" -a "${TARGET_STORAGE}" = "etcd3" ]; then |   if [ "$(echo ${CURRENT_VERSION} | cut -c1-2)" = "3." -a "${CURRENT_STORAGE}" = "etcd2" -a "${TARGET_STORAGE}" = "etcd3" ]; then | ||||||
|     # If it is the first 3.x release in the list and we are migrating |     # If it is the first 3.x release in the list and we are migrating | ||||||
|     # also from 'etcd2' to 'etcd3', do the migration now. |     # also from 'etcd2' to 'etcd3', do the migration now. | ||||||
|   | |||||||
| @@ -37,7 +37,7 @@ | |||||||
|     "command": [ |     "command": [ | ||||||
|               "/bin/sh", |               "/bin/sh", | ||||||
|               "-c", |               "-c", | ||||||
|               "if [ -e /usr/local/bin/migrate-if-needed.sh ]; then /usr/local/bin/migrate-if-needed.sh; fi; /usr/local/bin/etcd --name etcd-{{ hostname }} --listen-peer-urls http://{{ hostname }}:{{ server_port }} --initial-advertise-peer-urls http://{{ hostname }}:{{ server_port }} --advertise-client-urls http://127.0.0.1:{{ port }} --listen-client-urls http://127.0.0.1:{{ port }} --data-dir /var/etcd/data{{ suffix }} --initial-cluster-state {{ cluster_state }} --initial-cluster {{ etcd_cluster }} 1>>/var/log/etcd{{ suffix }}.log 2>&1" |               "if [ -e /usr/local/bin/migrate-if-needed.sh ]; then /usr/local/bin/migrate-if-needed.sh 1>>/var/log/etcd{{ suffix }}.log 2>&1; fi; /usr/local/bin/etcd --name etcd-{{ hostname }} --listen-peer-urls http://{{ hostname }}:{{ server_port }} --initial-advertise-peer-urls http://{{ hostname }}:{{ server_port }} --advertise-client-urls http://127.0.0.1:{{ port }} --listen-client-urls http://127.0.0.1:{{ port }} --data-dir /var/etcd/data{{ suffix }} --initial-cluster-state {{ cluster_state }} --initial-cluster {{ etcd_cluster }} 1>>/var/log/etcd{{ suffix }}.log 2>&1" | ||||||
|             ], |             ], | ||||||
|     "env": [ |     "env": [ | ||||||
|       { "name": "TARGET_STORAGE", |       { "name": "TARGET_STORAGE", | ||||||
|   | |||||||
| @@ -165,6 +165,7 @@ TARGET_STORAGE="etcd3" \ | |||||||
|   ETCD=$(which etcd) \ |   ETCD=$(which etcd) \ | ||||||
|   ETCDCTL=$(which etcdctl) \ |   ETCDCTL=$(which etcdctl) \ | ||||||
|   ATTACHLEASE="${KUBE_OUTPUT_HOSTBIN}/attachlease" \ |   ATTACHLEASE="${KUBE_OUTPUT_HOSTBIN}/attachlease" \ | ||||||
|  |   DO_NOT_MOVE_BINARIES="true" \ | ||||||
|   ${KUBE_ROOT}/cluster/images/etcd/migrate-if-needed.sh |   ${KUBE_ROOT}/cluster/images/etcd/migrate-if-needed.sh | ||||||
| kube::etcd::start | kube::etcd::start | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user