Skip to content

Commit

Permalink
Merge pull request #290 from karelyatin/OSPRH-7130
Browse files Browse the repository at this point in the history
[ovnController] Handle nicMappings with dashes
  • Loading branch information
openshift-merge-bot[bot] authored May 22, 2024
2 parents 5abe4b7 + 4677db5 commit 6d6cd21
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ kind: NetworkAttachmentDefinition
metadata:
annotations:
labels:
osp/net: datacentre3
osp/net: data-centre3
service: ovn-controller
name: datacentre3
name: data-centre3
spec:
config: |
{
"cniVersion": "0.3.1",
"name": "datacentre3",
"name": "data-centre3",
"type": "bridge",
"bridge": "ospbr3",
"ipam": {}
Expand Down
4 changes: 2 additions & 2 deletions templates/ovncontroller/bin/functions
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function configure_physical_networks {
for physicalNetwork in ${PhysicalNetworks}; do
br_name="br-${physicalNetwork}"
bridgeMapping="${physicalNetwork}:${br_name}"
if [ -z "$OvnBridgeMappings"]; then
if [ -z "$OvnBridgeMappings" ]; then
OvnBridgeMappings=$bridgeMapping
br_new=$br_name
else
Expand Down Expand Up @@ -98,7 +98,7 @@ function configure_physical_networks {
# Add the new bridges.
for br_name in ${br_to_add}; do
ovs-vsctl --may-exist add-br ${br_name}
ovs-vsctl --may-exist add-port ${br_name} ${br_name##*-}
ovs-vsctl --may-exist add-port ${br_name} ${br_name#*-}
done

# Delete the old bridges not longer present in "OvnBridgeMappings" and the
Expand Down
2 changes: 1 addition & 1 deletion tests/kuttl/common/cleanup-ovn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ delete:
name: datacentre2
- apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
name: datacentre3
name: data-centre3
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: TestStep
commands:
- script: |
oc apply -n $NAMESPACE -f ../../../../config/samples/nad_datacentre2.yaml
oc apply -n $NAMESPACE -f ../../../../config/samples/nad_datacentre3.yaml
oc apply -n $NAMESPACE -f ../../../../config/samples/nad_data-centre3.yaml
5 changes: 3 additions & 2 deletions tests/kuttl/tests/ovn_nicmappings/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ commands:
controller_pod=$(oc get pod -n $NAMESPACE -l service=ovn-controller-ovs -o name|head -1)
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev datacentre2 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-datacentre2 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev datacentre3 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-datacentre3 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ovs-vsctl list-ports br-datacentre2 | grep datacentre2 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev data-centre3 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-data-centre3 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ovs-vsctl --if-exists get open . external_ids:ovn-bridge-mappings | grep -q "datacentre2:br-datacentre2" || exit 1
exit 0
7 changes: 4 additions & 3 deletions tests/kuttl/tests/ovn_nicmappings/04-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Check for:
#
# - The interface "datacentre3" exists in the ovn-controller container
# - The interface "data-centre3" exists in the ovn-controller container
# - The interface "datacentre2" no longer exists in the ovn-controller container
# - The OVS Open vSwitch external_ids:ovn-bridge-mappings is configured correctly

Expand All @@ -11,8 +11,9 @@ timeout: 300
commands:
- script: |
controller_pod=$(oc get pod -n $NAMESPACE -l service=ovn-controller-ovs -o name|head -1)
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev datacentre3 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-datacentre3 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev data-centre3 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-data-centre3 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ovs-vsctl list-ports br-data-centre3 | grep data-centre3 || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev datacentre2 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ip link show dev br-datacentre2 2>&1 | grep "does not exist" || exit 1
oc rsh -n $NAMESPACE ${controller_pod} ovs-vsctl --if-exists get open . external_ids:ovn-bridge-mappings | grep "datacentre2:br-datacentre2" && exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ commands:
oc patch OVNController -n $NAMESPACE ovncontroller-sample --type='json' -p='[{
"op": "replace",
"path": "/spec/nicMappings",
"value":{"datacentre3":"ospbr3"}
"value":{"data-centre3":"ospbr3"}
}]'

0 comments on commit 6d6cd21

Please sign in to comment.