@@ -298,7 +298,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount", func() {
298
298
// Act
299
299
ginkgo .By ("Starting the initial pod" )
300
300
accessModes := []v1.PersistentVolumeAccessMode {t .volumeMode }
301
- _ , claim , pod := m .createPodWithSELinux (ctx , accessModes , t .mountOptions , t .firstPodSELinuxOpts , t .firstPodChangePolicy )
301
+ _ , claim , pod := m .createPodWithSELinux (ctx , accessModes , t .mountOptions , t .firstPodSELinuxOpts , t .firstPodChangePolicy , false /* privileged */ )
302
302
err := e2epod .WaitForPodNameRunningInNamespace (ctx , m .cs , pod .Name , pod .Namespace )
303
303
framework .ExpectNoError (err , "starting the initial pod" )
304
304
@@ -331,7 +331,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount", func() {
331
331
pod , err = m .cs .CoreV1 ().Pods (pod .Namespace ).Get (ctx , pod .Name , metav1.GetOptions {})
332
332
framework .ExpectNoError (err , "getting the initial pod" )
333
333
nodeSelection := e2epod.NodeSelection {Name : pod .Spec .NodeName }
334
- pod2 , err := startPausePodWithSELinuxOptions (f .ClientSet , claim , nodeSelection , f .Namespace .Name , t .secondPodSELinuxOpts , t .secondPodChangePolicy )
334
+ pod2 , err := startPausePodWithSELinuxOptions (f .ClientSet , claim , nodeSelection , f .Namespace .Name , t .secondPodSELinuxOpts , t .secondPodChangePolicy , false /* privileged */ )
335
335
framework .ExpectNoError (err , "creating second pod with SELinux context %s" , t .secondPodSELinuxOpts )
336
336
m .pods = append (m .pods , pod2 )
337
337
@@ -453,8 +453,10 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
453
453
csiDriverSELinuxEnabled bool
454
454
firstPodSELinuxOpts * v1.SELinuxOptions
455
455
firstPodChangePolicy * v1.PodSELinuxChangePolicy
456
+ firstPodPrivileged bool
456
457
secondPodSELinuxOpts * v1.SELinuxOptions
457
458
secondPodChangePolicy * v1.PodSELinuxChangePolicy
459
+ secondPodPrivileged bool
458
460
volumeMode v1.PersistentVolumeAccessMode
459
461
waitForSecondPodStart bool
460
462
secondPodFailureEvent string
@@ -599,7 +601,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
599
601
testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
600
602
},
601
603
{
602
- name : "error is not bumped on two Pods with a different policy RWX volume (nil + MountOption)" ,
604
+ name : "error is not bumped on two Pods with the same policy RWX volume (nil + MountOption)" ,
603
605
csiDriverSELinuxEnabled : true ,
604
606
firstPodSELinuxOpts : & seLinuxOpts1 ,
605
607
firstPodChangePolicy : & mount ,
@@ -611,7 +613,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
611
613
testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
612
614
},
613
615
{
614
- name : "error is not bumped on two Pods with a different policy RWX volume (MountOption + MountOption)" ,
616
+ name : "error is not bumped on two Pods with the same policy RWX volume (MountOption + MountOption)" ,
615
617
csiDriverSELinuxEnabled : true ,
616
618
firstPodSELinuxOpts : & seLinuxOpts1 ,
617
619
firstPodChangePolicy : & mount ,
@@ -648,6 +650,75 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
648
650
expectControllerConflictProperty : "SELinuxLabel" ,
649
651
testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
650
652
},
653
+ {
654
+ name : "error is not bumped on two privileged Pods with mount policy RWO volume" ,
655
+ csiDriverSELinuxEnabled : true ,
656
+ firstPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
657
+ firstPodPrivileged : true ,
658
+ firstPodChangePolicy : & recursive ,
659
+ secondPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
660
+ secondPodPrivileged : true ,
661
+ secondPodChangePolicy : & recursive ,
662
+ volumeMode : v1 .ReadWriteOnce ,
663
+ waitForSecondPodStart : true ,
664
+ expectNodeIncreases : sets .New [string ]( /* no metric is increased, admitted_total was already increased when the first pod started */ ),
665
+ testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
666
+ },
667
+ {
668
+ name : "error is not bumped on two privileged Pods with recursive policy RWO volume" ,
669
+ csiDriverSELinuxEnabled : true ,
670
+ firstPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
671
+ firstPodPrivileged : true ,
672
+ firstPodChangePolicy : & mount ,
673
+ secondPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
674
+ secondPodPrivileged : true ,
675
+ secondPodChangePolicy : & mount ,
676
+ volumeMode : v1 .ReadWriteOnce ,
677
+ waitForSecondPodStart : true ,
678
+ expectNodeIncreases : sets .New [string ]( /* no metric is increased, admitted_total was already increased when the first pod started */ ),
679
+ testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
680
+ },
681
+ {
682
+ name : "error is not bumped on a privileged and unprivileged Pod with given SELinux context and recursive policy" ,
683
+ csiDriverSELinuxEnabled : true ,
684
+ firstPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
685
+ firstPodPrivileged : true ,
686
+ secondPodSELinuxOpts : & seLinuxOpts1 ,
687
+ secondPodChangePolicy : & recursive ,
688
+ secondPodPrivileged : false ,
689
+ volumeMode : v1 .ReadWriteMany ,
690
+ waitForSecondPodStart : true ,
691
+ expectNodeIncreases : sets .New [string ]( /* no metric is increased, admitted_total was already increased when the first pod started */ ),
692
+ testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
693
+ },
694
+ {
695
+ name : "error is bumped on a privileged and unprivileged Pod with given SELinux with MountOption policy" ,
696
+ csiDriverSELinuxEnabled : true ,
697
+ firstPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
698
+ firstPodPrivileged : true ,
699
+ secondPodSELinuxOpts : & seLinuxOpts1 ,
700
+ secondPodChangePolicy : & mount ,
701
+ secondPodFailureEvent : "conflicting SELinux labels of volume" ,
702
+ volumeMode : v1 .ReadWriteOncePod ,
703
+ waitForSecondPodStart : false ,
704
+ expectNodeIncreases : sets.New [string ]("volume_manager_selinux_volume_context_mismatch_errors_total" ),
705
+ expectControllerConflictProperty : "SELinuxLabel" ,
706
+ testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
707
+ },
708
+ {
709
+ name : "error is bumped on an unprivileged and privileged Pod with given SELinux with MountOption policy" ,
710
+ csiDriverSELinuxEnabled : true ,
711
+ firstPodSELinuxOpts : & seLinuxOpts1 ,
712
+ firstPodChangePolicy : & mount ,
713
+ secondPodSELinuxOpts : nil , /* privileged Pods are typically without SELinux context */
714
+ secondPodPrivileged : true ,
715
+ secondPodFailureEvent : "conflicting SELinux labels of volume" ,
716
+ volumeMode : v1 .ReadWriteOncePod ,
717
+ waitForSecondPodStart : false ,
718
+ expectNodeIncreases : sets.New [string ]("volume_manager_selinux_volume_context_mismatch_errors_total" ),
719
+ expectControllerConflictProperty : "SELinuxLabel" ,
720
+ testTags : []interface {}{framework .WithFeatureGate (features .SELinuxMount )},
721
+ },
651
722
}
652
723
for _ , t := range tests {
653
724
t := t
@@ -673,7 +744,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
673
744
674
745
ginkgo .By ("Starting the first pod" )
675
746
accessModes := []v1.PersistentVolumeAccessMode {t .volumeMode }
676
- _ , claim , pod := m .createPodWithSELinux (ctx , accessModes , []string {}, t .firstPodSELinuxOpts , t .firstPodChangePolicy )
747
+ _ , claim , pod := m .createPodWithSELinux (ctx , accessModes , []string {}, t .firstPodSELinuxOpts , t .firstPodChangePolicy , t . firstPodPrivileged )
677
748
err = e2epod .WaitForPodNameRunningInNamespace (ctx , m .cs , pod .Name , pod .Namespace )
678
749
framework .ExpectNoError (err , "starting the initial pod" )
679
750
@@ -688,7 +759,7 @@ var _ = utils.SIGDescribe("CSI Mock selinux on mount metrics and SELinuxWarningC
688
759
ginkgo .By ("Starting the second pod" )
689
760
// Skip scheduler, it would block scheduling the second pod with ReadWriteOncePod PV.
690
761
nodeSelection := e2epod.NodeSelection {Name : pod .Spec .NodeName }
691
- pod2 , err := startPausePodWithSELinuxOptions (f .ClientSet , claim , nodeSelection , f .Namespace .Name , t .secondPodSELinuxOpts , t .secondPodChangePolicy )
762
+ pod2 , err := startPausePodWithSELinuxOptions (f .ClientSet , claim , nodeSelection , f .Namespace .Name , t .secondPodSELinuxOpts , t .secondPodChangePolicy , t . secondPodPrivileged )
692
763
framework .ExpectNoError (err , "creating second pod with SELinux context %s" , t .secondPodSELinuxOpts )
693
764
m .pods = append (m .pods , pod2 )
694
765
0 commit comments