Skip to content

Commit ce37edd

Browse files
committed
Copy also SchedulingPolicy and CleanPodPolicy
1 parent 502685c commit ce37edd

19 files changed

+527
-79
lines changed

pkg/apis/kubeflow/v2beta1/default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func setDefaultsTypeWorker(spec *common.ReplicaSpec) {
5151

5252
func setDefaultsRunPolicy(policy *RunPolicy) {
5353
if policy.CleanPodPolicy == nil {
54-
policy.CleanPodPolicy = newCleanPodPolicy(common.CleanPodPolicyNone)
54+
policy.CleanPodPolicy = newCleanPodPolicy(CleanPodPolicyNone)
5555
}
5656
// The remaining fields are passed as-is to the k8s Job API, which does its
5757
// own defaulting.
@@ -80,6 +80,6 @@ func newInt32(v int32) *int32 {
8080
return &v
8181
}
8282

83-
func newCleanPodPolicy(policy common.CleanPodPolicy) *common.CleanPodPolicy {
83+
func newCleanPodPolicy(policy CleanPodPolicy) *CleanPodPolicy {
8484
return &policy
8585
}

pkg/apis/kubeflow/v2beta1/default_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
3131
Spec: MPIJobSpec{
3232
SlotsPerWorker: newInt32(1),
3333
RunPolicy: RunPolicy{
34-
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyNone),
34+
CleanPodPolicy: newCleanPodPolicy(CleanPodPolicyNone),
3535
},
3636
SSHAuthMountPath: "/root/.ssh",
3737
MPIImplementation: MPIImplementationOpenMPI,
@@ -43,7 +43,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
4343
Spec: MPIJobSpec{
4444
SlotsPerWorker: newInt32(10),
4545
RunPolicy: RunPolicy{
46-
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
46+
CleanPodPolicy: newCleanPodPolicy(CleanPodPolicyRunning),
4747
TTLSecondsAfterFinished: newInt32(2),
4848
ActiveDeadlineSeconds: newInt64(3),
4949
BackoffLimit: newInt32(4),
@@ -56,7 +56,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
5656
Spec: MPIJobSpec{
5757
SlotsPerWorker: newInt32(10),
5858
RunPolicy: RunPolicy{
59-
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
59+
CleanPodPolicy: newCleanPodPolicy(CleanPodPolicyRunning),
6060
TTLSecondsAfterFinished: newInt32(2),
6161
ActiveDeadlineSeconds: newInt64(3),
6262
BackoffLimit: newInt32(4),
@@ -78,7 +78,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
7878
Spec: MPIJobSpec{
7979
SlotsPerWorker: newInt32(1),
8080
RunPolicy: RunPolicy{
81-
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyNone),
81+
CleanPodPolicy: newCleanPodPolicy(CleanPodPolicyNone),
8282
},
8383
SSHAuthMountPath: "/root/.ssh",
8484
MPIImplementation: MPIImplementationOpenMPI,
@@ -103,7 +103,7 @@ func TestSetDefaults_MPIJob(t *testing.T) {
103103
Spec: MPIJobSpec{
104104
SlotsPerWorker: newInt32(1),
105105
RunPolicy: RunPolicy{
106-
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyNone),
106+
CleanPodPolicy: newCleanPodPolicy(CleanPodPolicyNone),
107107
},
108108
SSHAuthMountPath: "/root/.ssh",
109109
MPIImplementation: MPIImplementationOpenMPI,

pkg/apis/kubeflow/v2beta1/openapi_generated.go

Lines changed: 66 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kubeflow/v2beta1/swagger.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,41 @@
293293
},
294294
"schedulingPolicy": {
295295
"description": "SchedulingPolicy defines the policy related to scheduling, e.g. gang-scheduling",
296-
"$ref": "#/definitions/v1.SchedulingPolicy"
296+
"$ref": "#/definitions/v2beta1.SchedulingPolicy"
297297
},
298298
"ttlSecondsAfterFinished": {
299299
"description": "TTLSecondsAfterFinished is the TTL to clean up jobs. It may take extra ReconcilePeriod seconds for the cleanup, since reconcile gets called periodically. Default to infinite.",
300300
"type": "integer",
301301
"format": "int32"
302302
}
303303
}
304+
},
305+
"v2beta1.SchedulingPolicy": {
306+
"description": "SchedulingPolicy encapsulates various scheduling policies of the distributed training job, for example `minAvailable` for gang-scheduling.",
307+
"type": "object",
308+
"properties": {
309+
"minAvailable": {
310+
"type": "integer",
311+
"format": "int32"
312+
},
313+
"minResources": {
314+
"type": "object",
315+
"additionalProperties": {
316+
"default": {},
317+
"$ref": "#/definitions/resource.Quantity"
318+
}
319+
},
320+
"priorityClass": {
321+
"type": "string"
322+
},
323+
"queue": {
324+
"type": "string"
325+
},
326+
"scheduleTimeoutSeconds": {
327+
"type": "integer",
328+
"format": "int32"
329+
}
330+
}
304331
}
305332
}
306333
}

pkg/apis/kubeflow/v2beta1/types.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package v2beta1
1616

1717
import (
1818
common "github.com/kubeflow/common/pkg/apis/common/v1"
19+
v1 "k8s.io/api/core/v1"
1920
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2021
)
2122

@@ -37,13 +38,33 @@ type MPIJobList struct {
3738
Items []MPIJob `json:"items"`
3839
}
3940

41+
// CleanPodPolicy describes how to deal with pods when the job is finished.
42+
type CleanPodPolicy string
43+
44+
const (
45+
CleanPodPolicyUndefined CleanPodPolicy = ""
46+
CleanPodPolicyAll CleanPodPolicy = "All"
47+
CleanPodPolicyRunning CleanPodPolicy = "Running"
48+
CleanPodPolicyNone CleanPodPolicy = "None"
49+
)
50+
51+
// SchedulingPolicy encapsulates various scheduling policies of the distributed training
52+
// job, for example `minAvailable` for gang-scheduling.
53+
type SchedulingPolicy struct {
54+
MinAvailable *int32 `json:"minAvailable,omitempty"`
55+
Queue string `json:"queue,omitempty"`
56+
MinResources *v1.ResourceList `json:"minResources,omitempty"`
57+
PriorityClass string `json:"priorityClass,omitempty"`
58+
ScheduleTimeoutSeconds *int32 `json:"scheduleTimeoutSeconds,omitempty"`
59+
}
60+
4061
// RunPolicy encapsulates various runtime policies of the distributed training
4162
// job, for example how to clean up resources and how long the job can stay
4263
// active.
4364
type RunPolicy struct {
4465
// CleanPodPolicy defines the policy to kill pods after the job completes.
4566
// Default to Running.
46-
CleanPodPolicy *common.CleanPodPolicy `json:"cleanPodPolicy,omitempty"`
67+
CleanPodPolicy *CleanPodPolicy `json:"cleanPodPolicy,omitempty"`
4768

4869
// TTLSecondsAfterFinished is the TTL to clean up jobs.
4970
// It may take extra ReconcilePeriod seconds for the cleanup, since
@@ -62,7 +83,7 @@ type RunPolicy struct {
6283

6384
// SchedulingPolicy defines the policy related to scheduling, e.g. gang-scheduling
6485
// +optional
65-
SchedulingPolicy *common.SchedulingPolicy `json:"schedulingPolicy,omitempty"`
86+
SchedulingPolicy *SchedulingPolicy `json:"schedulingPolicy,omitempty"`
6687
}
6788

6889
type MPIJobSpec struct {

pkg/apis/kubeflow/v2beta1/zz_generated.deepcopy.go

Lines changed: 41 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kubeflow/validation/validation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import (
2929

3030
var (
3131
validCleanPolicies = sets.NewString(
32-
string(common.CleanPodPolicyNone),
33-
string(common.CleanPodPolicyRunning),
34-
string(common.CleanPodPolicyAll))
32+
string(kubeflow.CleanPodPolicyNone),
33+
string(kubeflow.CleanPodPolicyRunning),
34+
string(kubeflow.CleanPodPolicyAll))
3535

3636
validMPIImplementations = sets.NewString(
3737
string(kubeflow.MPIImplementationOpenMPI),

0 commit comments

Comments
 (0)