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

[release-4.18] OCPBUGS-48389: only provision workloads when network creation has started #29413

Open
wants to merge 6 commits into
base: release-4.18
Choose a base branch
from
Prev Previous commit
Next Next commit
virt, persistent ips: figure out provisioned network name
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb authored and openshift-cherrypick-robot committed Jan 9, 2025
commit 5fbeeec78c483e63f3866b8927ffd2158090dce7
27 changes: 22 additions & 5 deletions test/extended/networking/livemigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F
)

DescribeTableSubtree("created using",
func(createNetworkFn func(netConfig networkAttachmentConfigParams)) {
func(createNetworkFn func(netConfig networkAttachmentConfigParams) networkAttachmentConfig) {

DescribeTable("[Suite:openshift/network/virtualization] should keep ip", func(netConfig networkAttachmentConfigParams, vmResource string, opCmd func(cli *kubevirt.Client, vmNamespace, vmName string)) {
var err error
Expand All @@ -79,11 +79,11 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F

isDualStack := getIPFamilyForCluster(f) == DualStack

createNetworkFn(netConfig)
provisionedNetConfig := createNetworkFn(netConfig)

for _, node := range workerNodes {
Eventually(func() bool {
isNetProvisioned, err := isNetworkProvisioned(oc, node.Name, netConfig.networkName)
isNetProvisioned, err := isNetworkProvisioned(oc, node.Name, provisionedNetConfig.networkName)
return err == nil && isNetProvisioned
}).WithPolling(time.Second).WithTimeout(udnCrReadyTimeout).Should(
BeTrueBecause("the network must be ready before creating workloads"),
Expand Down Expand Up @@ -194,18 +194,25 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F
restartVM,
))
},
Entry("NetworkAttachmentDefinitions", func(c networkAttachmentConfigParams) {
Entry("NetworkAttachmentDefinitions", func(c networkAttachmentConfigParams) networkAttachmentConfig {
netConfig := newNetworkAttachmentConfig(c)
nad := generateNAD(netConfig)
By(fmt.Sprintf("Creating NetworkAttachmentDefinitions %s/%s", nad.Namespace, nad.Name))
_, err := nadClient.NetworkAttachmentDefinitions(c.namespace).Create(context.Background(), nad, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
return netConfig
}),
Entry("UserDefinedNetwork", func(c networkAttachmentConfigParams) {
Entry("UserDefinedNetwork", func(c networkAttachmentConfigParams) networkAttachmentConfig {
udnManifest := generateUserDefinedNetworkManifest(&c)
By(fmt.Sprintf("Creating UserDefinedNetwork %s/%s", c.namespace, c.name))
Expect(applyManifest(c.namespace, udnManifest)).To(Succeed())
Expect(waitForUserDefinedNetworkReady(c.namespace, c.name, udnCrReadyTimeout)).To(Succeed())

nad, err := nadClient.NetworkAttachmentDefinitions(c.namespace).Get(
context.Background(), c.name, metav1.GetOptions{},
)
Expect(err).NotTo(HaveOccurred())
return networkAttachmentConfig{networkAttachmentConfigParams{networkName: networkName(nad.Spec.Config)}}
}))
})
})
Expand Down Expand Up @@ -540,3 +547,13 @@ func logicalSwitchName(networkName string) string {
netName = strings.ReplaceAll(netName, "/", ".")
return fmt.Sprintf("%s_ovn_layer2_switch", netName)
}

func networkName(netSpecConfig string) string {
GinkgoHelper()
type netConfig struct {
Name string `json:"name,omitempty"`
}
var nc netConfig
Expect(json.Unmarshal([]byte(netSpecConfig), &nc)).To(Succeed())
return nc.Name
}