How To Gather Data For Openshift OVN-Kubernetes
How To Gather Data For Openshift OVN-Kubernetes
Kubernetes
SOLUTION VERIFIED - Updated April 6 2022 at 9:22 AM -
English
Environment
Red Hat Openshift Container Platform 4.4
Red Hat Openshift Container Platform 4.5
Red Hat Openshift Container Platform 4.6
Issue
Issue with potentially missing ovn LogicalFlow, or ovs OpenFlow rules
Issue not seeing packets getting to the outgoing host interface
Intermittent traffic failures
Diagnostic Steps
Using must-gather
Note: When possible you should use must-gather to collect networking information in a
consistent/simplified way, however to do this you must run must-gather in
an advanced fashion, to add the network collection to the archive.
Raw
export NODES="node1.clusterName.example.com node2.clusterName.example.com"
oc adm must-gather -- 'gather && gather_network_logs '${NODES}''
Note: If this collection fails or can't be run due to an api server outage; please follow the
remainder of this article to manually collect the information for debugging a cluster.
Raw
# oc get pods -n test-mydb-operator -o wide
NAME READY STATUS RESTARTS
AGE IP NODE NOMINATED NODE READINESS GATES
awesomedb-head-5b75dcf67d-llkv9 1/1 Running 30 34h 172.24.2.216
openshift-worker-1 <none> <none>
awesomedb-bigdata-655f86bd75-qrk8z 3/3 Running 30 34h 172.24.3.217
openshift-worker-0 <none> <none>
awesomedb-sort-6fbf8dc89b-nf2qk 2/2 Running 30 34h 172.24.2.267
openshift-worker-1 <none> <none>
With the above example my NODES to gather data from would be openshift-worker-
1 and openshift-worker-0.
To make sure not to lose any log entries it is best to stream the logs to a central location. In the
example script you can either enable to log to a local file (local to where you are running the
script) or not log local if you have an alternative destination.
Note: Alter the NODES variable to match which hosts you wish to debug.
Raw
#!/bin/bash
LOG_LOCAL=true
# This scriptuses "oc logs ... -f" and sends it to bg.
# You have to manually stop it when you're done:
# kill $(ps f | awk '$0 ~ /oc.*logs/ {print $1}')
OUTDIRa=ovn_outputs
OUTDIRb=ovs_outputs
mkdir -p ${OUTDIRa}
mkdir -p ${OUTDIRb}
# Adding master nodes to the list of NODES regradless to help detect potential
replication issues
for NODE in $(echo $NODES $(oc get nodes -l node-role.kubernetes.io/master -o
jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') | sort -u); do
echo "Working on $NODE"
OVN_POD=$(oc -n openshift-ovn-kubernetes get pod -l app=ovnkube-
node,component=network -o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}
{.metadata.name}{end}')
OVS_POD=$(oc -n openshift-ovn-kubernetes get pod -l app=ovs-node,component=network
-o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}{.metadata.name}{end}')
if ! $LOG_LOCAL; then
# if LOG_LOCAL variable is set to false the loop stops here and will not log
locally
continue
fi
Raw
kill $(ps f | awk '$0 ~ /oc.*logs/ {print $1}')
Note: it will kill any currently running oc log command on the current system
If the LOG_LOCAL variable was set to true then pod logs will be in these two directories ready to
be analyzed or attached to a case:
- ./ovn_outputs/.*.log
- ./ovs_outputs/.*.log
Raw
#!/bin/bash
# Adding master nodes to the list of NODES regradless to help detect potential
replication issues
for NODE in $(echo $NODES $(oc get nodes -l node-role.kubernetes.io/master -o
jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') | sort -u); do
OVN_POD=$(oc -n openshift-ovn-kubernetes get pod -l app=ovnkube-
node,component=network -o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}
{.metadata.name}{end}')
OVS_POD=$(oc -n openshift-ovn-kubernetes get pod -l app=ovs-node,component=network
-o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}{.metadata.name}{end}')
done
Gathering OVN and OVS data
For Openshift Container Platform releases 4.7.x in addition to the below script, also run the
following must-gather collection script:
Raw
oc adm must-gather --dest-dir="./network-ovn" -- /usr/bin/gather_network_logs
The below script will grab the dumps for both ovn and ovs, all that is required to have is to
change the NODES variable in the script to the node names experiencing the issue (current
example: "openshift-worker-0 openshift-worker-1")
Collection script:
Raw
#!/bin/bash
OUTDIRa=ovn_outputs
OUTDIRb=ovs_outputs
mkdir -p ${OUTDIRa}
mkdir -p ${OUTDIRb}
OVN_NB_TABLES=(
"NB_Global"
"Logical_Switch"
"Logical_Switch_Port"
"Address_Set"
"Port_Group"
"Load_Balancer"
"ACL"
"Logical_Router"
"QoS"
"Meter"
"Meter_Band"
"Logical_Router_Port"
"Logical_Router_Static_Route"
"NAT"
"DHCP_Options"
"Connection"
"DNS"
"SSL"
"Gateway_Chassis"
)
PIDS=()
for NODE in ${NODES}; do
echo ${NODE}
### OVN
POD_OVNKUBE=$(2>/dev/null oc -n openshift-ovn-kubernetes get pod -l app=ovnkube-
node,component=network -o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}
{.metadata.name}{end}')
NBDB=$(oc describe ds ovnkube-node -n openshift-ovn-kubernetes | awk '/nb-address/
{gsub(/"/, "", $2); print $2}')
SBDB=$(oc describe ds ovnkube-node -n openshift-ovn-kubernetes | awk '/sb-address/
{gsub(/"/, "", $2); print $2}')
ARGS="-p /ovn-cert/tls.key -c /ovn-cert/tls.crt -C /ovn-ca/ca-bundle.crt"
### OVS
POD_OVS_NODE=$(2>/dev/null oc -n openshift-ovn-kubernetes get pod -l app=ovs-
node,component=network -o jsonpath='{range .items[?(@.spec.nodeName=="'${NODE}'")]}
{.metadata.name}{end}')
OVS_BRIDGES=$(oc -n openshift-ovn-kubernetes exec -t ${POD_OVS_NODE} -- ovs-vsctl
list-br 2>/dev/null)
for OVS_BRIDGE in ${OVS_BRIDGES}; do
echo "oc -n openshift-ovn-kubernetes exec -t ${POD_OVS_NODE} -- ovs-ofctl dump-
flows ${OVS_BRIDGE}"
oc -n openshift-ovn-kubernetes exec -t ${POD_OVS_NODE} -- ovs-ofctl dump-flows $
{OVS_BRIDGE} > ${OUTDIRb}/${NODE}.ovs-ofctl.dump-flows.${OVS_BRIDGE}
Once it is ran it should create a "ovs_ovn_dumps.tar.gz" tarball file, simply upload it to the case
if you wish to have support analyze it.
OVN Tracing
For information on how to trace OVN flows (using ovn-trace/ovnkube-trace) please check
the following KCS:
- https://access.redhat.com/solutions/5887511