Skip to content

Commit cb292ec

Browse files
committed
Fix remaining loop devices manipulations in NodeSetup E2Es
1 parent 183c53d commit cb292ec

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

test/e2e/set/nodeconfig/nodeconfig_disksetup.go

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
4040
f := framework.NewFramework("nodesetup")
4141

4242
ncTemplate := scyllafixture.NodeConfig.ReadOrFail()
43-
var matchingNodes []*corev1.Node
43+
var nodeUnderTest *corev1.Node
4444

4545
g.JustBeforeEach(func() {
4646
ctx, cancel := context.WithCancel(context.Background())
4747
defer cancel()
4848

4949
g.By("Verifying there is at least one scylla node")
5050
var err error
51-
matchingNodes, err = utils.GetMatchingNodesForNodeConfig(ctx, f.KubeAdminClient().CoreV1(), ncTemplate)
51+
matchingNodes, err := utils.GetMatchingNodesForNodeConfig(ctx, f.KubeAdminClient().CoreV1(), ncTemplate)
5252
o.Expect(err).NotTo(o.HaveOccurred())
5353
o.Expect(matchingNodes).NotTo(o.HaveLen(0))
54-
framework.Infof("There are %d scylla nodes", len(matchingNodes))
54+
nodeUnderTest = matchingNodes[0]
55+
framework.Infof("There are %d scylla nodes. %s will be used in tests.", len(matchingNodes), nodeUnderTest.GetName())
5556
})
5657

5758
g.DescribeTable("should make RAID0 array out of loop devices, format it to XFS, and mount at desired location", func(numberOfDevices int) {
@@ -61,7 +62,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
6162
nc := ncTemplate.DeepCopy()
6263

6364
framework.By("Creating a client Pod")
64-
clientPod := newClientPod(nc)
65+
clientPod := newClientPod(nc, nodeUnderTest)
6566

6667
clientPod, err := f.KubeClient().CoreV1().Pods(f.Namespace()).Create(ctx, clientPod, metav1.CreateOptions{})
6768
o.Expect(err).NotTo(o.HaveOccurred())
@@ -258,7 +259,6 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
258259
defer cancel()
259260

260261
nc := e.nodeConfigFunc()
261-
nodeUnderTest := matchingNodes[0]
262262

263263
if e.preNodeConfigCreationFunc != nil {
264264
cleanupFunc := e.preNodeConfigCreationFunc(ctx, nc, nodeUnderTest)
@@ -408,7 +408,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
408408
hostMountPath := fmt.Sprintf("/host/var/lib/%s", f.Namespace())
409409

410410
framework.By("Creating a client Pod")
411-
clientPod := newClientPod(nc)
411+
clientPod := newClientPod(nc, nodeUnderTest)
412412
clientPod.Spec.NodeName = nodeUnderTest.GetName()
413413

414414
clientPod, err := f.KubeClient().CoreV1().Pods(f.Namespace()).Create(ctx, clientPod, metav1.CreateOptions{})
@@ -468,7 +468,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
468468
hostDevicePath := "/host/dev/loops/disk"
469469

470470
framework.By("Creating a client Pod")
471-
clientPod := newClientPod(nc)
471+
clientPod := newClientPod(nc, nodeUnderTest)
472472
clientPod.Spec.NodeName = nodeUnderTest.GetName()
473473

474474
clientPod, err := f.KubeClient().CoreV1().Pods(f.Namespace()).Create(ctx, clientPod, metav1.CreateOptions{})
@@ -530,11 +530,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
530530
}),
531531
)
532532

533-
g.It("should successfully start a failed mount unit with a corrupted filesystem when it's overwritten with a clean one", func(ctx context.Context) {
534-
o.Expect(matchingNodes).NotTo(o.BeEmpty())
535-
o.Expect(matchingNodes[0]).NotTo(o.BeNil())
536-
nodeUnderTest := matchingNodes[0]
537-
533+
g.FIt("should successfully start a failed mount unit with a corrupted filesystem when it's overwritten with a clean one", func(ctx context.Context) {
538534
devicePath := fmt.Sprintf("/dev/loops/%s", f.Namespace())
539535
hostDevicePath := path.Join("/host", devicePath)
540536

@@ -573,7 +569,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
573569
o.Expect(err).NotTo(o.HaveOccurred())
574570

575571
framework.By("Creating a client Pod")
576-
clientPod := newClientPod(nc)
572+
clientPod := newClientPod(nc, nodeUnderTest)
577573

578574
clientPod, err = f.KubeClient().CoreV1().Pods(f.Namespace()).Create(ctx, clientPod, metav1.CreateOptions{})
579575
o.Expect(err).NotTo(o.HaveOccurred())
@@ -607,7 +603,6 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
607603
framework.By("Getting the filesystem's block size")
608604
stdout, stderr, err = executeInPod(ctx, f.ClientConfig(), f.KubeClient().CoreV1(), clientPod, "stat", "--file-system", "--format=%s", devicePathInContainer)
609605
o.Expect(err).NotTo(o.HaveOccurred(), stdout, stderr)
610-
611606
blockSize := strings.TrimSpace(stdout)
612607

613608
framework.By("Corrupting the filesystem")
@@ -647,15 +642,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
647642
o.Expect(err).NotTo(o.HaveOccurred())
648643

649644
framework.By("Overwriting the corrupted filesystem")
650-
stdout, stderr, err = executeInPod(ctx, f.ClientConfig(), f.KubeClient().CoreV1(), clientPod, "mkfs", "-t", string(scyllav1alpha1.XFSFilesystem), "-b", fmt.Sprintf("size=%s", blockSize), "-K", "-f", hostDevicePath)
651-
o.Expect(err).NotTo(o.HaveOccurred(), stdout, stderr)
652-
653-
framework.By("Zeroing XFS log")
654-
stdout, stderr, err = executeInPod(ctx, f.ClientConfig(), f.KubeClient().CoreV1(), clientPod, "xfs_repair", "-L", "-f", hostDevicePath)
655-
o.Expect(err).NotTo(o.HaveOccurred(), stdout, stderr)
656-
657-
framework.By("Verifying the filesystem's integrity")
658-
stdout, stderr, err = executeInPod(ctx, f.ClientConfig(), f.KubeClient().CoreV1(), clientPod, "xfs_repair", "-o", "force_geometry", "-f", "-n", hostDevicePath)
645+
stdout, stderr, err = executeInPod(ctx, f.ClientConfig(), f.KubeClient().CoreV1(), clientPod, "mkfs", "-t", string(scyllav1alpha1.XFSFilesystem), "-b", fmt.Sprintf("size=%s", blockSize), "-K", "-f", devicePathInContainer)
659646
o.Expect(err).NotTo(o.HaveOccurred(), stdout, stderr)
660647

661648
framework.By("Waiting for NodeConfig to roll out")
@@ -702,12 +689,15 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
702689
}, g.NodeTimeout(testTimeout))
703690
})
704691

705-
func newClientPod(nc *scyllav1alpha1.NodeConfig) *corev1.Pod {
692+
func newClientPod(nc *scyllav1alpha1.NodeConfig, nodeUnderTest *corev1.Node) *corev1.Pod {
706693
return &corev1.Pod{
707694
ObjectMeta: metav1.ObjectMeta{
708695
Name: "client",
709696
},
710697
Spec: corev1.PodSpec{
698+
// We want to schedule the Pod specifically on the node that is under test as we will perform operations
699+
// on the host filesystem through that Pod.
700+
NodeName: nodeUnderTest.Name,
711701
Containers: []corev1.Container{
712702
{
713703
Name: "client",

0 commit comments

Comments
 (0)