@@ -71,6 +71,7 @@ import (
7171 testingtfjob "sigs.k8s.io/kueue/pkg/util/testingjobs/tfjob"
7272 testingtrainjob "sigs.k8s.io/kueue/pkg/util/testingjobs/trainjob"
7373 testingxgboostjob "sigs.k8s.io/kueue/pkg/util/testingjobs/xgboostjob"
74+ "sigs.k8s.io/kueue/pkg/workload"
7475 "sigs.k8s.io/kueue/pkg/workloadslicing"
7576 "sigs.k8s.io/kueue/test/integration/framework"
7677 "sigs.k8s.io/kueue/test/util"
@@ -1885,6 +1886,91 @@ var _ = ginkgo.Describe("MultiKueue", ginkgo.Label("area:multikueue", "feature:m
18851886 }, gomega .Equal (completedJobCondition ))))
18861887 })
18871888 })
1889+ ginkgo .It ("Should redo the admission process once the workload looses Admission in the worker cluster" , func () {
1890+ job := testingjob .MakeJob ("job" , managerNs .Name ).
1891+ ManagedBy (kueue .MultiKueueControllerName ).
1892+ Queue (kueue .LocalQueueName (managerLq .Name )).
1893+ Obj ()
1894+ util .MustCreate (managerTestCluster .ctx , managerTestCluster .client , job )
1895+
1896+ createdWorkload := & kueue.Workload {}
1897+ wlLookupKey := types.NamespacedName {Name : workloadjob .GetWorkloadNameForJob (job .Name , job .UID ), Namespace : managerNs .Name }
1898+
1899+ ginkgo .By ("setting workload reservation in the management cluster" , func () {
1900+ admission := utiltestingapi .MakeAdmission (managerCq .Name ).Obj ()
1901+ util .SetQuotaReservation (managerTestCluster .ctx , managerTestCluster .client , wlLookupKey , admission )
1902+ })
1903+
1904+ ginkgo .By ("checking the workload creation in the worker clusters" , func () {
1905+ managerWl := & kueue.Workload {}
1906+ gomega .Expect (managerTestCluster .client .Get (managerTestCluster .ctx , wlLookupKey , managerWl )).To (gomega .Succeed ())
1907+ gomega .Eventually (func (g gomega.Gomega ) {
1908+ g .Expect (worker1TestCluster .client .Get (worker1TestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1909+ g .Expect (createdWorkload .Spec ).To (gomega .BeComparableTo (managerWl .Spec ))
1910+ g .Expect (worker2TestCluster .client .Get (worker2TestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1911+ g .Expect (createdWorkload .Spec ).To (gomega .BeComparableTo (managerWl .Spec ))
1912+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
1913+ })
1914+
1915+ ginkgo .By ("setting workload reservation in worker1, AC state is updated in manager and worker2 wl is removed" , func () {
1916+ admission := utiltestingapi .MakeAdmission (managerCq .Name ).Obj ()
1917+ util .SetQuotaReservation (worker1TestCluster .ctx , worker1TestCluster .client , wlLookupKey , admission )
1918+
1919+ gomega .Eventually (func (g gomega.Gomega ) {
1920+ g .Expect (managerTestCluster .client .Get (managerTestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1921+ acs := admissioncheck .FindAdmissionCheck (createdWorkload .Status .AdmissionChecks , kueue .AdmissionCheckReference (multiKueueAC .Name ))
1922+ g .Expect (acs ).NotTo (gomega .BeNil ())
1923+ g .Expect (acs .State ).To (gomega .Equal (kueue .CheckStateReady ))
1924+ g .Expect (acs .Message ).To (gomega .Equal (`The workload got reservation on "worker1"` ))
1925+ ok , err := utiltesting .HasEventAppeared (managerTestCluster .ctx , managerTestCluster .client , corev1.Event {
1926+ Reason : "MultiKueue" ,
1927+ Type : corev1 .EventTypeNormal ,
1928+ Message : `The workload got reservation on "worker1"` ,
1929+ })
1930+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
1931+ g .Expect (ok ).To (gomega .BeTrue ())
1932+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
1933+
1934+ gomega .Eventually (func (g gomega.Gomega ) {
1935+ g .Expect (worker2TestCluster .client .Get (worker2TestCluster .ctx , wlLookupKey , createdWorkload )).To (utiltesting .BeNotFoundError ())
1936+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
1937+ })
1938+
1939+ ginkgo .By ("preempting workload in worker1" , func () {
1940+ gomega .Eventually (func (g gomega.Gomega ) {
1941+ createdWorkload := & kueue.Workload {}
1942+ g .Expect (worker1TestCluster .client .Get (worker1TestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1943+ g .Expect (workload .SetConditionAndUpdate (worker1TestCluster .ctx , worker1TestCluster .client , createdWorkload , kueue .WorkloadEvicted , metav1 .ConditionTrue , kueue .WorkloadEvictedByPreemption , "By test" , "evict" , util .RealClock )).To (gomega .Succeed ())
1944+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
1945+ })
1946+
1947+ ginkgo .By ("check manager's workload ClusterName reset" , func () {
1948+ gomega .Eventually (func (g gomega.Gomega ) {
1949+ managerWl := & kueue.Workload {}
1950+ g .Expect (managerTestCluster .client .Get (worker1TestCluster .ctx , wlLookupKey , managerWl )).To (gomega .Succeed ())
1951+ g .Expect (managerWl .Status .NominatedClusterNames ).To (gomega .ContainElements (workerCluster1 .Name , workerCluster2 .Name ))
1952+ g .Expect (managerWl .Status .ClusterName ).To (gomega .BeNil ())
1953+ g .Expect (managerWl .Status .AdmissionChecks ).To (gomega .ContainElement (gomega .BeComparableTo (
1954+ kueue.AdmissionCheckState {
1955+ Name : kueue .AdmissionCheckReference (multiKueueAC .Name ),
1956+ State : kueue .CheckStatePending ,
1957+ },
1958+ cmpopts .IgnoreFields (kueue.AdmissionCheckState {}, "LastTransitionTime" , "PodSetUpdates" , "Message" , "RetryCount" ))))
1959+ }, util .LongTimeout , util .Interval ).Should (gomega .Succeed ())
1960+ })
1961+
1962+ ginkgo .By ("checking the workload admission process started again" , func () {
1963+ managerWl := & kueue.Workload {}
1964+ gomega .Expect (managerTestCluster .client .Get (managerTestCluster .ctx , wlLookupKey , managerWl )).To (gomega .Succeed ())
1965+ gomega .Eventually (func (g gomega.Gomega ) {
1966+ createdWorkload := & kueue.Workload {}
1967+ g .Expect (worker1TestCluster .client .Get (worker1TestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1968+ g .Expect (createdWorkload .Spec ).To (gomega .BeComparableTo (managerWl .Spec ))
1969+ g .Expect (worker2TestCluster .client .Get (worker2TestCluster .ctx , wlLookupKey , createdWorkload )).To (gomega .Succeed ())
1970+ g .Expect (createdWorkload .Spec ).To (gomega .BeComparableTo (managerWl .Spec ))
1971+ }, util .LongTimeout , util .Interval ).Should (gomega .Succeed ())
1972+ })
1973+ })
18881974})
18891975
18901976func admitWorkloadAndCheckWorkerCopies (acName string , wlLookupKey types.NamespacedName , admission * utiltestingapi.AdmissionWrapper ) {
0 commit comments