@@ -40,18 +40,19 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
40
40
f := framework .NewFramework ("nodesetup" )
41
41
42
42
ncTemplate := scyllafixture .NodeConfig .ReadOrFail ()
43
- var matchingNodes [] * corev1.Node
43
+ var nodeUnderTest * corev1.Node
44
44
45
45
g .JustBeforeEach (func () {
46
46
ctx , cancel := context .WithCancel (context .Background ())
47
47
defer cancel ()
48
48
49
49
g .By ("Verifying there is at least one scylla node" )
50
50
var err error
51
- matchingNodes , err = utils .GetMatchingNodesForNodeConfig (ctx , f .KubeAdminClient ().CoreV1 (), ncTemplate )
51
+ matchingNodes , err : = utils .GetMatchingNodesForNodeConfig (ctx , f .KubeAdminClient ().CoreV1 (), ncTemplate )
52
52
o .Expect (err ).NotTo (o .HaveOccurred ())
53
53
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 ())
55
56
})
56
57
57
58
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() {
61
62
nc := ncTemplate .DeepCopy ()
62
63
63
64
framework .By ("Creating a client Pod" )
64
- clientPod := newClientPod (nc )
65
+ clientPod := newClientPod (nc , nodeUnderTest )
65
66
66
67
clientPod , err := f .KubeClient ().CoreV1 ().Pods (f .Namespace ()).Create (ctx , clientPod , metav1.CreateOptions {})
67
68
o .Expect (err ).NotTo (o .HaveOccurred ())
@@ -258,7 +259,6 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
258
259
defer cancel ()
259
260
260
261
nc := e .nodeConfigFunc ()
261
- nodeUnderTest := matchingNodes [0 ]
262
262
263
263
if e .preNodeConfigCreationFunc != nil {
264
264
cleanupFunc := e .preNodeConfigCreationFunc (ctx , nc , nodeUnderTest )
@@ -408,7 +408,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
408
408
hostMountPath := fmt .Sprintf ("/host/var/lib/%s" , f .Namespace ())
409
409
410
410
framework .By ("Creating a client Pod" )
411
- clientPod := newClientPod (nc )
411
+ clientPod := newClientPod (nc , nodeUnderTest )
412
412
clientPod .Spec .NodeName = nodeUnderTest .GetName ()
413
413
414
414
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() {
468
468
hostDevicePath := "/host/dev/loops/disk"
469
469
470
470
framework .By ("Creating a client Pod" )
471
- clientPod := newClientPod (nc )
471
+ clientPod := newClientPod (nc , nodeUnderTest )
472
472
clientPod .Spec .NodeName = nodeUnderTest .GetName ()
473
473
474
474
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() {
530
530
}),
531
531
)
532
532
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 ) {
538
534
devicePath := fmt .Sprintf ("/dev/loops/%s" , f .Namespace ())
539
535
hostDevicePath := path .Join ("/host" , devicePath )
540
536
@@ -573,7 +569,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
573
569
o .Expect (err ).NotTo (o .HaveOccurred ())
574
570
575
571
framework .By ("Creating a client Pod" )
576
- clientPod := newClientPod (nc )
572
+ clientPod := newClientPod (nc , nodeUnderTest )
577
573
578
574
clientPod , err = f .KubeClient ().CoreV1 ().Pods (f .Namespace ()).Create (ctx , clientPod , metav1.CreateOptions {})
579
575
o .Expect (err ).NotTo (o .HaveOccurred ())
@@ -607,7 +603,6 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
607
603
framework .By ("Getting the filesystem's block size" )
608
604
stdout , stderr , err = executeInPod (ctx , f .ClientConfig (), f .KubeClient ().CoreV1 (), clientPod , "stat" , "--file-system" , "--format=%s" , devicePathInContainer )
609
605
o .Expect (err ).NotTo (o .HaveOccurred (), stdout , stderr )
610
-
611
606
blockSize := strings .TrimSpace (stdout )
612
607
613
608
framework .By ("Corrupting the filesystem" )
@@ -647,15 +642,7 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
647
642
o .Expect (err ).NotTo (o .HaveOccurred ())
648
643
649
644
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 )
659
646
o .Expect (err ).NotTo (o .HaveOccurred (), stdout , stderr )
660
647
661
648
framework .By ("Waiting for NodeConfig to roll out" )
@@ -702,12 +689,15 @@ var _ = g.Describe("Node Setup", framework.Serial, func() {
702
689
}, g .NodeTimeout (testTimeout ))
703
690
})
704
691
705
- func newClientPod (nc * scyllav1alpha1.NodeConfig ) * corev1.Pod {
692
+ func newClientPod (nc * scyllav1alpha1.NodeConfig , nodeUnderTest * corev1. Node ) * corev1.Pod {
706
693
return & corev1.Pod {
707
694
ObjectMeta : metav1.ObjectMeta {
708
695
Name : "client" ,
709
696
},
710
697
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 ,
711
701
Containers : []corev1.Container {
712
702
{
713
703
Name : "client" ,
0 commit comments