Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
44e66a97
Commit
44e66a97
authored
Oct 25, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migration script
parent
cfbb0eb2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
migrate-if-needed.sh
cluster/images/etcd/migrate-if-needed.sh
+23
-11
test-update-storage-objects.sh
hack/test-update-storage-objects.sh
+1
-1
No files found.
cluster/images/etcd/migrate-if-needed.sh
View file @
44e66a97
#!/bin/
ba
sh
#!/bin/sh
# Copyright 2016 The Kubernetes Authors.
# Copyright 2016 The Kubernetes Authors.
#
#
...
@@ -59,7 +59,9 @@ fi
...
@@ -59,7 +59,9 @@ 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).
SUPPORTED_VERSIONS
=(
"2.2.1"
"2.3.7"
"3.0.12"
)
# We cannot use array since sh doesn't support it.
SUPPORTED_VERSIONS_STRING
=
"2.2.1 2.3.7 3.0.12"
SUPPORTED_VERSIONS
=
$(
echo
"
${
SUPPORTED_VERSIONS_STRING
}
"
|
tr
" "
"
\n
"
)
VERSION_FILE
=
"version.txt"
VERSION_FILE
=
"version.txt"
CURRENT_STORAGE
=
"etcd2"
CURRENT_STORAGE
=
"etcd2"
...
@@ -82,7 +84,7 @@ fi
...
@@ -82,7 +84,7 @@ fi
if
[
-z
"
$(
ls
-A
${
DATA_DIRECTORY
})
"
]
;
then
if
[
-z
"
$(
ls
-A
${
DATA_DIRECTORY
})
"
]
;
then
echo
"
${
DATA_DIRECTORY
}
is empty - skipping migration"
echo
"
${
DATA_DIRECTORY
}
is empty - skipping migration"
echo
"
${
TARGET_VERSION
}
/
${
TARGET_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
echo
"
${
TARGET_VERSION
}
/
${
TARGET_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
exit
0
exit
0
fi
fi
# Starts 'etcd' version ${START_VERSION} and writes to it:
# Starts 'etcd' version ${START_VERSION} and writes to it:
...
@@ -96,7 +98,8 @@ start_etcd() {
...
@@ -96,7 +98,8 @@ start_etcd() {
ETCD_PEER_PORT
=
18630
ETCD_PEER_PORT
=
18630
local
ETCD_CMD
=
"
${
ETCD
:-
/usr/local/bin/etcd-
${
START_VERSION
}}
"
local
ETCD_CMD
=
"
${
ETCD
:-
/usr/local/bin/etcd-
${
START_VERSION
}}
"
local
ETCDCTL_CMD
=
"
${
ETCDCTL
:-
/usr/local/bin/etcdctl-
${
START_VERSION
}}
"
local
ETCDCTL_CMD
=
"
${
ETCDCTL
:-
/usr/local/bin/etcdctl-
${
START_VERSION
}}
"
if
[
"
${
START_VERSION
:0:2
}
"
==
"2."
]
;
then
local
API_VERSION
=
"
$(
echo
${
START_STORAGE
}
|
cut
-c5-5
)
"
if
[
"
${
API_VERSION
}
"
=
"2"
]
;
then
ETCDCTL_CMD
=
"
${
ETCDCTL_CMD
}
--endpoint=http://127.0.0.1:
${
ETCD_PORT
}
set"
ETCDCTL_CMD
=
"
${
ETCDCTL_CMD
}
--endpoint=http://127.0.0.1:
${
ETCD_PORT
}
set"
else
else
ETCDCTL_CMD
=
"
${
ETCDCTL_CMD
}
--endpoints=http://127.0.0.1:
${
ETCD_PORT
}
put"
ETCDCTL_CMD
=
"
${
ETCDCTL_CMD
}
--endpoints=http://127.0.0.1:
${
ETCD_PORT
}
put"
...
@@ -108,7 +111,6 @@ start_etcd() {
...
@@ -108,7 +111,6 @@ start_etcd() {
--initial-advertise-peer-urls
http://127.0.0.1:
${
ETCD_PEER_PORT
}
\
--initial-advertise-peer-urls
http://127.0.0.1:
${
ETCD_PEER_PORT
}
\
1>>/dev/null 2>&1 &
1>>/dev/null 2>&1 &
ETCD_PID
=
$!
ETCD_PID
=
$!
local
API_VERSION
=
"
${
START_STORAGE
:4:4
}
"
# Wait until we can write to etcd.
# Wait until we can write to etcd.
for
i
in
$(
seq
240
)
;
do
for
i
in
$(
seq
240
)
;
do
ETCDCTL_API
=
"
${
API_VERSION
}
"
${
ETCDCTL_CMD
}
'etcd_version'
${
START_VERSION
}
ETCDCTL_API
=
"
${
API_VERSION
}
"
${
ETCDCTL_CMD
}
'etcd_version'
${
START_VERSION
}
...
@@ -132,8 +134,18 @@ ATTACHLEASE="${ATTACHLEASE:-/usr/local/bin/attachlease}"
...
@@ -132,8 +134,18 @@ ATTACHLEASE="${ATTACHLEASE:-/usr/local/bin/attachlease}"
ROLLBACK
=
"
${
ROLLBACK
:-
/usr/local/bin/rollback
}
"
ROLLBACK
=
"
${
ROLLBACK
:-
/usr/local/bin/rollback
}
"
# Do the roll-forward migration if needed.
# Do the roll-forward migration if needed.
for
step
in
"
${
SUPPORTED_VERSIONS
[@]
}
"
;
do
# The migration goes as following:
if
[
"
${
step
}
"
==
"
${
CURRENT_VERSION
}
"
-a
"
${
CURRENT_VERSION
}
"
!=
"
${
TARGET_VERSION
}
"
]
;
then
# 1. for all versions starting one after the current version of etcd
# we do "start, wait until healthy and stop etcd". This is the
# procedure that etcd documentation suggests for upgrading binaries.
# 2. For the first 3.0.x version that we encounter, if we are still in
# v2 API, we do upgrade to v3 API using the "etcdct migrate" and
# attachlease commands.
SKIP_STEP
=
true
for
step
in
${
SUPPORTED_VERSIONS
}
;
do
if
[
"
${
step
}
"
=
"
${
CURRENT_VERSION
}
"
]
;
then
SKIP_STEP
=
false
elif
[
"
${
SKIP_STEP
}
"
!=
"true"
]
;
then
# Do the migration step, by just starting etcd in this version.
# Do the migration step, by just starting etcd in this version.
START_VERSION
=
"
${
step
}
"
START_VERSION
=
"
${
step
}
"
START_STORAGE
=
"
${
CURRENT_STORAGE
}
"
START_STORAGE
=
"
${
CURRENT_STORAGE
}
"
...
@@ -147,7 +159,7 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
...
@@ -147,7 +159,7 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
fi
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
}
"
if
[
"
$
{
CURRENT_VERSION
:0: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.
echo
"Performing etcd2 -> etcd3 migration"
echo
"Performing etcd2 -> etcd3 migration"
...
@@ -173,7 +185,7 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
...
@@ -173,7 +185,7 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
CURRENT_STORAGE
=
"etcd3"
CURRENT_STORAGE
=
"etcd3"
echo
"
${
CURRENT_VERSION
}
/
${
CURRENT_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
echo
"
${
CURRENT_VERSION
}
/
${
CURRENT_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
fi
fi
if
[
"
${
CURRENT_VERSION
}
"
=
=
"
${
TARGET_VERSION
}
"
-a
"
${
CURRENT_STORAGE
}
"
=
=
"
${
TARGET_STORAGE
}
"
]
;
then
if
[
"
${
CURRENT_VERSION
}
"
=
"
${
TARGET_VERSION
}
"
-a
"
${
CURRENT_STORAGE
}
"
=
"
${
TARGET_STORAGE
}
"
]
;
then
break
break
fi
fi
done
done
...
@@ -181,8 +193,8 @@ done
...
@@ -181,8 +193,8 @@ done
# Do the rollback of needed.
# Do the rollback of needed.
# NOTE: Rollback is only supported from "3.0.x" version in 'etcd3' mode to
# NOTE: Rollback is only supported from "3.0.x" version in 'etcd3' mode to
# "2.3.7" version in 'etcd2' mode.
# "2.3.7" version in 'etcd2' mode.
if
[
"
${
CURRENT_STORAGE
}
"
=
=
"etcd3"
-a
"
${
TARGET_STORAGE
}
"
=
=
"etcd2"
]
;
then
if
[
"
${
CURRENT_STORAGE
}
"
=
"etcd3"
-a
"
${
TARGET_STORAGE
}
"
=
"etcd2"
]
;
then
if
[
"
$
{
CURRENT_VERSION
:0:4
}
"
!=
"3.0."
-o
"
${
TARGET_VERSION
}
"
!=
"2.3.7"
]
;
then
if
[
"
$
(
echo
${
CURRENT_VERSION
}
|
cut
-c1-4
)
"
!=
"3.0."
-o
"
${
TARGET_VERSION
}
"
!=
"2.3.7"
]
;
then
echo
"etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.3.7"
echo
"etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.3.7"
return
0
return
0
fi
fi
...
...
hack/test-update-storage-objects.sh
View file @
44e66a97
...
@@ -160,7 +160,7 @@ killApiServer
...
@@ -160,7 +160,7 @@ killApiServer
kube::etcd::stop
kube::etcd::stop
TARGET_STORAGE
=
"etcd3"
\
TARGET_STORAGE
=
"etcd3"
\
TARGET_VERSION
=
"3.0.1
0
"
\
TARGET_VERSION
=
"3.0.1
2
"
\
DATA_DIRECTORY
=
"
${
ETCD_DIR
}
"
\
DATA_DIRECTORY
=
"
${
ETCD_DIR
}
"
\
ETCD
=
$(
which etcd
)
\
ETCD
=
$(
which etcd
)
\
ETCDCTL
=
$(
which etcdctl
)
\
ETCDCTL
=
$(
which etcdctl
)
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment