@@ -1806,7 +1806,6 @@ var _ = framework.SIGDescribe("node")(framework.WithLabel("DRA"), func() {
1806
1806
createdTaint := b .Create (ctx , taint )
1807
1807
taint = createdTaint [0 ].(* resourcealphaapi.DeviceTaintRule )
1808
1808
gomega .Expect (* taint ).Should (gomega .HaveField ("Spec.Taint.TimeAdded.Time" , gomega .BeTemporally ("~" , time .Now (), time .Minute /* allow for some clock drift and delays */ )))
1809
-
1810
1809
framework .ExpectNoError (e2epod .WaitForPodTerminatingInNamespaceTimeout (ctx , f .ClientSet , pod .Name , f .Namespace .Name , f .Timeouts .PodStart ))
1811
1810
pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , pod .Name , metav1.GetOptions {})
1812
1811
framework .ExpectNoError (err , "get pod" )
@@ -1820,6 +1819,177 @@ var _ = framework.SIGDescribe("node")(framework.WithLabel("DRA"), func() {
1820
1819
})
1821
1820
})
1822
1821
1822
+ framework .Context (f .WithFeatureGate (features .DRAExtendedResource ), func () {
1823
+ nodes := drautils .NewNodes (f , 1 , 1 )
1824
+ driver := drautils .NewDriver (f , nodes , drautils .NetworkResources (10 , false ))
1825
+ b := drautils .NewBuilder (f , driver )
1826
+ b .UseExtendedResourceName = true
1827
+
1828
+ ginkgo .It ("must run a pod with extended resource with one container one resource" , func (ctx context.Context ) {
1829
+ pod := b .Pod ()
1830
+ res := v1.ResourceList {}
1831
+ res [v1 .ResourceName (drautils .ExtendedResourceName (0 ))] = resource .MustParse ("1" )
1832
+ pod .Spec .Containers [0 ].Resources .Requests = res
1833
+ pod .Spec .Containers [0 ].Resources .Limits = res
1834
+
1835
+ b .Create (ctx , pod )
1836
+ err := e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod )
1837
+ framework .ExpectNoError (err , "start pod" )
1838
+ containerEnv := []string {
1839
+ "container_0_request_0" , "true" ,
1840
+ }
1841
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [0 ].Name , false , containerEnv ... )
1842
+ })
1843
+
1844
+ ginkgo .It ("must run a pod with extended resource with one container three resources" , func (ctx context.Context ) {
1845
+ pod := b .Pod ()
1846
+ res := v1.ResourceList {}
1847
+ for i := range 3 {
1848
+ res [v1 .ResourceName (drautils .ExtendedResourceName (i ))] = resource .MustParse ("1" )
1849
+ }
1850
+ pod .Spec .Containers [0 ].Resources .Requests = res
1851
+ pod .Spec .Containers [0 ].Resources .Limits = res
1852
+
1853
+ b .Create (ctx , pod )
1854
+ err := e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod )
1855
+ framework .ExpectNoError (err , "start pod" )
1856
+ containerEnv := []string {
1857
+ "container_0_request_0" , "true" ,
1858
+ "container_0_request_1" , "true" ,
1859
+ "container_0_request_2" , "true" ,
1860
+ }
1861
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [0 ].Name , false , containerEnv ... )
1862
+ })
1863
+ ginkgo .It ("must run a pod with extended resource with three containers one resource each" , func (ctx context.Context ) {
1864
+ pod := b .Pod ()
1865
+ pod .Spec .Containers = append (pod .Spec .Containers , * pod .Spec .Containers [0 ].DeepCopy ())
1866
+ pod .Spec .Containers = append (pod .Spec .Containers , * pod .Spec .Containers [0 ].DeepCopy ())
1867
+ pod .Spec .Containers [0 ].Name = "container0"
1868
+ pod .Spec .Containers [1 ].Name = "container1"
1869
+ pod .Spec .Containers [2 ].Name = "container2"
1870
+
1871
+ for i := range 3 {
1872
+ res := v1.ResourceList {}
1873
+ res [v1 .ResourceName (drautils .ExtendedResourceName (i ))] = resource .MustParse ("1" )
1874
+ pod .Spec .Containers [i ].Resources .Requests = res
1875
+ pod .Spec .Containers [i ].Resources .Limits = res
1876
+ }
1877
+
1878
+ b .Create (ctx , pod )
1879
+ err := e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod )
1880
+ framework .ExpectNoError (err , "start pod" )
1881
+ for i := range 3 {
1882
+ containerEnv := []string {
1883
+ fmt .Sprintf ("container_%d_request_0" , i ), "true" ,
1884
+ }
1885
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [i ].Name , false , containerEnv ... )
1886
+ }
1887
+ })
1888
+ ginkgo .It ("must run a pod with extended resource with three containers multiple resources each" , func (ctx context.Context ) {
1889
+ pod := b .Pod ()
1890
+ pod .Spec .Containers = append (pod .Spec .Containers , * pod .Spec .Containers [0 ].DeepCopy ())
1891
+ pod .Spec .Containers = append (pod .Spec .Containers , * pod .Spec .Containers [0 ].DeepCopy ())
1892
+ pod .Spec .Containers [0 ].Name = "container0"
1893
+ pod .Spec .Containers [1 ].Name = "container1"
1894
+ pod .Spec .Containers [2 ].Name = "container2"
1895
+
1896
+ res := v1.ResourceList {}
1897
+ res [v1 .ResourceName (drautils .ExtendedResourceName (0 ))] = resource .MustParse ("1" )
1898
+ pod .Spec .Containers [0 ].Resources .Requests = res
1899
+ pod .Spec .Containers [0 ].Resources .Limits = res
1900
+ res = v1.ResourceList {}
1901
+ res [v1 .ResourceName (drautils .ExtendedResourceName (1 ))] = resource .MustParse ("1" )
1902
+ res [v1 .ResourceName (drautils .ExtendedResourceName (2 ))] = resource .MustParse ("1" )
1903
+ pod .Spec .Containers [1 ].Resources .Requests = res
1904
+ pod .Spec .Containers [1 ].Resources .Limits = res
1905
+ res = v1.ResourceList {}
1906
+ res [v1 .ResourceName (drautils .ExtendedResourceName (3 ))] = resource .MustParse ("1" )
1907
+ res [v1 .ResourceName (drautils .ExtendedResourceName (4 ))] = resource .MustParse ("1" )
1908
+ res [v1 .ResourceName (drautils .ExtendedResourceName (5 ))] = resource .MustParse ("1" )
1909
+ pod .Spec .Containers [2 ].Resources .Requests = res
1910
+ pod .Spec .Containers [2 ].Resources .Limits = res
1911
+
1912
+ b .Create (ctx , pod )
1913
+ err := e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod )
1914
+ framework .ExpectNoError (err , "start pod" )
1915
+ containerEnv := []string {
1916
+ "container_0_request_0" , "true" ,
1917
+ }
1918
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [0 ].Name , false , containerEnv ... )
1919
+ containerEnv = []string {
1920
+ "container_1_request_0" , "true" ,
1921
+ "container_1_request_1" , "true" ,
1922
+ }
1923
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [1 ].Name , false , containerEnv ... )
1924
+ containerEnv = []string {
1925
+ "container_2_request_0" , "true" ,
1926
+ "container_2_request_1" , "true" ,
1927
+ "container_2_request_2" , "true" ,
1928
+ }
1929
+ drautils .TestContainerEnv (ctx , f , pod , pod .Spec .Containers [2 ].Name , false , containerEnv ... )
1930
+ })
1931
+ })
1932
+
1933
+ framework .Context (f .WithFeatureGate (features .DRAExtendedResource ), func () {
1934
+ nodes := drautils .NewNodes (f , 2 , 2 )
1935
+ nodes .NumReservedNodes = 1
1936
+ driver := drautils .NewDriver (f , nodes , drautils .NetworkResources (2 , false ))
1937
+ b := drautils .NewBuilder (f , driver )
1938
+ b .UseExtendedResourceName = true
1939
+
1940
+ // This test needs the entire test cluster for itself, one node in the cluster
1941
+ // is deployed device plugin for the test, therefore it is marked as serial.
1942
+ // The test runs two pods, one pod request extended resource backed by DRA,
1943
+ // the other pod requests extended resource by device plugin.
1944
+ f .It ("must run pods with extended resource on dra nodes and device plugin nodes" , f .WithSerial (), func (ctx context.Context ) {
1945
+ extendedResourceName := deployDevicePlugin (ctx , f , nodes .ExtraNodeNames )
1946
+ // drautils.ExtendedResourceName(-1) must be the same as the returned extendedResourceName
1947
+ // drautils.ExtendedResourceName(-1) is used for DRA drivers
1948
+ // extendedResourceName is used for device plugin.
1949
+ gomega .Expect (string (extendedResourceName )).To (gomega .Equal (drautils .ExtendedResourceName (- 1 )))
1950
+
1951
+ pod1 := b .Pod ()
1952
+ res := v1.ResourceList {}
1953
+ res [v1 .ResourceName (drautils .ExtendedResourceName (- 1 ))] = resource .MustParse ("2" )
1954
+ pod1 .Spec .Containers [0 ].Resources .Requests = res
1955
+ pod1 .Spec .Containers [0 ].Resources .Limits = res
1956
+ b .Create (ctx , pod1 )
1957
+
1958
+ pod2 := b .Pod ()
1959
+ pod2 .Spec .Containers [0 ].Resources .Requests = res
1960
+ pod2 .Spec .Containers [0 ].Resources .Limits = res
1961
+ b .Create (ctx , pod2 )
1962
+
1963
+ err := e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod1 )
1964
+ framework .ExpectNoError (err , "start pod1" )
1965
+ err = e2epod .WaitForPodRunningInNamespace (ctx , f .ClientSet , pod2 )
1966
+ framework .ExpectNoError (err , "start pod2" )
1967
+
1968
+ scheduledPod1 , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , pod1 .Name , metav1.GetOptions {})
1969
+ gomega .Expect (scheduledPod1 ).ToNot (gomega .BeNil ())
1970
+ framework .ExpectNoError (err )
1971
+
1972
+ scheduledPod2 , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , pod2 .Name , metav1.GetOptions {})
1973
+ gomega .Expect (scheduledPod2 ).ToNot (gomega .BeNil ())
1974
+ framework .ExpectNoError (err )
1975
+
1976
+ draPod := scheduledPod1
1977
+ devicePluginPod := scheduledPod2
1978
+ if scheduledPod1 .Spec .NodeName == nodes .ExtraNodeNames [0 ] {
1979
+ draPod = scheduledPod2
1980
+ devicePluginPod = scheduledPod1
1981
+ }
1982
+
1983
+ gomega .Expect (devicePluginPod .Spec .NodeName ).To (gomega .Equal (nodes .ExtraNodeNames [0 ]))
1984
+ gomega .Expect (devicePluginPod .Status .ExtendedResourceClaimStatus ).To (gomega .BeNil ())
1985
+ gomega .Expect (draPod .Spec .NodeName ).To (gomega .Equal (nodes .NodeNames [0 ]))
1986
+ containerEnv := []string {
1987
+ "container_0_request_0" , "true" ,
1988
+ }
1989
+ drautils .TestContainerEnv (ctx , f , draPod , draPod .Spec .Containers [0 ].Name , false , containerEnv ... )
1990
+ })
1991
+ })
1992
+
1823
1993
ginkgo .Context ("ResourceSlice Controller" , func () {
1824
1994
// This is a stress test for creating many large slices.
1825
1995
// Each slice is as large as API limits allow.
0 commit comments