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

OCPBUGS-45893: Allows for backwards compatibility with upcoming network name change #29525

Merged
Merged
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
46 changes: 35 additions & 11 deletions test/extended/networking/network_segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1538,17 +1538,29 @@ func assertNetAttachDefManifest(nadClient nadclient.K8sCniCncfIoV1Interface, nam
BlockOwnerDeletion: pointer.Bool(true),
Controller: pointer.Bool(true),
}}))
expectedNetworkName := namespace + "." + udnName
expectedNadName := namespace + "/" + udnName
ExpectWithOffset(1, nad.Spec.Config).To(MatchJSON(`{

jsonTemplate := `{
"cniVersion":"1.0.0",
"type": "ovn-k8s-cni-overlay",
"name": "` + expectedNetworkName + `",
"netAttachDefName": "` + expectedNadName + `",
"name": "%s",
"netAttachDefName": "%s",
"topology": "layer2",
"role": "secondary",
"subnets": "10.100.0.0/16"
}`))
}`

// REMOVEME(trozet): after network name has been updated to use underscores in OVNK
expectedLegacyNetworkName := namespace + "." + udnName
expectedNetworkName := namespace + "_" + udnName
expectedNadName := namespace + "/" + udnName

nadJSONLegacy := fmt.Sprintf(jsonTemplate, expectedLegacyNetworkName, expectedNadName)
nadJSON := fmt.Sprintf(jsonTemplate, expectedNetworkName, expectedNadName)

ExpectWithOffset(1, nad.Spec.Config).To(SatisfyAny(
MatchJSON(nadJSONLegacy),
MatchJSON(nadJSON),
))
}

func validateUDNStatusReportsConsumers(client dynamic.Interface, udnNamesapce, udnName, expectedPodName string) error {
Expand Down Expand Up @@ -1608,17 +1620,29 @@ func assertClusterNADManifest(nadClient nadclient.K8sCniCncfIoV1Interface, names
ExpectWithOffset(1, nad.Labels).To(Equal(map[string]string{"k8s.ovn.org/user-defined-network": ""}))
ExpectWithOffset(1, nad.Finalizers).To(Equal([]string{"k8s.ovn.org/user-defined-network-protection"}))

expectedNetworkName := "cluster.udn." + udnName
// REMOVEME(trozet): after network name has been updated to use underscores in OVNK
expectedLegacyNetworkName := "cluster.udn." + udnName

expectedNetworkName := "cluster_udn_" + udnName
expectedNadName := namespace + "/" + udnName
ExpectWithOffset(1, nad.Spec.Config).To(MatchJSON(`{

jsonTemplate := `{
"cniVersion":"1.0.0",
"type": "ovn-k8s-cni-overlay",
"name": "` + expectedNetworkName + `",
"netAttachDefName": "` + expectedNadName + `",
"name": "%s",
"netAttachDefName": "%s",
"topology": "layer2",
"role": "secondary",
"subnets": "10.100.0.0/16"
}`))
}`

nadJSONLegacy := fmt.Sprintf(jsonTemplate, expectedLegacyNetworkName, expectedNadName)
nadJSON := fmt.Sprintf(jsonTemplate, expectedNetworkName, expectedNadName)

ExpectWithOffset(1, nad.Spec.Config).To(SatisfyAny(
MatchJSON(nadJSONLegacy),
MatchJSON(nadJSON),
))
}

func validateClusterUDNStatusReportsActiveNamespacesFunc(client dynamic.Interface, cUDNName string, expectedActiveNsNames ...string) func() error {
Expand Down