From cb4e875ae1e1ec2e6ddf8a6b37f42283697fd50c Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 30 Sep 2015 11:23:39 +0000 Subject: Common start.sh The majority of the start.sh code is identical. This removes that duplicate code while still maintaining the ability to call code in a specific container. The start.sh is moved into /usr/local/bin/kolla_start in the container The extend_start.sh script is called by the kolla_start script at the location /usr/local/bin/kolla_extend_start . It always exists because we create a noop kolla_extend_start in the base directory. We override it with extend_start.sh in a specific image should we need to. Of note, the neutron-agents container is exempt from this new structure due to it being a fat container. Additionally, we fix the inconsistent permissions throughout. 644 for repo files and the scripts are set to 755 via a Docker RUN command to ensure someones local perm change won't break upstream containers. Change-Id: I7da8d19965463ad30ee522a71183e3f092e0d6ad Closes-Bug: #1501295 --- docker/neutron/neutron-agents/Dockerfile.j2 | 1 + docker/neutron/neutron-agents/config-sudoers.sh | 12 ++++++++++++ docker/neutron/neutron-agents/start.sh | 4 ++-- docker/neutron/neutron-base/Dockerfile.j2 | 3 ++- docker/neutron/neutron-base/config-sudoers.sh | 12 ------------ docker/neutron/neutron-base/extend_start.sh | 11 +++++++++++ docker/neutron/neutron-base/ip_wrapper.py | 4 +++- docker/neutron/neutron-linuxbridge-agent/Dockerfile.j2 | 7 ++----- docker/neutron/neutron-linuxbridge-agent/start.sh | 8 -------- docker/neutron/neutron-openvswitch-agent/Dockerfile.j2 | 7 +------ docker/neutron/neutron-openvswitch-agent/start.sh | 8 -------- docker/neutron/neutron-server/Dockerfile.j2 | 5 ++--- docker/neutron/neutron-server/extend_start.sh | 18 ++++++++++++++++++ docker/neutron/neutron-server/start.sh | 14 -------------- 14 files changed, 54 insertions(+), 60 deletions(-) create mode 100644 docker/neutron/neutron-agents/config-sudoers.sh delete mode 100644 docker/neutron/neutron-base/config-sudoers.sh create mode 100644 docker/neutron/neutron-base/extend_start.sh mode change 100755 => 100644 docker/neutron/neutron-base/ip_wrapper.py delete mode 100755 docker/neutron/neutron-linuxbridge-agent/start.sh delete mode 100755 docker/neutron/neutron-openvswitch-agent/start.sh create mode 100644 docker/neutron/neutron-server/extend_start.sh delete mode 100755 docker/neutron/neutron-server/start.sh (limited to 'docker/neutron') diff --git a/docker/neutron/neutron-agents/Dockerfile.j2 b/docker/neutron/neutron-agents/Dockerfile.j2 index 3fb1ffe30..2967222f4 100644 --- a/docker/neutron/neutron-agents/Dockerfile.j2 +++ b/docker/neutron/neutron-agents/Dockerfile.j2 @@ -31,6 +31,7 @@ COPY fwaas_driver.ini /etc/neutron/ COPY neutron-dhcp-agent/ /opt/kolla/neutron-dhcp-agent COPY neutron-l3-agent/ /opt/kolla/neutron-l3-agent COPY neutron-metadata-agent/ /opt/kolla/neutron-metadata-agent +COPY config-sudoers.sh /opt/kolla/ COPY start.sh / diff --git a/docker/neutron/neutron-agents/config-sudoers.sh b/docker/neutron/neutron-agents/config-sudoers.sh new file mode 100644 index 000000000..82cf0d624 --- /dev/null +++ b/docker/neutron/neutron-agents/config-sudoers.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Neutron uses rootwrap which requires a tty for sudo. +# Since the container is running in daemon mode, a tty +# is not present and requiretty must be commented out. +if [ ! -f /sudo-modified ]; then + chmod 0640 /etc/sudoers + sed -i '/Defaults requiretty/s/^/#/' /etc/sudoers + chmod 0440 /etc/sudoers +fi + +touch /sudo-modified diff --git a/docker/neutron/neutron-agents/start.sh b/docker/neutron/neutron-agents/start.sh index 8b5f302cf..baf3d2a8e 100755 --- a/docker/neutron/neutron-agents/start.sh +++ b/docker/neutron/neutron-agents/start.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o errexit -# Loading common functions. -source /opt/kolla/kolla-common.sh +# Processing /opt/kolla/config_files/config.json +python /opt/kolla/set_configs.py exec /usr/bin/supervisord diff --git a/docker/neutron/neutron-base/Dockerfile.j2 b/docker/neutron/neutron-base/Dockerfile.j2 index 8560d72d5..fe073d8cf 100644 --- a/docker/neutron/neutron-base/Dockerfile.j2 +++ b/docker/neutron/neutron-base/Dockerfile.j2 @@ -40,4 +40,5 @@ RUN ln -s neutron-base-source/* neutron \ {% endif %} -COPY config-sudoers.sh /opt/kolla/ +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start diff --git a/docker/neutron/neutron-base/config-sudoers.sh b/docker/neutron/neutron-base/config-sudoers.sh deleted file mode 100644 index 82cf0d624..000000000 --- a/docker/neutron/neutron-base/config-sudoers.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Neutron uses rootwrap which requires a tty for sudo. -# Since the container is running in daemon mode, a tty -# is not present and requiretty must be commented out. -if [ ! -f /sudo-modified ]; then - chmod 0640 /etc/sudoers - sed -i '/Defaults requiretty/s/^/#/' /etc/sudoers - chmod 0440 /etc/sudoers -fi - -touch /sudo-modified diff --git a/docker/neutron/neutron-base/extend_start.sh b/docker/neutron/neutron-base/extend_start.sh new file mode 100644 index 000000000..07212efce --- /dev/null +++ b/docker/neutron/neutron-base/extend_start.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Neutron uses rootwrap which requires a tty for sudo. +# Since the container is running in daemon mode, a tty +# is not present and requiretty must be commented out. +if [ ! -f /sudo-modified ]; then + chmod 0640 /etc/sudoers + sed -i '/Defaults requiretty/s/^/#/' /etc/sudoers + chmod 0440 /etc/sudoers + touch /sudo-modified +fi diff --git a/docker/neutron/neutron-base/ip_wrapper.py b/docker/neutron/neutron-base/ip_wrapper.py old mode 100755 new mode 100644 index 591fca6f4..871c615ab --- a/docker/neutron/neutron-base/ip_wrapper.py +++ b/docker/neutron/neutron-base/ip_wrapper.py @@ -19,7 +19,9 @@ # access all of the neutron network namespaces as well as all # containers that bind mount /run/netns from the host. -# This is required for "thin" neutron containers to function properly +# This is required for "thin" neutron containers to function properly. However, +# due to a missing feature/bug in Docker it is not possible to use this script +# at this time. Once Docker updates with this feature we will usre this again. import nsenter import subprocess diff --git a/docker/neutron/neutron-linuxbridge-agent/Dockerfile.j2 b/docker/neutron/neutron-linuxbridge-agent/Dockerfile.j2 index 360afc4d1..179890b46 100644 --- a/docker/neutron/neutron-linuxbridge-agent/Dockerfile.j2 +++ b/docker/neutron/neutron-linuxbridge-agent/Dockerfile.j2 @@ -15,13 +15,10 @@ RUN yum install -y \ {% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} # Install required packages -RUN yum install -y ebtables && yum clean all +RUN yum install -y ebtables \ + && yum clean all {% endif %} {% endif %} -COPY start.sh / - -CMD ["/start.sh"] - {{ include_footer }} diff --git a/docker/neutron/neutron-linuxbridge-agent/start.sh b/docker/neutron/neutron-linuxbridge-agent/start.sh deleted file mode 100755 index 6c4b09679..000000000 --- a/docker/neutron/neutron-linuxbridge-agent/start.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -o errexit - -# Loading common functions. -source /opt/kolla/kolla-common.sh -source /opt/kolla/config-sudoers.sh - -exec $CMD diff --git a/docker/neutron/neutron-openvswitch-agent/Dockerfile.j2 b/docker/neutron/neutron-openvswitch-agent/Dockerfile.j2 index b6e797b0c..5e659f5a0 100644 --- a/docker/neutron/neutron-openvswitch-agent/Dockerfile.j2 +++ b/docker/neutron/neutron-openvswitch-agent/Dockerfile.j2 @@ -15,15 +15,10 @@ RUN yum install -y \ {% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} # Install required packages -RUN yum install -y \ - openvswitch \ +RUN yum install -y openvswitch \ && yum clean all {% endif %} {% endif %} -COPY start.sh / - -CMD ["/start.sh"] - {{ include_footer }} diff --git a/docker/neutron/neutron-openvswitch-agent/start.sh b/docker/neutron/neutron-openvswitch-agent/start.sh deleted file mode 100755 index 6c4b09679..000000000 --- a/docker/neutron/neutron-openvswitch-agent/start.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -o errexit - -# Loading common functions. -source /opt/kolla/kolla-common.sh -source /opt/kolla/config-sudoers.sh - -exec $CMD diff --git a/docker/neutron/neutron-server/Dockerfile.j2 b/docker/neutron/neutron-server/Dockerfile.j2 index 12a9b2df7..5fcf47a78 100644 --- a/docker/neutron/neutron-server/Dockerfile.j2 +++ b/docker/neutron/neutron-server/Dockerfile.j2 @@ -23,8 +23,7 @@ RUN yum install -y which \ {% endif %} {% endif %} -COPY start.sh / - -CMD ["/start.sh"] +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start {{ include_footer }} diff --git a/docker/neutron/neutron-server/extend_start.sh b/docker/neutron/neutron-server/extend_start.sh new file mode 100644 index 000000000..c832d586d --- /dev/null +++ b/docker/neutron/neutron-server/extend_start.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases +# of the KOLLA_BOOTSTRAP variable being set, including empty. +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + su -s /bin/bash -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron + exit 0 +fi + +# Neutron uses rootwrap which requires a tty for sudo. +# Since the container is running in daemon mode, a tty +# is not present and requiretty must be commented out. +if [ ! -f /sudo-modified ]; then + chmod 0640 /etc/sudoers + sed -i '/Defaults requiretty/s/^/#/' /etc/sudoers + chmod 0440 /etc/sudoers + touch /sudo-modified +fi diff --git a/docker/neutron/neutron-server/start.sh b/docker/neutron/neutron-server/start.sh deleted file mode 100755 index cf30a7f0a..000000000 --- a/docker/neutron/neutron-server/start.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -o errexit - -# Loading common functions. -source /opt/kolla/kolla-common.sh - -# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases -# of the KOLLA_BOOTSTRAP variable being set, including empty. -if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then - su -s /bin/bash -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron - exit 0 -fi - -exec $CMD -- cgit v1.2.3