Use the same node for every PV creation
When we run tests with two PV's possible situation that we will create
PV with different node affinity, it will prevent from the VM to start.
@@ -181,6 +181,7 @@ const (
)
var testNamespaces = []string{NamespaceTestDefault, NamespaceTestAlternative}
+var schedulableNode = ""
type startType string
@@ -308,7 +309,7 @@ func (w *ObjectEventWatcher) Watch(abortChan chan struct{}, processFunc ProcessF
resourceVersion = w.resourceVersion
case watchSinceWatchedObjectUpdate:
var err error
- w.resourceVersion, err = meta.NewAccessor().ResourceVersion(w.object)
+ resourceVersion, err = meta.NewAccessor().ResourceVersion(w.object)
Expect(err).ToNot(HaveOccurred())
}
@@ -642,6 +643,9 @@ func BeforeTestSuitSetup() {
PanicOnError(err)
Eventually(func() int {
nodes := GetAllSchedulableNodes(virtClient)
+ if len(nodes.Items) > 0 {
+ schedulableNode = nodes.Items[0].Name
+ }
return len(nodes.Items)
}, 5*time.Minute, 10*time.Second).ShouldNot(BeZero(), "no schedulable nodes found")
@@ -810,11 +814,6 @@ func CreateHostPathPvWithSize(osName string, hostPath string, size string) {
hostPathType := k8sv1.HostPathDirectoryOrCreate
name := fmt.Sprintf("%s-disk-for-tests", osName)
-
- nodes := GetAllSchedulableNodes(virtCli)
- Expect(len(nodes.Items) > 0).To(BeTrue())
- nodeName := nodes.Items[0].Name
-
pv := &k8sv1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: name,
@@ -843,7 +842,7 @@ func CreateHostPathPvWithSize(osName string, hostPath string, size string) {
{
Key: "kubernetes.io/hostname",
Operator: k8sv1.NodeSelectorOpIn,
- Values: []string{nodeName},
+ Values: []string{schedulableNode},
},
},
},
@@ -1950,12 +1949,6 @@ func newBlockVolumePV(name string, labelSelector map[string]string, size string)
storageClass := Config.StorageClassBlockVolume
volumeMode := k8sv1.PersistentVolumeBlock
- virtCli, err := kubecli.GetKubevirtClient()
- PanicOnError(err)
-
- nodes := GetAllSchedulableNodes(virtCli)
- Expect(len(nodes.Items) > 0).To(BeTrue())
- nodeName := nodes.Items[0].Name
// Note: the path depends on kubevirtci!
// It's configured to have a device backed by a cirros image at exactly that place on node01
// And the local storage provider also has access to it
@@ -1984,7 +1977,7 @@ func newBlockVolumePV(name string, labelSelector map[string]string, size string)
{
Key: "kubernetes.io/hostname",
Operator: k8sv1.NodeSelectorOpIn,
- Values: []string{nodeName},
+ Values: []string{schedulableNode},
},
},
},
