diff --git a/docker-update-message.txt b/docker-update-message.txt new file mode 100644 index 0000000..5803485 --- /dev/null +++ b/docker-update-message.txt @@ -0,0 +1,28 @@ + *** WARNING *** + +The docker service has not been restarted. + +In the migration from docker<1.10.0 to docker>=1.10.0, the Docker image format +has changed to be completely content-addressible. This results in several positive +improvements to image operations (better caching during builds mainly). However, +the migration operation may take several hours if you have a lot of large images +on a Docker host. In order to ensure that you have minimum downtime, the docker +service has not been restarted as it will trigger this migration. You may either +restart this service at a time of your choosing or manually run the separate +migration tool (which will not cause downtime for your Docker daemon). + +You can run the migration with this command, which will exit after the migration +has been completed: + +$ %{_libexecdir}/docker-image-migrator/do-image-migration-v1to2.sh + +Because the migrator requires information about the storage driver used by Docker, +the migration script will source %{_sysconfdir}/sysconfig/docker and use \$DOCKER_OPTS as +arguments to the migrator. If this automated migration fails, it will be re-attempted +with every known storage driver. In addition, the script accepts arguments which +will simiarly be appended to the set of arguments (after \$DOCKER_OPTS) to the +migrator. + +Restarting docker without running this separate migration tool, WILL CAUSE DOWNTIME, +BECAUSE DOCKER WILL RUN THE MIGRATION ON FIRST START AND YOU WILL BE UNABLE TO START +ANY CONTAINERS OR USE ANY DOCKER COMMANDS (EVEN CONTAINERS WITH RESTART POLICIES ACTIVE): diff --git a/docker.changes b/docker.changes index e39e27b..1caf2e9 100644 --- a/docker.changes +++ b/docker.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jul 25 05:34:50 UTC 2016 - sflees@suse.de + +- Don't exit mid install, add the ability to not restart the docker + service during certain updates with long migration phases + bsc#980555 + ------------------------------------------------------------------- Tue Jul 19 17:03:32 UTC 2016 - jmassaguerpla@suse.com diff --git a/docker.spec b/docker.spec index 46de566..dfb6a30 100644 --- a/docker.spec +++ b/docker.spec @@ -17,13 +17,19 @@ # nodebuginfo -%define docker_store %{_localstatedir}/lib/docker +%global docker_store %{_localstatedir}/lib/docker +%global docker_migration_testfile %{docker_store}/.suse-image-migration-v1to2-complete +%global docker_migration_warnfile %{docker_store}/docker-update-message.txt %define docker_graph %{docker_store}/graph -%define docker_migration_testfile %{docker_store}/.suse-image-migration-v1to2-complete %define git_version 9e83765 %define go_arches %ix86 x86_64 aarch64 %define version_unconverted 1.11.2 %define __arch_install_post export NO_BRP_STRIP_DEBUG=true +# When upgrading to a new version requires the service not to be restarted +# Due to a long migration process update last_migration_version to the new version +# that will first perform the migration, last time this was needed was version +# 1.10.1 +%global last_migration_version 1.10.1 Name: docker Version: 1.11.2 Release: 0 @@ -38,6 +44,7 @@ Source4: sysconfig.docker Source6: docker-rpmlintrc Source7: README_SUSE.md Source8: docker-audit.rules +Source9: docker-update-message.txt # Required to overcome some limitations of gcc-go: https://groups.google.com/forum/#!msg/golang-nuts/SlGCPYkjxo4/4DjcjXRCqAkJ Patch101: gcc-go-patches.patch Patch102: netlink_gcc_go.patch @@ -233,80 +240,42 @@ install -d %{buildroot}%{_mandir}/man5 install -p -m 644 man/man5/Dockerfile.5 %{buildroot}%{_mandir}/man5 %endif +install -D -m 0644 %{SOURCE9} %{buildroot}%{docker_migration_warnfile} + %fdupes %{buildroot} %pre -# We're currently inside rpmlint, which will cause us to fail the tests if it -# happens that the Docker install in the builder requires a migration. -if [[ -z "$BUILD_ROOT" ]] -then - # In order to make sure we don't print a scary warning when we shouldn't we - # need to test these things (in this order): - # 1. Check that %{_localstatedir}/lib/docker actually exists (docker daemon has run). - # 2. Check that the migrator has *not* finished. - # 3. Check that %{_localstatedir}/lib/docker/graph exists (this is a <=1.9.1 thing, but - # will stick around if it has been migrated -- which is why we need the - # MIGRATION_TESTFILE check). - # 4. Check that there are images in the graph/ directory. - if [[ -d "%{docker_store}" && ( ! -f "%{docker_migration_testfile}" ) && -d "%{docker_store}" && -n "$(find "%{docker_store}" -maxdepth 1 -type d 2>/dev/null | grep -Ev '_tmp|^%{docker_store}$')" ]] - then +# In order to make sure we don't print a scary warning when we shouldn't we +# need to test these things (in this order): +# 1. Check that %{_localstatedir}/lib/docker actually exists (docker daemon has run). +# 2. Check that the migrator has *not* finished. +# 3. Check that %{_localstatedir}/lib/docker/graph exists (this is a <=1.9.1 thing, but +# will stick around if it has been migrated -- which is why we need the +# MIGRATION_TESTFILE check). +# 4. Check that there are images in the graph/ directory. +if [[ -d "%{docker_store}" && -n "$(find "%{docker_store}" -maxdepth 1 -type d 2>/dev/null | grep -Ev '_tmp|^%{docker_store}$')" ]]; then + # Check if currently installed version of docker is old enough to need migration. + CURRENT_DOCKER_VERSION=$(docker -v | sed 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/') + # This variable will contain the current docker version if migration is needed otherwise it will contain the upgrade point. + # Next time the docker package needs to be upgraded without restarting the service increase the 1.10.1 to the new version. + NEED_UPGRADE_VERSION=$(echo -e "$CURRENT_DOCKER_VERSION\n%{last_migration_version}" | sort -V | head -1) - if [ -n "$DOCKER_FORCE_INSTALL" ] - then - echo >&2 "*** IGNORING DOWNTIME WARNING! FORCING INSTALLATION. ***" - else - -cat >&2 <=1.10.0, the Docker image format -has changed to be completely content-addressible. This results in several positive -improvements to image operations (better caching during builds mainly). However, -the migration operation may take several hours if you have a lot of large images -on a Docker host. In order to ensure that you have minimum downtime, this update -of Docker will not complete successfully, and you will have the opportunity to -run a separate migration tool (which will not cause downtime for your Docker -daemon). - -In order to run this migration tool, please install the 'docker-image-migrator' -package. You can run the migration with this command, which will exit after the -migration has been completed: - -$ %{_libexecdir}/docker-image-migrator/do-image-migration-v1to2.sh - -Because the migrator requires information about the storage driver used by Docker, -the migration script will source %{_sysconfdir}/sysconfig/docker and use \$DOCKER_OPTS as -arguments to the migrator. If this automated migration fails, it will be re-attempted -with every known storage driver. In addition, the script accepts arguments which -will simiarly be appended to the set of arguments (after \$DOCKER_OPTS) to the -migrator. - -However, if you prefer to not run this separate migration tool, you can force this -update using the following command. THIS WILL CAUSE DOWNTIME, BECAUSE DOCKER WILL -RUN THE MIGRATION ON FIRST START AND YOU WILL BE UNABLE TO START ANY CONTAINERS -OR USE ANY DOCKER COMMANDS (EVEN CONTAINERS WITH RESTART POLICIES ACTIVE): - -$ DOCKER_FORCE_INSTALL=1 sudo -E zypper up docker -EOF - - # Fail the update. - exit 1 - fi - fi - - # In order to make sure that we don't accidentally cause problems with an - # upgrade to docker>=1.10.2, we'll touch the same file we tested in (2). - # -m701 is *not* a typo, it is necessary for certain syscalls with remapped - # root. - [[ -d "%{docker_store}" ]] || install -d -m701 %{docker_store} || : - touch %{docker_migration_testfile} + if [[ $CURRENT_DOCKER_VERSION == $NEED_UPGRADE_VERSION ]]; then + touch %{docker_migration_testfile} + fi fi getent group docker >/dev/null || groupadd -r docker %service_add_pre %{name}.service %{name}.socket %post +if [ -e %{docker_migration_testfile} ]; then + cp %{docker_migration_warnfile} /var/adm/update-messages/docker +else + if [ -e %{docker_migration_warnfile} ]; then + rm %{docker_migration_warnfile} + fi +fi %service_add_post %{name}.service %{name}.socket %{fillup_only -n docker} @@ -314,6 +283,10 @@ getent group docker >/dev/null || groupadd -r docker %service_del_preun %{name}.service %{name}.socket %postun +if [ -e %{docker_migration_testfile} ]; then + rm %{docker_migration_testfile} + export DISABLE_RESTART_ON_UPDATE=yes +fi %service_del_postun %{name}.service %{name}.socket %files @@ -327,6 +300,7 @@ getent group docker >/dev/null || groupadd -r docker %config %{_sysconfdir}/audit/rules.d/%{name}.rules %{_udevrulesdir}/80-%{name}.rules %{_localstatedir}/adm/fillup-templates/sysconfig.docker +%{_localstatedir}/lib/docker/ %ifarch %{go_arches} %{_mandir}/man1/docker-*.1%{ext_man} %{_mandir}/man1/docker.1%{ext_man}