Skip to content

Commit

Permalink
Merge pull request #13399 from giuseppe/system-containers-notify
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Mar 17, 2017
2 parents 9be07d7 + 75b2674 commit 5b8b4dc
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 49 deletions.
2 changes: 1 addition & 1 deletion images/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY etc/cni/net.d/* /etc/cni/net.d/
COPY conf/openshift-sdn-ovs.conf /usr/lib/systemd/system/origin-node.service.d/
COPY scripts/* /usr/local/bin/
COPY system-container/system-container-wrapper.sh /usr/local/bin/
COPY system-container/config.json.template system-container/service.template system-container/tmpfiles.template /exports/
COPY system-container/manifest.json system-container/config.json.template system-container/service.template system-container/tmpfiles.template /exports/

RUN curl -L -o /etc/yum.repos.d/origin-next-epel-7.repo https://copr.fedoraproject.org/coprs/maxamillion/origin-next/repo/epel-7/maxamillion-origin-next-epel-7.repo && \
INSTALL_PKGS="libmnl libnetfilter_conntrack conntrack-tools openvswitch \
Expand Down
2 changes: 1 addition & 1 deletion images/node/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM openshift/origin

COPY scripts/* /usr/local/bin/
COPY system-container/system-container-wrapper.sh /usr/local/bin
COPY system-container/config.json.template system-container/service.template system-container/tmpfiles.template /exports/
COPY system-container/manifest.json system-container/config.json.template system-container/service.template system-container/tmpfiles.template /exports/

RUN INSTALL_PKGS="origin-sdn-ovs libmnl libnetfilter_conntrack conntrack-tools openvswitch \
libnfnetlink iptables iproute bridge-utils procps-ng ethtool socat openssl \
Expand Down
45 changes: 23 additions & 22 deletions images/node/system-container/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@
"rw"
]
},
{
"type": "bind",
"source": "/usr/bin/docker-current",
"destination": "/usr/bin/docker-current",
"options": [
"rbind",
"ro"
]
},
{
"type": "bind",
"source": "/etc/localtime",
Expand All @@ -163,16 +154,6 @@
"ro"
]
},
{
"type": "bind",
"source": "/etc/origin/sdn",
"destination": "/etc/openshift-sdn",
"options": [
"rbind",
"rw",
"mode=755"
]
},
{
"type": "bind",
"source": "/run",
Expand Down Expand Up @@ -215,7 +196,7 @@
},
{
"type": "bind",
"source": "/etc/origin/openvswitch",
"source": "$ORIGIN_CONFIG_DIR/openvswitch",
"destination": "/etc/openvswitch",
"options": [
"rbind",
Expand All @@ -225,7 +206,7 @@
},
{
"type": "bind",
"source": "/var/lib/origin",
"source": "$ORIGIN_DATA_DIR",
"destination": "/var/lib/origin",
"options": [
"rbind",
Expand Down Expand Up @@ -295,14 +276,34 @@
},
{
"type": "bind",
"source": "/etc/origin/node",
"source": "$ORIGIN_CONFIG_DIR/sdn",
"destination": "/etc/openshift-sdn",
"options": [
"rbind",
"rw",
"mode=755"
]
},
{
"type": "bind",
"source": "$ORIGIN_CONFIG_DIR/node",
"destination": "/etc/origin/node",
"options": [
"rbind",
"rw",
"mode=755"
]
},
{
"type": "bind",
"source": "$ORIGIN_CONFIG_DIR/cloudprovider",
"destination": "/etc/origin/cloudprovider",
"options": [
"rbind",
"rw",
"mode=755"
]
},
{
"destination": "/tmp",
"type": "tmpfs",
Expand Down
10 changes: 10 additions & 0 deletions images/node/system-container/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "1.0",
"defaultValues": {
"ORIGIN_CONFIG_DIR": "/etc/origin",
"ORIGIN_DATA_DIR": "/var/lib/origin",
"MASTER_SERVICE": "atomic-openshift-master.service",
"DOCKER_SERVICE": "docker.service",
"OPENVSWITCH_SERVICE": "openvswitch.service"
}
}
11 changes: 4 additions & 7 deletions images/node/system-container/service.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[Unit]
After=atomic-openshift-master.service
After=docker.service
After=openvswitch.service
PartOf=docker.service
Requires=docker.service
Requires=openvswitch.service
Requires=$NAME-dep.service
After=${DOCKER_SERVICE}
After=${OPENVSWITCH_SERVICE}
Wants=${DOCKER_SERVICE}
After=$NAME-dep.service
After=${MASTER_SERVICE}

[Service]
EnvironmentFile=/etc/sysconfig/$NAME
Expand Down
5 changes: 3 additions & 2 deletions images/node/system-container/tmpfiles.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
d /var/lib/origin - - - - -
d $ORIGIN_DATA_DIR - - - - -
d /var/lib/cni - - - - -
d /var/run/secrets - - - - -
d /etc/origin/sdn - - - - -
d $ORIGIN_CONFIG_DIR/sdn - - - - -
d $ORIGIN_CONFIG_DIR/cloudprovider - - - - -
2 changes: 1 addition & 1 deletion images/openvswitch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ ENV HOME /root

# files required to run as a system container
COPY system-container/system-container-wrapper.sh /usr/local/bin/
COPY system-container/config.json.template system-container/service.template /exports/
COPY system-container/config.json.template system-container/service.template system-container/tmpfiles.template system-container/manifest.json /exports/

ENTRYPOINT ["/usr/local/bin/ovs-run.sh"]
2 changes: 1 addition & 1 deletion images/openvswitch/system-container/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
},
{
"type": "bind",
"source": "/etc/origin/openvswitch",
"source": "$ORIGIN_CONFIG_DIR/openvswitch",
"destination": "/etc/openvswitch",
"options": [
"rbind",
Expand Down
7 changes: 7 additions & 0 deletions images/openvswitch/system-container/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "1.0",
"defaultValues": {
"ORIGIN_CONFIG_DIR": "/etc/origin",
"DOCKER_SERVICE": "docker.service"
}
}
10 changes: 5 additions & 5 deletions images/openvswitch/system-container/service.template
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[Unit]
After=docker.service
Requires=docker.service
PartOf=docker.service
After=${DOCKER_SERVICE}
Requires=${DOCKER_SERVICE}
PartOf=${DOCKER_SERVICE}

[Service]
EnvironmentFile=/etc/sysconfig/$NAME
ExecStartPre=/bin/bash -c 'export -p > /run/$NAME-env'
ExecStart=$EXEC_START
ExecStartPost=/usr/bin/sleep 5
ExecStop=$EXEC_STOP
SyslogIdentifier=$NAME
Restart=always
RestartSec=5s
Type=notify
NotifyAccess=all
WorkingDirectory=$DESTDIR
RuntimeDirectory=${NAME}

Expand Down
27 changes: 26 additions & 1 deletion images/openvswitch/system-container/system-container-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
#!/bin/sh
#!/bin/bash
source /run/$NAME-env

MAINPID=`sed -n -e "/^PPid/ s|PPid:\t||p" /proc/$$/status`

# openvswitch 2.4 has no systemd-notify support, so add it here.
# Workaround for a bug in systemd-notify 219. Whenever used with --pid, systemd-notify 219
# sends an incorrect packet to $NOTIFY_SOCKET and the process hangs.
# Newer versions of systemd-notify don't have this issue, and also this change in runc,
# even if addressing another issue: https://github.com/opencontainers/runc/pull/1308
# will ensure once it gets in a release that the notify events are properly propagated.
if test -n ${NOTIFY_SOCKET-}; then
/usr/share/openvswitch/scripts/ovs-ctl status
while /usr/share/openvswitch/scripts/ovs-ctl status | grep -q "not running"; do
sleep 1
done
ps aux | grep $MAINPID
python - << EOF
import socket
import os
s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
e = os.getenv('NOTIFY_SOCKET')
s.connect(e)
s.sendall('MAINPID=%i\nREADY=1\n' % $MAINPID)
s.close()
EOF
fi &

exec /usr/local/bin/ovs-run.sh
1 change: 1 addition & 0 deletions images/openvswitch/system-container/tmpfiles.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /etc/origin/openvswitch - - - - -
2 changes: 1 addition & 1 deletion images/origin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
FROM openshift/origin-base

COPY system-container/system-container-wrapper.sh /usr/local/bin/
COPY system-container/config.json.template system-container/manifest.json system-container/service.template /exports/
COPY system-container/config.json.template system-container/manifest.json system-container/service.template system-container/tmpfiles.template /exports/
COPY bin/openshift /usr/bin/openshift
RUN ln -s /usr/bin/openshift /usr/bin/oc && \
ln -s /usr/bin/openshift /usr/bin/oadm && \
Expand Down
2 changes: 1 addition & 1 deletion images/origin/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ EXPOSE 8443 53

# files required to run as a system container
COPY system-container/system-container-wrapper.sh /usr/local/bin
COPY system-container/config.json.template system-container/manifest.json system-container/service.template /exports/
COPY system-container/config.json.template system-container/manifest.json system-container/service.template system-container/tmpfiles.template /exports/

ENTRYPOINT ["/usr/bin/openshift"]
4 changes: 2 additions & 2 deletions images/origin/system-container/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
},
{
"type": "bind",
"source": "/etc/origin",
"source": "$ORIGIN_CONFIG_DIR",
"destination": "/etc/origin",
"options": [
"bind",
Expand All @@ -137,7 +137,7 @@
},
{
"type": "bind",
"source": "/var/lib/origin",
"source": "$ORIGIN_DATA_DIR",
"destination": "/var/lib/origin",
"options": [
"rbind",
Expand Down
6 changes: 5 additions & 1 deletion images/origin/system-container/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"version": "1.0",
"defaultValues": {
"COMMAND": ""
"COMMAND": "",
"ORIGIN_CONFIG_DIR": "/etc/origin",
"ORIGIN_DATA_DIR": "/var/lib/origin",
"ETCD_SERVICE": "etcd.service",
"NODE_SERVICE": "atomic-openshift-node.service"
}
}

6 changes: 3 additions & 3 deletions images/origin/system-container/service.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
After=docker.service
Requires=docker.service
PartOf=docker.service
After=network-online.target
After=${ETCD_SERVICE}
Before=${NODE_SERVICE}

[Service]
EnvironmentFile=-/etc/sysconfig/$NAME
Expand Down
2 changes: 2 additions & 0 deletions images/origin/system-container/tmpfiles.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
d $ORIGIN_CONFIG_DIR - - - - -
d $ORIGIN_DATA_DIR - - - - -

0 comments on commit 5b8b4dc

Please sign in to comment.