Feature: pod affinity changes for OVN
Deploy OVN northd using the same pod affinity rules
used with the NB and SB statefulsets. Also change
default anti-affinity for NB and SB statefulsets
to requiredDuringSchedulingIgnoredDuringExecution
over preferredDuringSchedulingIgnoredDuringExecution
Change-Id: I844bbdc53fe10a8b8d9f017b9a3c68d93b695b98
Add unit tests to for OVN Anti-Affinity Rules
These unit tests go over all the statefulset and
deployment pods using the and make sure they are
all using the right anti-affinity rules.
Change-Id: I2c8b5bf7515040e715bdeed4410acf6656578133
(cherry picked from commit dea3c67d1904ce66de83056cc498a35bc3653e46)
diff --git a/internal/testutils/oslo_db.go b/internal/testutils/oslo_db.go
index 0b02304..3a9159d 100644
--- a/internal/testutils/oslo_db.go
+++ b/internal/testutils/oslo_db.go
@@ -5,6 +5,7 @@
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
"github.com/vexxhost/atmosphere/internal/openstack_helm"
)
@@ -43,3 +44,20 @@
assert.Contains(t, vals.Pod.PriorityClass, podName)
}
}
+
+func TestAllPodsHaveAntiAffinityType(t *testing.T, vals *openstack_helm.HelmValues) {
+ for pod := range vals.Pod.AntiAffinityType {
+ podName := podNameForClass(pod)
+
+ expected := "requiredDuringSchedulingIgnoredDuringExecution"
+
+ defaultRaw, ok := vals.Pod.AntiAffinityType["default"]
+ require.True(t, ok, "default key not found in affinity.anti.type block")
+
+ actual, ok := defaultRaw.(string)
+ require.True(t, ok, "default anti affinity type is not a string")
+
+ assert.Equal(t, expected, actual, "anti affinity type does not match expected value")
+ assert.Contains(t, vals.Pod.AntiAffinityType, podName)
+ }
+}