From 5a78f9d7841691916c6d42f813ff9bd9cc5a3148 Mon Sep 17 00:00:00 2001 From: Michael Cambria Date: Thu, 9 Apr 2020 19:03:47 -0400 Subject: [PATCH 1/2] Add hostPath type: Directory where needed for OVS host directories Signed-off-by: Michael Cambria --- .../network/ovn-kubernetes/006-ovs-node.yaml | 77 ++++++++++++++- .../network/ovn-kubernetes/ovnkube-node.yaml | 93 ++++++++++++++++++- 2 files changed, 161 insertions(+), 9 deletions(-) diff --git a/bindata/network/ovn-kubernetes/006-ovs-node.yaml b/bindata/network/ovn-kubernetes/006-ovs-node.yaml index 122ca1c379..8be898948d 100644 --- a/bindata/network/ovn-kubernetes/006-ovs-node.yaml +++ b/bindata/network/ovn-kubernetes/006-ovs-node.yaml @@ -42,6 +42,18 @@ spec: - | #!/bin/bash set -euo pipefail + set -x + if [[ -f /usr/bin/id ]]; then + /usr/bin/id openvswitch + else + echo "id command not found" + fi + if [[ -d /run/openvswitch ]]; then + ls -al /run/openvswitch + 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,6 +62,18 @@ 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 + 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 { # 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 @@ -57,9 +81,37 @@ spec: 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 + if (systemctl is-active --quiet openvswitch) ; then + echo "OVS started by RHCOS" + systemctl is-active openvswitch + journalctl -xeu openvswitch --no-pager + else + echo "OVS started by ovs-node container, NOT RHCOS" + # Need container up v0.0 just to see if host starts ovs and friends /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 diff --git a/bindata/network/ovn-kubernetes/ovnkube-node.yaml b/bindata/network/ovn-kubernetes/ovnkube-node.yaml index 61ea850280..ca405d46dc 100644 --- a/bindata/network/ovn-kubernetes/ovnkube-node.yaml +++ b/bindata/network/ovn-kubernetes/ovnkube-node.yaml @@ -41,12 +41,46 @@ spec: - -c - | set -e + set -x + if [[ -f /usr/bin/id ]]; then + /usr/bin/id openvswitch + else + echo "id command not found" + fi + 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 + 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 if [[ -f "/env/${K8S_NODE}" ]]; then set -o allexport source "/env/${K8S_NODE}" set +o allexport fi echo "$(date -Iseconds) - starting ovn-controller" + if (modprobe openvswitch) ; then + echo "modprobe openvswitch success?" + else + echo "modprobe openvswitch fail?" + fi + lsmod | grep openvswitch + 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 exec ovn-controller unix:/var/run/openvswitch/db.sock -vfile:off \ --no-chdir --pidfile=/var/run/ovn/ovn-controller.pid \ -p /ovn-cert/tls.key -c /ovn-cert/tls.crt -C /ovn-ca/ca-bundle.crt \ @@ -61,8 +95,11 @@ spec: fieldRef: fieldPath: spec.nodeName volumeMounts: + - mountPath: /host + name: host-slash + readOnly: false - mountPath: /run/openvswitch - name: run-openvswitch + name: host-run-openvswitch - mountPath: /run/ovn/ name: run-ovn - mountPath: /etc/openvswitch @@ -91,12 +128,56 @@ spec: - -c - | set -xe + if [[ -f /usr/bin/id ]]; then + /usr/bin/id openvswitch + else + echo "id command not found" + fi + 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 + 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 + if [[ -d /run/ovn ]]; then + ls -al /run/ovn + else + echo "/run/ovn doesn't exist" + fi + if [[ -d /var/run/ovn ]]; then + ls -al /var/run/ovn + else + echo "/var/run/ovn doesn't exist" + fi if [[ -f "/env/${K8S_NODE}" ]]; then set -o allexport source "/env/${K8S_NODE}" set +o allexport fi echo "I$(date "+%m%d %H:%M:%S.%N") - waiting for db_ip addresses" + if (modprobe openvswitch) ; then + echo "modprobe openvswitch success?" + else + echo "modprobe openvswitch fail?" + fi + lsmod | grep openvswitch + 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 + mkdir -p /run/ovn-kubernetes cp -f /usr/libexec/cni/ovn-k8s-cni-overlay /cni-bin-dir/ ovn_config_namespace=openshift-ovn-kubernetes retries=0 @@ -158,7 +239,7 @@ spec: # for the iptables wrapper - mountPath: /host name: host-slash - readOnly: true + readOnly: false # for the CNI server socket - mountPath: /run/ovn-kubernetes/ name: host-run-ovn-kubernetes @@ -177,7 +258,7 @@ spec: - mountPath: /var/lib/cni/networks/ovn-k8s-cni-overlay name: host-var-lib-cni-networks-ovn-kubernetes - mountPath: /run/openvswitch - name: run-openvswitch + name: host-run-openvswitch - mountPath: /run/ovn/ name: run-ovn - mountPath: /etc/openvswitch @@ -214,6 +295,7 @@ spec: - name: host-slash hostPath: path: / + type: Directory - name: host-run-netns hostPath: path: /run/netns @@ -223,9 +305,10 @@ spec: - name: etc-openvswitch hostPath: path: /var/lib/openvswitch/etc - - name: run-openvswitch + - name: host-run-openvswitch hostPath: - path: /var/run/openvswitch + path: /run/openvswitch + type: Directory - name: run-ovn hostPath: path: /var/run/ovn From 78954212c0a8cd496a2a94138f1d148467c841b7 Mon Sep 17 00:00:00 2001 From: Michael Cambria Date: Wed, 22 Apr 2020 10:21:37 -0400 Subject: [PATCH 2/2] ovnkube-master.yaml /run/openvswitch change from emptyDir to hostPath Signed-off-by: Michael Cambria --- bindata/network/ovn-kubernetes/ovnkube-master.yaml | 4 +++- bindata/network/ovn-kubernetes/ovnkube-node.yaml | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bindata/network/ovn-kubernetes/ovnkube-master.yaml b/bindata/network/ovn-kubernetes/ovnkube-master.yaml index d27fb54707..2e7fee8d81 100644 --- a/bindata/network/ovn-kubernetes/ovnkube-master.yaml +++ b/bindata/network/ovn-kubernetes/ovnkube-master.yaml @@ -414,7 +414,9 @@ spec: hostPath: path: /var/lib/ovn/data - name: run-openvswitch - emptyDir: {} + hostPath: + path: /run/openvswitch + type: Directory - name: run-ovn hostPath: path: /var/run/ovn diff --git a/bindata/network/ovn-kubernetes/ovnkube-node.yaml b/bindata/network/ovn-kubernetes/ovnkube-node.yaml index ca405d46dc..b010599d12 100644 --- a/bindata/network/ovn-kubernetes/ovnkube-node.yaml +++ b/bindata/network/ovn-kubernetes/ovnkube-node.yaml @@ -59,6 +59,16 @@ spec: if [[ -f /var/run/openvswitch/ovsdb-server.pid ]] ; then cat /var/run/openvswitch/ovsdb-server.pid fi + if [[ -d /run/ovn ]]; then + ls -al /run/ovn + else + echo "/run/ovn doesn't exist" + fi + if [[ -d /var/run/ovn ]]; then + ls -al /var/run/ovn + else + echo "/var/run/ovn doesn't exist" + fi if [[ -f "/env/${K8S_NODE}" ]]; then set -o allexport source "/env/${K8S_NODE}" @@ -95,9 +105,6 @@ spec: fieldRef: fieldPath: spec.nodeName volumeMounts: - - mountPath: /host - name: host-slash - readOnly: false - mountPath: /run/openvswitch name: host-run-openvswitch - mountPath: /run/ovn/