From 2b2cc01931a0fcbe372bc9211b6a7d68dc1480b7 Mon Sep 17 00:00:00 2001 From: Ayush Raj Date: Mon, 21 Sep 2026 11:58:51 +0530 Subject: [PATCH 1/2] fix(coscheduling): fallback to default scheduleTimeoutSeconds when unset Signed-off-by: Ayush Raj --- .../plugins/coscheduling/coscheduling.go | 7 ++- .../plugins/coscheduling/coscheduling_test.go | 62 +++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/pkg/runtime/framework/plugins/coscheduling/coscheduling.go b/pkg/runtime/framework/plugins/coscheduling/coscheduling.go index e91ea14525..99e36a5afb 100644 --- a/pkg/runtime/framework/plugins/coscheduling/coscheduling.go +++ b/pkg/runtime/framework/plugins/coscheduling/coscheduling.go @@ -60,7 +60,10 @@ var _ framework.EnforcePodGroupPolicyPlugin = (*CoScheduling)(nil) var _ framework.WatchExtensionPlugin = (*CoScheduling)(nil) var _ framework.ComponentBuilderPlugin = (*CoScheduling)(nil) -const Name = "CoScheduling" +const ( + Name = "CoScheduling" + defaultScheduleTimeoutSeconds = 60 +) // +kubebuilder:rbac:groups=scheduling.x-k8s.io,resources=podgroups,verbs=create;get;list;watch;update;patch // +kubebuilder:rbac:groups=node.k8s.io,resources=runtimeclasses,verbs=get;list;watch @@ -125,7 +128,7 @@ func (c *CoScheduling) Build(ctx context.Context, info *runtime.Info, trainJob * podGroup.WithSpec(schedulerpluginsv1alpha1ac.PodGroupSpec(). WithMinMember(totalMembers). WithMinResources(totalResources). - WithScheduleTimeoutSeconds(*info.RuntimePolicy.PodGroupPolicy.Coscheduling.ScheduleTimeoutSeconds)) + WithScheduleTimeoutSeconds(ptr.Deref(info.RuntimePolicy.PodGroupPolicy.Coscheduling.ScheduleTimeoutSeconds, defaultScheduleTimeoutSeconds))) podGroup.WithOwnerReferences(metav1ac.OwnerReference(). WithAPIVersion(trainer.GroupVersion.String()). diff --git a/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go b/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go index f6fb659942..eb631b4573 100644 --- a/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go +++ b/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go @@ -181,6 +181,68 @@ func TestCoScheduling(t *testing.T) { Obj(), }, }, + "succeeded to build PodGroup when ScheduleTimeoutSeconds is nil": { + info: &runtime.Info{ + Scheduler: &runtime.Scheduler{}, + RuntimePolicy: runtime.RuntimePolicy{ + PodGroupPolicy: &trainerv1alpha1.PodGroupPolicy{ + PodGroupPolicySource: trainerv1alpha1.PodGroupPolicySource{ + Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{ + ScheduleTimeoutSeconds: nil, + }, + }, + }, + }, + TemplateSpec: runtime.TemplateSpec{ + PodSets: []runtime.PodSet{ + { + Name: "node", + Count: ptr.To[int32](1), + }, + }, + }, + }, + trainJob: utiltesting.MakeTrainJobWrapper(metav1.NamespaceDefault, "trainJob"). + UID("trainJob"). + Trainer( + utiltesting.MakeTrainJobTrainerWrapper(). + NumNodes(2). + Obj()). + Obj(), + wantInfo: &runtime.Info{ + Scheduler: &runtime.Scheduler{ + PodLabels: map[string]string{ + "scheduling.x-k8s.io/pod-group": "trainJob", + }, + }, + RuntimePolicy: runtime.RuntimePolicy{ + PodGroupPolicy: &trainerv1alpha1.PodGroupPolicy{ + PodGroupPolicySource: trainerv1alpha1.PodGroupPolicySource{ + Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{ + ScheduleTimeoutSeconds: nil, + }, + }, + }, + }, + TemplateSpec: runtime.TemplateSpec{ + PodSets: []runtime.PodSet{ + { + Name: "node", + Count: ptr.To[int32](1), + }, + }, + }, + }, + objs: []client.Object{}, + wantObjs: []apiruntime.Object{ + utiltesting.MakeSchedulerPluginsPodGroup(metav1.NamespaceDefault, "trainJob"). + MinMember(1). + MinResources(corev1.ResourceList{}). + SchedulingTimeout(60). + ControllerReference(trainerv1alpha1.GroupVersion.WithKind(trainerv1alpha1.TrainJobKind), "trainJob", "trainJob"). + Obj(), + }, + }, "succeeded to build PodGroup with multiple PodSets": { info: &runtime.Info{ Scheduler: &runtime.Scheduler{}, From eb8a083160e3905e6b39f838f9e71d36f82f0f95 Mon Sep 17 00:00:00 2001 From: Ayush Raj Date: Wed, 30 Sep 2026 10:16:23 +0530 Subject: [PATCH 2/2] test(coscheduling): use empty CoschedulingPodGroupPolicySource in nil timeout test case Signed-off-by: Ayush Raj --- .../framework/plugins/coscheduling/coscheduling_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go b/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go index eb631b4573..54f1e643a5 100644 --- a/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go +++ b/pkg/runtime/framework/plugins/coscheduling/coscheduling_test.go @@ -187,9 +187,7 @@ func TestCoScheduling(t *testing.T) { RuntimePolicy: runtime.RuntimePolicy{ PodGroupPolicy: &trainerv1alpha1.PodGroupPolicy{ PodGroupPolicySource: trainerv1alpha1.PodGroupPolicySource{ - Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{ - ScheduleTimeoutSeconds: nil, - }, + Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{}, }, }, }, @@ -218,9 +216,7 @@ func TestCoScheduling(t *testing.T) { RuntimePolicy: runtime.RuntimePolicy{ PodGroupPolicy: &trainerv1alpha1.PodGroupPolicy{ PodGroupPolicySource: trainerv1alpha1.PodGroupPolicySource{ - Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{ - ScheduleTimeoutSeconds: nil, - }, + Coscheduling: &trainerv1alpha1.CoschedulingPodGroupPolicySource{}, }, }, },