Skip to content

Commit

Permalink
Merge pull request #1443 from zimnx/mz/multi-node-orphaned-pv-e2e
Browse files Browse the repository at this point in the history
Enable orphaned PV e2e test on envs with multiple Nodes
  • Loading branch information
scylla-operator-bot[bot] authored Oct 5, 2023
2 parents af9002f + a79360d commit 750234a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions test/e2e/set/scyllacluster/scyllacluster_pv.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,26 @@ var _ = g.Describe("ScyllaCluster Orphaned PV controller", func() {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()

nodes, err := f.KubeAdminClient().CoreV1().Nodes().List(ctx, metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

if len(nodes.Items) != 1 {
g.Skip(
"This test supports running at most 1 Node, as it relies on the fact that all Pods land on the same Node." +
"Replace with actual Node removal logic when CI env is bigger",
)
}

testStorageClassName := f.Namespace()

sc := scyllafixture.BasicScyllaCluster.ReadOrFail()
sc.Spec.AutomaticOrphanedNodeCleanup = true
sc.Spec.Datacenter.Racks[0].Members = 3
sc.Spec.Datacenter.Racks[0].Storage.StorageClassName = pointer.Ptr(testStorageClassName)
sc.Spec.Datacenter.Racks[0].Placement = &scyllav1.PlacementSpec{
PodAffinity: &corev1.PodAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
cloneLabelKey: f.Namespace(),
},
},
TopologyKey: corev1.LabelHostname,
},
},
},
}

// This test to trigger the orphaned PV cleanup is updating NodeAffinity of PV used by ScyllaCluster to not exiting Node.
// The problem is, that local volume storage provisioners which we use in CI, may set this field, which is immutable.
Expand Down Expand Up @@ -138,14 +142,17 @@ var _ = g.Describe("ScyllaCluster Orphaned PV controller", func() {
pvcClone.Spec.StorageClassName = nil

framework.Infof("Creating clone PVC for %q", pvc.Name)
pvcClone, err = f.KubeClient().CoreV1().PersistentVolumeClaims(f.Namespace()).Create(ctx, pvcClone, metav1.CreateOptions{})
pvcClone, err := f.KubeClient().CoreV1().PersistentVolumeClaims(f.Namespace()).Create(ctx, pvcClone, metav1.CreateOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

framework.Infof("Creating PVC clone consumer Pod")
consumerPodName := fmt.Sprintf("consumer-%s", pvcClone.Name)
consumerPod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: consumerPodName,
Labels: map[string]string{
cloneLabelKey: f.Namespace(),
},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand Down Expand Up @@ -256,7 +263,7 @@ var _ = g.Describe("ScyllaCluster Orphaned PV controller", func() {
}()

framework.By("Creating a ScyllaCluster")
sc, err = f.ScyllaClient().ScyllaV1().ScyllaClusters(f.Namespace()).Create(ctx, sc, metav1.CreateOptions{})
sc, err := f.ScyllaClient().ScyllaV1().ScyllaClusters(f.Namespace()).Create(ctx, sc, metav1.CreateOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

framework.By("Waiting for the ScyllaCluster to rollout (RV=%s)", sc.ResourceVersion)
Expand Down

0 comments on commit 750234a

Please sign in to comment.