mirror of
https://github.com/rancher/os.git
synced 2025-09-04 08:14:21 +00:00
Fix image preloading
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM rancher/os-base
|
FROM rancher/os-base
|
||||||
RUN ln -sf /var/lib/rancher/docker/docker /usr/bin/docker
|
RUN ln -sf /var/lib/rancher/engine/docker /usr/bin/docker
|
||||||
COPY preload.sh /
|
COPY preload.sh /
|
||||||
CMD ["/preload.sh"]
|
CMD ["/preload.sh"]
|
||||||
|
@@ -4,6 +4,12 @@ set -e
|
|||||||
BASE=${1:-${PRELOAD_DIR}}
|
BASE=${1:-${PRELOAD_DIR}}
|
||||||
BASE=${BASE:-/mnt/preload}
|
BASE=${BASE:-/mnt/preload}
|
||||||
|
|
||||||
|
if [ "${SYSTEM_IMAGES}" = "true" ]; then
|
||||||
|
docker_bin=system-docker
|
||||||
|
else
|
||||||
|
docker_bin=docker
|
||||||
|
fi
|
||||||
|
|
||||||
should_load() {
|
should_load() {
|
||||||
file=${1}
|
file=${1}
|
||||||
if [[ ${file} =~ \.done$ ]]; then echo false
|
if [[ ${file} =~ \.done$ ]]; then echo false
|
||||||
@@ -26,7 +32,7 @@ if [ -d ${BASE} ]; then
|
|||||||
if [[ ${file} =~ \.t?gz$ ]]; then CAT="${CAT} | gunzip"; fi
|
if [[ ${file} =~ \.t?gz$ ]]; then CAT="${CAT} | gunzip"; fi
|
||||||
if [[ ${file} =~ \.t?xz$ ]]; then CAT="${CAT} | unxz"; fi
|
if [[ ${file} =~ \.t?xz$ ]]; then CAT="${CAT} | unxz"; fi
|
||||||
wait-for-docker
|
wait-for-docker
|
||||||
CAT="${CAT} | docker load"
|
CAT="${CAT} | ${docker_bin} load"
|
||||||
echo loading from ${path}
|
echo loading from ${path}
|
||||||
eval ${CAT} || :
|
eval ${CAT} || :
|
||||||
touch ${path}.done || :
|
touch ${path}.done || :
|
||||||
|
@@ -253,6 +253,8 @@ rancher:
|
|||||||
- system-volumes
|
- system-volumes
|
||||||
preload-system-images:
|
preload-system-images:
|
||||||
image: {{.OS_REPO}}/os-preload:{{.VERSION}}{{.SUFFIX}}
|
image: {{.OS_REPO}}/os-preload:{{.VERSION}}{{.SUFFIX}}
|
||||||
|
environment:
|
||||||
|
- SYSTEM_IMAGES=true
|
||||||
labels:
|
labels:
|
||||||
io.rancher.os.detach: "false"
|
io.rancher.os.detach: "false"
|
||||||
io.rancher.os.scope: system
|
io.rancher.os.scope: system
|
||||||
|
23
tests/preload_test.go
Normal file
23
tests/preload_test.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *QemuSuite) TestPreload(c *C) {
|
||||||
|
err := s.RunQemu()
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
s.CheckCall(c, `
|
||||||
|
docker pull busybox
|
||||||
|
sudo docker save -o /var/lib/rancher/preload/system-docker/busybox.tar busybox
|
||||||
|
sudo system-docker pull alpine
|
||||||
|
sudo system-docker save -o /var/lib/rancher/preload/docker/alpine.tar alpine`)
|
||||||
|
|
||||||
|
s.Reboot(c)
|
||||||
|
|
||||||
|
s.CheckCall(c, `
|
||||||
|
sleep 5
|
||||||
|
sudo system-docker images | grep busybox
|
||||||
|
docker images | grep alpine`)
|
||||||
|
}
|
Reference in New Issue
Block a user