-
Notifications
You must be signed in to change notification settings - Fork 287
[WIP] Start host openvswitch using systemctl #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,18 @@ spec: | |
| - | | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| set -x | ||
| if [[ -f /usr/bin/id ]]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't understand all these checks, they are not atomic and thus worse than redundant because they hid the real error message.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or no
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or I guess it's not clear in which environment
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Most (if not all) of these checks were added to debug and will not exist in the final PR. |
||
| /usr/bin/id openvswitch | ||
| else | ||
| echo "id command not found" | ||
| fi | ||
| if [[ -d /run/openvswitch ]]; then | ||
| ls -al /run/openvswitch | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess question here as well, when is |
||
| fi | ||
| if [[ -d /var/run/openvswitch ]]; then | ||
| ls -al /var/run/openvswitch | ||
| fi | ||
| if [[ -f "/env/${K8S_NODE}" ]]; then | ||
| set -o allexport | ||
| source "/env/${K8S_NODE}" | ||
|
|
@@ -50,16 +62,56 @@ spec: | |
| echo "$(date -Iseconds) - starting ovs-daemons" | ||
| chown -R openvswitch:openvswitch /run/openvswitch | ||
| chown -R openvswitch:openvswitch /etc/openvswitch | ||
| if [[ -d /run/openvswitch ]]; then | ||
| ls -al /run/openvswitch | ||
| fi | ||
| if [[ -d /var/run/openvswitch ]]; then | ||
| ls -al /var/run/openvswitch | ||
| fi | ||
| if [[ -f /var/run/openvswitch/ovs-vswitchd.pid ]] ; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| cat /var/run/openvswitch/ovs-vswitchd.pid | ||
| fi | ||
| if [[ -f /var/run/openvswitch/ovsdb-server.pid ]] ; then | ||
| cat /var/run/openvswitch/ovsdb-server.pid | ||
| fi | ||
| function quit { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes. This needs to be moved to the "non-systemd case"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is all debug code
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not the |
||
| # Don't allow ovs-vswitchd to clear datapath flows on exit | ||
| kill -9 $(cat /var/run/openvswitch/ovs-vswitchd.pid 2>/dev/null) 2>/dev/null || true | ||
| kill $(cat /var/run/openvswitch/ovsdb-server.pid 2>/dev/null) 2>/dev/null || true | ||
| exit 0 | ||
| } | ||
| trap quit SIGTERM | ||
| if [[ -S /var/run/openvswitch/db.sock ]]; then | ||
| echo "Found /var/run/openvswitch/db.sock" | ||
| else | ||
| echo "File /var/run/openvswitch/db.sock was not found" | ||
| fi | ||
| if [[ -S /run/openvswitch/db.sock ]]; then | ||
| echo "Found /run/openvswitch/db.sock" | ||
| else | ||
| echo "File /run/openvswitch/db.sock was not found" | ||
| fi | ||
| export SYSTEMD_IGNORE_CHROOT=yes | ||
| journalctl -xeu ovsdb-server --no-pager | ||
| #systemctl is-active --quiet ovsdb-server | ||
| journalctl -xeu openvswitch --no-pager | ||
| if (modprobe openvswitch) ; then | ||
| echo "modprobe openvswitch success?" | ||
| else | ||
| echo "modprobe openvswitch fail?" | ||
| fi | ||
| lsmod | grep openvswitch | ||
|
mccv1r0 marked this conversation as resolved.
|
||
| if (systemctl is-active --quiet openvswitch) ; then | ||
| echo "OVS started by RHCOS" | ||
| systemctl is-active openvswitch | ||
| journalctl -xeu openvswitch --no-pager | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably just want to |
||
| else | ||
|
mccv1r0 marked this conversation as resolved.
Outdated
|
||
| echo "OVS started by ovs-node container, NOT RHCOS" | ||
| # Need container up v0.0 just to see if host starts ovs and friends | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix the indentation here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand why we need to start OVS from this container. Shouldn't systemd OVS be configured as a service with restart=Always? Why does a pod need to start it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might have been left-over from before the MCO was going to start OVS. Our first pass was starting system OVS from a pod via systemctl without MCO, but we moved to MCO because Clayton told us to. |
||
| /usr/share/openvswitch/scripts/ovs-ctl start --ovs-user=openvswitch:openvswitch --system-id=random | ||
| ovs-appctl vlog/set "file:${OVS_LOG_LEVEL}" | ||
| /usr/share/openvswitch/scripts/ovs-ctl --protocol=udp --dport=6081 enable-protocol | ||
| fi | ||
| echo "$(date -Iseconds) - ovs-daemons running" | ||
|
|
||
| tail -F --pid=$(cat /var/run/openvswitch/ovs-vswitchd.pid) /var/log/openvswitch/ovs-vswitchd.log & | ||
|
|
@@ -82,9 +134,15 @@ spec: | |
| name: host-sys | ||
| readOnly: true | ||
| - mountPath: /run/openvswitch | ||
| name: run-openvswitch | ||
| name: host-run-openvswitch | ||
| - mountPath: /run/systemd | ||
| name: host-run-systemd | ||
| - mountPath: /etc/openvswitch | ||
| name: etc-openvswitch | ||
| - mountPath: /var/log/openvswitch | ||
| name: host-var-log-openvswitch | ||
| - mountPath: /sys/fs/cgroup | ||
| name: sys-fs-cgroup | ||
| - mountPath: /var/lib/openvswitch | ||
| name: var-lib-openvswitch | ||
| - mountPath: /env | ||
|
|
@@ -120,22 +178,33 @@ spec: | |
| - key: network.operator.openshift.io/external-openvswitch | ||
| operator: DoesNotExist | ||
| volumes: | ||
| # used for iptables wrapper scripts | ||
| - name: host-modules | ||
| hostPath: | ||
| path: /lib/modules | ||
| - name: var-lib-openvswitch | ||
| hostPath: | ||
| path: /var/lib/openvswitch/data | ||
| - name: host-run-openvswitch | ||
| hostPath: | ||
| path: /run/openvswitch | ||
| type: Directory | ||
| - name: host-run-systemd | ||
| hostPath: | ||
| path: /run/systemd | ||
| type: Directory | ||
| - name: etc-openvswitch | ||
| hostPath: | ||
| path: /var/lib/openvswitch/etc | ||
| - name: run-openvswitch | ||
| - name: host-var-log-openvswitch | ||
| hostPath: | ||
| path: /run/openvswitch | ||
| path: /var/log/openvswitch | ||
| type: Directory | ||
| - name: host-sys | ||
| hostPath: | ||
| path: /sys | ||
| - name: sys-fs-cgroup | ||
| hostPath: | ||
| path: /sys/fs/cgroup | ||
| - name: env-overrides | ||
| configMap: | ||
| name: env-overrides | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mccv1r0 let's remove this for the final one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed