Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bindata/network/ovn-kubernetes/007-pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: ovn-raft-quorum-guard
namespace: openshift-ovn-kubernetes
spec:
minAvailable: {{.OVN_MIN_AVAILABLE}}
selector:
matchLabels:
name: ovnkube-master
38 changes: 38 additions & 0 deletions bindata/network/ovn-kubernetes/ovnkube-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@ spec:
containerPort: {{.OVN_NB_PORT}}
- name: nb-db-raft-port
containerPort: {{.OVN_NB_RAFT_PORT}}
readinessProbe:
initalDelaySeconds: 30
exec:
command:
- /bin/bash
- -c
- |
set -e
OVN_NODES_ARRAY=({{.OVN_NODES}})
AVAILABLE_NODES=0
for node in "${OVN_NODES_ARRAY[@]}"; do
node_ip=$(getent ahostsv4 "${node}" | grep RAW | awk '{print $1}')
if ovs-appctl -t /var/run/openvswitch/ovnnb_db.ctl cluster/status OVN_Northbound | grep -q $node_ip; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this, and it turns out we don't ever remove servers if we're not available. So we need to parse the "connections" line. I'll give you a sample in a bit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, all we need to do is check that the DB port is open. it turns out ovsdb takes care of this for us and only opens the port when consensus is achieved.

(( AVAILABLE_NODES += 1 ))
fi
done
if [[ "${AVAILABLE_NODES}" -lt {{.OVN_MIN_AVAILABLE}} ]]; then
exit 1
fi

# sbdb: The southbound, or flow DB. In raft mode
- name: sbdb
Expand Down Expand Up @@ -278,6 +297,25 @@ spec:
containerPort: {{.OVN_SB_PORT}}
- name: sb-db-raft-port
containerPort: {{.OVN_SB_RAFT_PORT}}
readinessProbe:
initalDelaySeconds: 30
exec:
command:
- /bin/bash
- -c
- |
set -xe
OVN_NODES_ARRAY=({{.OVN_NODES}})
AVAILABLE_NODES=0
for node in "${OVN_NODES_ARRAY[@]}"; do
node_ip=$(getent ahostsv4 "${node}" | grep RAW | awk '{print $1}')
if ovs-appctl -t /var/run/openvswitch/ovnsb_db.ctl cluster/status OVN_Southbound | grep -q $node_ip; then
(( AVAILABLE_NODES += 1 ))
fi
done
if [[ "${AVAILABLE_NODES}" -lt {{.OVN_MIN_AVAILABLE}} ]]; then
exit 1
fi

# ovnkube master: convert kubernetes objects in to nbdb logical network components
- name: ovnkube-master
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type KuryrBootstrapResult struct {
}

type OVNBootstrapResult struct {
OVNMasterNodes []string
OVNMasterNodes []string
OVNMinAvailable int
}

type BootstrapResult struct {
Expand Down
4 changes: 3 additions & 1 deletion pkg/network/ovn_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
data.Data["OVN_NB_RAFT_PORT"] = OVN_NB_RAFT_PORT
data.Data["OVN_SB_RAFT_PORT"] = OVN_SB_RAFT_PORT
data.Data["OVN_NODES"] = strings.Join(bootstrapResult.OVN.OVNMasterNodes, " ")
data.Data["OVN_MIN_AVAILABLE"] = bootstrapResult.OVN.OVNMinAvailable

var ippools string
for _, net := range conf.ClusterNetwork {
Expand Down Expand Up @@ -170,7 +171,8 @@ func boostrapOVN(kubeClient client.Client) (*bootstrap.BootstrapResult, error) {

res := bootstrap.BootstrapResult{
OVN: bootstrap.OVNBootstrapResult{
OVNMasterNodes: ovnMasterNodes,
OVNMasterNodes: ovnMasterNodes,
OVNMinAvailable: len(ovnMasterNodes)/2 + 1,
},
}
return &res, nil
Expand Down