Skip to content
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

[DNM] Collect pluto debugging output with all option #2534

Open
wants to merge 8 commits into
base: release-4.15
Choose a base branch
from
31 changes: 31 additions & 0 deletions bindata/network/ovn-kubernetes/common/ipsec-containerized.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ spec:
- |
#!/bin/bash
set -exuo pipefail

{{ if .IPsecCheckForLibreswan }}
if rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container doesnt need to init anything"
exit 0
fi
{{ end }}

{{ if .NETWORK_NODE_IDENTITY_ENABLE }}
# When NETWORK_NODE_IDENTITY_ENABLE is true, use the per-node certificate to create a kubeconfig
# that will be used to talk to the API
Expand Down Expand Up @@ -187,6 +195,9 @@ spec:
name: signer-ca
- mountPath: /etc/openvswitch
name: etc-openvswitch
- mountPath: /usr/share/rpm
name: host-usr-share-rpm
readOnly: true
resources:
requests:
cpu: 10m
Expand Down Expand Up @@ -218,6 +229,13 @@ spec:
}
trap cleanup SIGTERM

{{ if .IPsecCheckForLibreswan }}
if rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container will sleep to infinity"
sleep infinity
fi
{{ end }}

# Don't start IPsec until ovnkube-node has finished setting up the node
counter=0
until [ -f /etc/cni/net.d/10-ovn-kubernetes.conf ]
Expand Down Expand Up @@ -274,6 +292,9 @@ spec:
name: host-var-log-ovs
- mountPath: /etc/openvswitch
name: etc-openvswitch
- mountPath: /usr/share/rpm
name: host-usr-share-rpm
readOnly: true
resources:
requests:
cpu: 10m
Expand All @@ -286,6 +307,12 @@ spec:
- -c
- |
#!/bin/bash
{{ if .IPsecCheckForLibreswan }}
if rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container is always \"alive\""
exit 0
fi
{{ end }}
if [[ $(ipsec whack --trafficstatus | wc -l) -eq 0 ]]; then
echo "no ipsec traffic configured"
exit 10
Expand Down Expand Up @@ -319,6 +346,10 @@ spec:
- name: host-cni-netd
hostPath:
path: "{{.CNIConfDir}}"
- name: host-usr-share-rpm
hostPath:
path: /usr/share/rpm
type: DirectoryOrCreate
tolerations:
- operator: "Exists"
{{end}}
55 changes: 55 additions & 0 deletions bindata/network/ovn-kubernetes/common/ipsec-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ spec:
- |
#!/bin/bash
set -exuo pipefail
{{ if .IPsecCheckForLibreswan }}
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container has nothing to init"
exit 0
fi
{{ end }}
{{ if .NETWORK_NODE_IDENTITY_ENABLE }}
# When NETWORK_NODE_IDENTITY_ENABLE is true, use the per-node certificate to create a kubeconfig
# that will be used to talk to the API
Expand Down Expand Up @@ -192,6 +198,9 @@ spec:
name: etc-openvswitch
- mountPath: /etc
name: host-etc
- mountPath: /usr/share/rpm
name: host-usr-share-rpm
readOnly: true
resources:
requests:
cpu: 10m
Expand All @@ -208,6 +217,12 @@ spec:
#!/bin/bash
set -exuo pipefail

{{ if .IPsecCheckForLibreswan }}
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container will sleep to infinity"
sleep infinity
fi
{{ end }}

# Don't start IPsec until ovnkube-node has finished setting up the node
counter=0
Expand All @@ -231,6 +246,14 @@ spec:
# After a restart of this container (or on initial startup), we flush xfrm state and policy
# before we start pluto and ovs-monitor-ipsec in order to start in a known good state. This
# will result in a small interruption in traffic until pluto and ovs-monitor-ipsec start again.
# Let us stop ipsec service first and wait for few seconds.
# This allows pluto to:
# 1) destroy all inbound SA.
# 2) send delete payloads to the other side to let them close their SA and once replies are sent.
# 3) pluto destroy also outbound SA.
chroot /proc/1/root ipsec stop && sleep 30s
# Try flushing xfrm state and policy explicitly again. It may not have any effect as ipsec stop
# cleaned up those entries already.
ip x s flush
ip x p flush

Expand All @@ -251,6 +274,18 @@ spec:
# since pluto is on the host, we need to restart it after the flush
chroot /proc/1/root ipsec restart

counter=0
until [ -r /run/pluto/pluto.ctl ]; do
counter=$((counter+1))
sleep 1
if [ $counter -gt 300 ];
then
echo "ipsec has not started after $counter seconds"
exit 1
fi
done
echo "ipsec service is restarted"

# Workaround for https://github.com/libreswan/libreswan/issues/373
ulimit -n 1024

Expand Down Expand Up @@ -280,6 +315,13 @@ spec:
# In order to maintain traffic flows during container restart, we
# need to ensure that xfrm state and policies are not flushed.

{{ if .IPsecCheckForLibreswan }}
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, preStop wont do anything"
exit 0
fi
{{ end }}

# Don't allow ovs monitor to cleanup persistent state
kill "$(cat /var/run/openvswitch/ovs-monitor-ipsec.pid 2>/dev/null)" 2>/dev/null || true
env:
Expand All @@ -303,6 +345,9 @@ spec:
name: host-var-lib
- mountPath: /etc
name: host-etc
- mountPath: /usr/share/rpm
name: host-usr-share-rpm
readOnly: true
resources:
requests:
cpu: 10m
Expand All @@ -315,6 +360,12 @@ spec:
- -c
- |
#!/bin/bash
{{ if .IPsecCheckForLibreswan }}
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container is always \"alive\""
exit 0
fi
{{ end }}
if [[ $(ipsec whack --trafficstatus | wc -l) -eq 0 ]]; then
echo "no ipsec traffic configured"
exit 10
Expand Down Expand Up @@ -358,6 +409,10 @@ spec:
path: /etc
type: Directory
name: host-etc
- name: host-usr-share-rpm
hostPath:
path: /usr/share/rpm
type: DirectoryOrCreate
tolerations:
- operator: "Exists"
{{end}}
11 changes: 5 additions & 6 deletions pkg/bootstrap/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ type OVNUpdateStatus struct {
// OVNIPsecStatus contains status of current IPsec configuration
// in the cluster.
type OVNIPsecStatus struct {
LegacyIPsecUpgrade bool // true if IPsec in 4.14 or Pre-4.14 cluster is upgraded to latest version
OVNIPsecActive bool // set to true unless we are sure it is not.
OVNIPsecActive bool // set to true unless we are sure it is not.
}

type OVNBootstrapResult struct {
Expand Down Expand Up @@ -97,11 +96,11 @@ type InfraStatus struct {
// WorkerIPsecMachineConfigs contains ipsec machine config objects of worker nodes.
WorkerIPsecMachineConfigs []*mcfgv1.MachineConfig

// MasterMCPStatus contains machine config pool statuses for pools having master role.
MasterMCPStatuses []mcfgv1.MachineConfigPoolStatus
// MasterMCPs contains machine config pools having master role.
MasterMCPs []mcfgv1.MachineConfigPool

// WorkerMCPStatus contains machine config pool statuses for pools having worker role.
WorkerMCPStatuses []mcfgv1.MachineConfigPoolStatus
// WorkerMCPs contains machine config pools having worker role.
WorkerMCPs []mcfgv1.MachineConfigPool

// MachineConfigClusterOperatorReady set to true when Machine Config cluster operator is in ready state.
MachineConfigClusterOperatorReady bool
Expand Down
Loading