From 0de08336754cbff67d320fcf5d68ad97243f96ec Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Thu, 2 Jul 2015 19:49:11 +0200 Subject: [PATCH] Add config-internal/config-external to Nova-compute containers Partially Implements: Blueprint standard-start Change-Id: Ia219015f18d788d0c01c0bffee6b475bb07291a9 --- .../nova-compute/nova-compute/Dockerfile | 2 ++ .../nova-compute/config-external.sh | 1 + .../nova-compute/config-internal.sh | 1 + .../nova-compute/nova-libvirt/Dockerfile | 2 ++ .../nova-libvirt/config-external.sh | 1 + .../nova-libvirt/config-internal.sh | 1 + .../nova-compute/nova-network/Dockerfile | 2 ++ .../nova-network/config-external.sh | 1 + .../nova-network/config-internal.sh | 1 + .../nova-compute/config-external.sh | 10 ++++++ .../nova-compute/config-internal.sh | 19 +++++++++++ .../common/nova-compute/nova-compute/start.sh | 22 +++++------- .../nova-libvirt/config-external.sh | 10 ++++++ .../nova-libvirt/config-internal.sh | 31 +++++++++++++++++ .../common/nova-compute/nova-libvirt/start.sh | 34 +++++-------------- .../nova-network/config-external.sh | 10 ++++++ .../nova-network/config-internal.sh | 8 +++++ .../common/nova-compute/nova-network/start.sh | 13 ++++--- 18 files changed, 125 insertions(+), 44 deletions(-) create mode 120000 docker/centos/binary/nova-compute/nova-compute/config-external.sh create mode 120000 docker/centos/binary/nova-compute/nova-compute/config-internal.sh create mode 120000 docker/centos/binary/nova-compute/nova-libvirt/config-external.sh create mode 120000 docker/centos/binary/nova-compute/nova-libvirt/config-internal.sh create mode 120000 docker/centos/binary/nova-compute/nova-network/config-external.sh create mode 120000 docker/centos/binary/nova-compute/nova-network/config-internal.sh create mode 100755 docker/common/nova-compute/nova-compute/config-external.sh create mode 100755 docker/common/nova-compute/nova-compute/config-internal.sh create mode 100755 docker/common/nova-compute/nova-libvirt/config-external.sh create mode 100755 docker/common/nova-compute/nova-libvirt/config-internal.sh create mode 100755 docker/common/nova-compute/nova-network/config-external.sh create mode 100755 docker/common/nova-compute/nova-network/config-internal.sh diff --git a/docker/centos/binary/nova-compute/nova-compute/Dockerfile b/docker/centos/binary/nova-compute/nova-compute/Dockerfile index d23b86e5f9..4e307a613c 100644 --- a/docker/centos/binary/nova-compute/nova-compute/Dockerfile +++ b/docker/centos/binary/nova-compute/nova-compute/Dockerfile @@ -8,6 +8,8 @@ ADD config-nova-compute.sh /opt/kolla/config-nova-compute.sh ADD ./start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + VOLUME [ "/sys/fs/cgroup" ] CMD ["/start.sh"] diff --git a/docker/centos/binary/nova-compute/nova-compute/config-external.sh b/docker/centos/binary/nova-compute/nova-compute/config-external.sh new file mode 120000 index 0000000000..46de4bf333 --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-compute/config-external.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-compute/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/nova-compute/nova-compute/config-internal.sh b/docker/centos/binary/nova-compute/nova-compute/config-internal.sh new file mode 120000 index 0000000000..58337d966a --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-compute/config-internal.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-compute/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/nova-compute/nova-libvirt/Dockerfile b/docker/centos/binary/nova-compute/nova-libvirt/Dockerfile index 9809406152..1dcf9156bd 100644 --- a/docker/centos/binary/nova-compute/nova-libvirt/Dockerfile +++ b/docker/centos/binary/nova-compute/nova-libvirt/Dockerfile @@ -13,4 +13,6 @@ VOLUME [ "/sys/fs/cgroup" ] ADD ./start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/nova-compute/nova-libvirt/config-external.sh b/docker/centos/binary/nova-compute/nova-libvirt/config-external.sh new file mode 120000 index 0000000000..22275236bb --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-libvirt/config-external.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-libvirt/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/nova-compute/nova-libvirt/config-internal.sh b/docker/centos/binary/nova-compute/nova-libvirt/config-internal.sh new file mode 120000 index 0000000000..c20242db76 --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-libvirt/config-internal.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-libvirt/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/nova-compute/nova-network/Dockerfile b/docker/centos/binary/nova-compute/nova-network/Dockerfile index 2434dbdf02..061ab1f9eb 100644 --- a/docker/centos/binary/nova-compute/nova-network/Dockerfile +++ b/docker/centos/binary/nova-compute/nova-network/Dockerfile @@ -7,4 +7,6 @@ RUN yum -y install openstack-nova-network \ ADD config-nova-network.sh /opt/kolla/config-nova-network.sh ADD ./start.sh /start.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/nova-compute/nova-network/config-external.sh b/docker/centos/binary/nova-compute/nova-network/config-external.sh new file mode 120000 index 0000000000..1257cd8984 --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-network/config-external.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-network/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/nova-compute/nova-network/config-internal.sh b/docker/centos/binary/nova-compute/nova-network/config-internal.sh new file mode 120000 index 0000000000..3b64fcabcb --- /dev/null +++ b/docker/centos/binary/nova-compute/nova-network/config-internal.sh @@ -0,0 +1 @@ +../../../../common/nova-compute/nova-network/config-internal.sh \ No newline at end of file diff --git a/docker/common/nova-compute/nova-compute/config-external.sh b/docker/common/nova-compute/nova-compute/config-external.sh new file mode 100755 index 0000000000..e844bf50c2 --- /dev/null +++ b/docker/common/nova-compute/nova-compute/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/nova-compute/nova.conf" +TARGET="/etc/nova/nova.conf" +OWNER="nova" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/nova-compute/nova-compute/config-internal.sh b/docker/common/nova-compute/nova-compute/config-internal.sh new file mode 100755 index 0000000000..ac7f781f4d --- /dev/null +++ b/docker/common/nova-compute/nova-compute/config-internal.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +. /opt/kolla/config-nova-compute.sh + +sleep 6 + +# https://bugs.launchpad.net/kolla/+bug/1461635 +# Cinder requires mounting /dev in the cinder-volume, nova-compute, +# and libvirt containers. If /dev/pts/ptmx does not have proper permissions +# on the host, then libvirt will fail to boot an instance. +# This is a bug in Docker where it is not correctly mounting /dev/pts +# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 +# **Temporary fix** +chmod 666 /dev/pts/ptmx + +echo "Starting nova-compute." +exec /usr/bin/nova-compute --config-file /etc/nova/nova.conf diff --git a/docker/common/nova-compute/nova-compute/start.sh b/docker/common/nova-compute/nova-compute/start.sh index ac7f781f4d..c1ca942699 100755 --- a/docker/common/nova-compute/nova-compute/start.sh +++ b/docker/common/nova-compute/nova-compute/start.sh @@ -1,19 +1,13 @@ #!/bin/bash +set -o errexit -set -e +CMD="/usr/bin/nova-compute" +ARGS="" -. /opt/kolla/config-nova-compute.sh +# Loading common functions. +source /opt/kolla/kolla-common.sh -sleep 6 +# Config-internal script exec out of this function, it does not return here. +set_configs -# https://bugs.launchpad.net/kolla/+bug/1461635 -# Cinder requires mounting /dev in the cinder-volume, nova-compute, -# and libvirt containers. If /dev/pts/ptmx does not have proper permissions -# on the host, then libvirt will fail to boot an instance. -# This is a bug in Docker where it is not correctly mounting /dev/pts -# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 -# **Temporary fix** -chmod 666 /dev/pts/ptmx - -echo "Starting nova-compute." -exec /usr/bin/nova-compute --config-file /etc/nova/nova.conf +exec $CMD $ARGS diff --git a/docker/common/nova-compute/nova-libvirt/config-external.sh b/docker/common/nova-compute/nova-libvirt/config-external.sh new file mode 100755 index 0000000000..59567d52df --- /dev/null +++ b/docker/common/nova-compute/nova-libvirt/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="" +TARGET="" +OWNER="" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/nova-compute/nova-libvirt/config-internal.sh b/docker/common/nova-compute/nova-libvirt/config-internal.sh new file mode 100755 index 0000000000..1f2ddbed8e --- /dev/null +++ b/docker/common/nova-compute/nova-libvirt/config-internal.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [[ $(cat /proc/cpuinfo | grep vmx) ]]; then + modprobe kvm_intel +elif [[ $(cat /proc/cpuinfo | grep svm) ]]; then + modprobe kvm_amd +else + echo "WARNING: Your hardware does not support hardware virtualization -" \ + "using qemu software virtualization instead" +fi + +modprobe ip6_tables ip_tables ebtable_nat + +# If libvirt is not installed on the host permissions need to be set +# If running in qemu, we don't need to set anything as /dev/kvm won't exist +if [[ -c /dev/kvm ]]; then + chmod 660 /dev/kvm + chown root:kvm /dev/kvm +fi + +# https://bugs.launchpad.net/kolla/+bug/1461635 +# Cinder requires mounting /dev in the cinder-volume, nova-compute, +# and libvirt containers. If /dev/pts/ptmx does not have proper permissions +# on the host, then libvirt will fail to boot an instance. +# This is a bug in Docker where it is not correctly mounting /dev/pts +# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 +# **Temporary fix** +chmod 666 /dev/pts/ptmx + +echo "Starting libvirtd." +exec /usr/sbin/libvirtd diff --git a/docker/common/nova-compute/nova-libvirt/start.sh b/docker/common/nova-compute/nova-libvirt/start.sh index 1f2ddbed8e..00d7046d1c 100755 --- a/docker/common/nova-compute/nova-libvirt/start.sh +++ b/docker/common/nova-compute/nova-libvirt/start.sh @@ -1,31 +1,13 @@ #!/bin/bash +set -o errexit -if [[ $(cat /proc/cpuinfo | grep vmx) ]]; then - modprobe kvm_intel -elif [[ $(cat /proc/cpuinfo | grep svm) ]]; then - modprobe kvm_amd -else - echo "WARNING: Your hardware does not support hardware virtualization -" \ - "using qemu software virtualization instead" -fi +CMD="/usr/sbin/libvirtd" +ARGS="" -modprobe ip6_tables ip_tables ebtable_nat +# Loading common functions. +source /opt/kolla/kolla-common.sh -# If libvirt is not installed on the host permissions need to be set -# If running in qemu, we don't need to set anything as /dev/kvm won't exist -if [[ -c /dev/kvm ]]; then - chmod 660 /dev/kvm - chown root:kvm /dev/kvm -fi +# Config-internal script exec out of this function, it does not return here. +set_configs -# https://bugs.launchpad.net/kolla/+bug/1461635 -# Cinder requires mounting /dev in the cinder-volume, nova-compute, -# and libvirt containers. If /dev/pts/ptmx does not have proper permissions -# on the host, then libvirt will fail to boot an instance. -# This is a bug in Docker where it is not correctly mounting /dev/pts -# Tech Debt tracker: https://bugs.launchpad.net/kolla/+bug/1468962 -# **Temporary fix** -chmod 666 /dev/pts/ptmx - -echo "Starting libvirtd." -exec /usr/sbin/libvirtd +exec $CMD $ARGS diff --git a/docker/common/nova-compute/nova-network/config-external.sh b/docker/common/nova-compute/nova-network/config-external.sh new file mode 100755 index 0000000000..7c1d6bb377 --- /dev/null +++ b/docker/common/nova-compute/nova-network/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/nova-network/nova.conf" +TARGET="/etc/nova/nova.conf" +OWNER="nova" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/nova-compute/nova-network/config-internal.sh b/docker/common/nova-compute/nova-network/config-internal.sh new file mode 100755 index 0000000000..92381b720f --- /dev/null +++ b/docker/common/nova-compute/nova-network/config-internal.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +. /opt/kolla/config-nova-network.sh + +# Start nova-network +exec /usr/bin/nova-network --config-file /etc/nova/nova.conf diff --git a/docker/common/nova-compute/nova-network/start.sh b/docker/common/nova-compute/nova-network/start.sh index 92381b720f..b6faa82152 100755 --- a/docker/common/nova-compute/nova-network/start.sh +++ b/docker/common/nova-compute/nova-network/start.sh @@ -1,8 +1,13 @@ #!/bin/bash +set -o errexit -set -e +CMD="/usr/bin/nova-network" +ARGS="" -. /opt/kolla/config-nova-network.sh +# Loading common functions. +source /opt/kolla/kolla-common.sh -# Start nova-network -exec /usr/bin/nova-network --config-file /etc/nova/nova.conf +# Config-internal script exec out of this function, it does not return here. +set_configs + +exec $CMD $ARGS