mirror of
https://github.com/rancher/os.git
synced 2025-06-29 16:26:50 +00:00
Merge pull request #987 from ibuildthecloud/foo
/media and /mnt mounted as shared for console
This commit is contained in:
commit
af52052758
@ -94,6 +94,7 @@ type RancherConfig struct {
|
|||||||
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
||||||
Debug bool `yaml:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
RmUsr bool `yaml:"rm_usr,omitempty"`
|
RmUsr bool `yaml:"rm_usr,omitempty"`
|
||||||
|
NoSharedRoot bool `yaml:"no_sharedroot,omitempty"`
|
||||||
Log bool `yaml:"log,omitempty"`
|
Log bool `yaml:"log,omitempty"`
|
||||||
ForceConsoleRebuild bool `yaml:"force_console_rebuild,omitempty"`
|
ForceConsoleRebuild bool `yaml:"force_console_rebuild,omitempty"`
|
||||||
Disable []string `yaml:"disable,omitempty"`
|
Disable []string `yaml:"disable,omitempty"`
|
||||||
|
@ -19,4 +19,10 @@ for i in /opt/bin /usr/local/bin; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
mount --make-shared /
|
||||||
|
|
||||||
|
if [ "$(grep '/var/lib/docker /var/lib/docker ' /proc/self/mountinfo | awk '{print $9}')" = "rootfs" ]; then
|
||||||
|
export DOCKER_RAMDISK=1
|
||||||
|
fi
|
||||||
|
|
||||||
exec /usr/bin/dockerlaunch $DOCKER_BIN "$@" $DOCKER_OPTS >>/var/log/docker.log 2>&1
|
exec /usr/bin/dockerlaunch $DOCKER_BIN "$@" $DOCKER_OPTS >>/var/log/docker.log 2>&1
|
||||||
|
24
init/init.go
24
init/init.go
@ -11,6 +11,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/docker/docker/pkg/mount"
|
||||||
"github.com/rancher/docker-from-scratch"
|
"github.com/rancher/docker-from-scratch"
|
||||||
"github.com/rancher/os/config"
|
"github.com/rancher/os/config"
|
||||||
"github.com/rancher/os/util"
|
"github.com/rancher/os/util"
|
||||||
@ -179,6 +180,28 @@ func isInitrd() bool {
|
|||||||
return int64(stat.Type) == TMPFS_MAGIC || int64(stat.Type) == RAMFS_MAGIC
|
return int64(stat.Type) == TMPFS_MAGIC || int64(stat.Type) == RAMFS_MAGIC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setupSharedRoot(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
|
if !c.NoSharedRoot {
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if isInitrd() {
|
||||||
|
for _, i := range []string{"/mnt", "/media"} {
|
||||||
|
if err := os.Mkdir(i, 0755); err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
if err := mount.Mount("tmpfs", i, "tmpfs", "rw"); err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
if err := mount.MakeRShared(i); err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
return c, mount.MakeShared("/")
|
||||||
|
}
|
||||||
|
|
||||||
func RunInit() error {
|
func RunInit() error {
|
||||||
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
|
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
|
||||||
if isInitrd() {
|
if isInitrd() {
|
||||||
@ -218,6 +241,7 @@ func RunInit() error {
|
|||||||
return c, dockerlaunch.PrepareFs(&mountConfig)
|
return c, dockerlaunch.PrepareFs(&mountConfig)
|
||||||
},
|
},
|
||||||
initializeSelinux,
|
initializeSelinux,
|
||||||
|
setupSharedRoot,
|
||||||
sysInit,
|
sysInit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +171,8 @@ rancher:
|
|||||||
- all-volumes
|
- all-volumes
|
||||||
volumes:
|
volumes:
|
||||||
- /usr/bin/iptables:/sbin/iptables:ro
|
- /usr/bin/iptables:/sbin/iptables:ro
|
||||||
|
- /media:/media:shared
|
||||||
|
- /mnt:/mnt:shared
|
||||||
container-data-volumes:
|
container-data-volumes:
|
||||||
image: {{.OS_REPO}}/os-state:{{.VERSION}}{{.SUFFIX}}
|
image: {{.OS_REPO}}/os-state:{{.VERSION}}{{.SUFFIX}}
|
||||||
labels:
|
labels:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/..
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/..
|
||||||
rm -rf build dist bin images/*/build
|
rm -rf build dist bin images/*/build
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# help: For development, creates iso, kernel, initrd gzip compressed
|
# help: For development, creates iso, kernel, initrd gzip compressed
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
mkdir -p bin dist build/initrd
|
mkdir -p bin dist build/initrd
|
||||||
if [ -e ./scripts/$1 ]; then
|
if [ -e ./scripts/$1 ]; then
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)/../build/initrd
|
cd $(dirname $0)/../build/initrd
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
source $(dirname $0)/version
|
source $(dirname $0)/version
|
||||||
export REPO_VERSION=$VERSION
|
export REPO_VERSION=$VERSION
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
||||||
DIRTY="-dirty"
|
DIRTY="-dirty"
|
||||||
fi
|
fi
|
||||||
|
21
tests/integration/rostest/test_15_shared_mount.py
Normal file
21
tests/integration/rostest/test_15_shared_mount.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import pytest
|
||||||
|
import rostest.util as u
|
||||||
|
from rostest.util import SSH
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def qemu(request):
|
||||||
|
q = u.run_qemu(request)
|
||||||
|
u.flush_out(q.stdout)
|
||||||
|
return q
|
||||||
|
|
||||||
|
|
||||||
|
def test_shared_mount(qemu):
|
||||||
|
SSH(qemu).check_call('''
|
||||||
|
set -x -e
|
||||||
|
|
||||||
|
sudo mkdir /mnt/shared
|
||||||
|
sudo touch /test
|
||||||
|
sudo system-docker run --privileged -v /mnt:/mnt:shared -v /test:/test {busybox_image} mount --bind / /mnt/shared
|
||||||
|
ls /mnt/shared | grep test
|
||||||
|
'''.format(busybox_image=u.busybox_image))
|
@ -15,6 +15,11 @@ if arch != 'amd64':
|
|||||||
suffix = '_' + arch
|
suffix = '_' + arch
|
||||||
|
|
||||||
|
|
||||||
|
busybox_image = {'amd64': 'busybox',
|
||||||
|
'arm': 'armhf/busybox',
|
||||||
|
'arm64': 'aarch64/busybox'}[arch]
|
||||||
|
|
||||||
|
|
||||||
def iter_lines(s):
|
def iter_lines(s):
|
||||||
return it.imap(str.rstrip, iter(s.readline, ''))
|
return it.imap(str.rstrip, iter(s.readline, ''))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user