@@ -25,7 +25,10 @@ import (
25
25
v1 "k8s.io/api/core/v1"
26
26
27
27
"k8s.io/apimachinery/pkg/util/sets"
28
+ utilfeature "k8s.io/apiserver/pkg/util/feature"
29
+ featuregatetesting "k8s.io/component-base/featuregate/testing"
28
30
_ "k8s.io/kubernetes/pkg/apis/core/install"
31
+ "k8s.io/kubernetes/pkg/features"
29
32
30
33
"reflect"
31
34
"strings"
@@ -661,6 +664,7 @@ func TestMakeAbsolutePath(t *testing.T) {
661
664
}
662
665
663
666
func TestGetPodVolumeNames (t * testing.T ) {
667
+ defer featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .EphemeralContainers , true )()
664
668
tests := []struct {
665
669
name string
666
670
pod * v1.Pod
@@ -822,6 +826,48 @@ func TestGetPodVolumeNames(t *testing.T) {
822
826
expectedMounts : sets .NewString ("vol1" , "vol3" ),
823
827
expectedDevices : sets .NewString ("vol2" , "vol4" ),
824
828
},
829
+ {
830
+ name : "pod with ephemeral containers" ,
831
+ pod : & v1.Pod {
832
+ Spec : v1.PodSpec {
833
+ Containers : []v1.Container {
834
+ {
835
+ Name : "container1" ,
836
+ VolumeMounts : []v1.VolumeMount {
837
+ {
838
+ Name : "vol1" ,
839
+ },
840
+ },
841
+ },
842
+ },
843
+ EphemeralContainers : []v1.EphemeralContainer {
844
+ {
845
+ EphemeralContainerCommon : v1.EphemeralContainerCommon {
846
+ Name : "debugger" ,
847
+ VolumeMounts : []v1.VolumeMount {
848
+ {
849
+ Name : "vol1" ,
850
+ },
851
+ {
852
+ Name : "vol2" ,
853
+ },
854
+ },
855
+ },
856
+ },
857
+ },
858
+ Volumes : []v1.Volume {
859
+ {
860
+ Name : "vol1" ,
861
+ },
862
+ {
863
+ Name : "vol2" ,
864
+ },
865
+ },
866
+ },
867
+ },
868
+ expectedMounts : sets .NewString ("vol1" , "vol2" ),
869
+ expectedDevices : sets .NewString (),
870
+ },
825
871
}
826
872
827
873
for _ , test := range tests {
0 commit comments