Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the default value of CleanPodPolicy to None #1754

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/apis/kubeflow.org/v1/defaulting_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ func setTypeNameToCamelCase(replicaSpecs map[commonv1.ReplicaType]*commonv1.Repl
}
}
}

func cleanPodPolicyPointer(cleanPodPolicy commonv1.CleanPodPolicy) *commonv1.CleanPodPolicy {
return &cleanPodPolicy
}
4 changes: 2 additions & 2 deletions pkg/apis/kubeflow.org/v1/mxnet_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func setMXNetTypeNamesToCamelCase(mxJob *MXJob) {

// SetDefaults_MXJob sets any unspecified values to defaults.
func SetDefaults_MXJob(mxjob *MXJob) {
// Set default cleanpod policy to All.
// Set default cleanpod policy to None.
if mxjob.Spec.RunPolicy.CleanPodPolicy == nil {
all := commonv1.CleanPodPolicyAll
all := commonv1.CleanPodPolicyNone
mxjob.Spec.RunPolicy.CleanPodPolicy = &all
}

Expand Down
35 changes: 30 additions & 5 deletions pkg/apis/kubeflow.org/v1/mxnet_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestSetDefaults_MXJob(t *testing.T) {
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, MXJobDefaultPort),
expected: expectedMXNetJob(commonv1.CleanPodPolicyNone, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, MXJobDefaultPort),
},
"Set spec with restart policy": {
original: &MXJob{
Expand All @@ -118,7 +118,7 @@ func TestSetDefaults_MXJob(t *testing.T) {
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, commonv1.RestartPolicyOnFailure, 1, MXJobDefaultPortName, MXJobDefaultPort),
expected: expectedMXNetJob(commonv1.CleanPodPolicyNone, commonv1.RestartPolicyOnFailure, 1, MXJobDefaultPortName, MXJobDefaultPort),
},
"Set spec with replicas": {
original: &MXJob{
Expand All @@ -140,7 +140,7 @@ func TestSetDefaults_MXJob(t *testing.T) {
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, MXJobDefaultRestartPolicy, 3, MXJobDefaultPortName, MXJobDefaultPort),
expected: expectedMXNetJob(commonv1.CleanPodPolicyNone, MXJobDefaultRestartPolicy, 3, MXJobDefaultPortName, MXJobDefaultPort),
},

"Set spec with default node port name and port": {
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestSetDefaults_MXJob(t *testing.T) {
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, MXJobDefaultPort),
expected: expectedMXNetJob(commonv1.CleanPodPolicyNone, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, MXJobDefaultPort),
},

"Set spec with node port": {
Expand Down Expand Up @@ -196,7 +196,32 @@ func TestSetDefaults_MXJob(t *testing.T) {
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, 9999),
expected: expectedMXNetJob(commonv1.CleanPodPolicyNone, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, 9999),
},

"set spec with cleanpod policy": {
original: &MXJob{
Spec: MXJobSpec{
RunPolicy: commonv1.RunPolicy{
CleanPodPolicy: cleanPodPolicyPointer(commonv1.CleanPodPolicyAll),
},
MXReplicaSpecs: map[commonv1.ReplicaType]*commonv1.ReplicaSpec{
MXJobReplicaTypeWorker: &commonv1.ReplicaSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
corev1.Container{
Name: MXJobDefaultContainerName,
Image: testImage,
},
},
},
},
},
},
},
},
expected: expectedMXNetJob(commonv1.CleanPodPolicyAll, MXJobDefaultRestartPolicy, 1, MXJobDefaultPortName, MXJobDefaultPort),
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/kubeflow.org/v1/tensorflow_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func setTensorflowTypeNamesToCamelCase(tfJob *TFJob) {

// SetDefaults_TFJob sets any unspecified values to defaults.
func SetDefaults_TFJob(tfJob *TFJob) {
// Set default cleanpod policy to Running.
// Set default cleanpod policy to None.
if tfJob.Spec.RunPolicy.CleanPodPolicy == nil {
running := commonv1.CleanPodPolicyRunning
running := commonv1.CleanPodPolicyNone
tfJob.Spec.RunPolicy.CleanPodPolicy = &running
}
// Set default success policy to "".
Expand Down
13 changes: 4 additions & 9 deletions pkg/apis/kubeflow.org/v1/tensorflow_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestSetDefaultTFJob(t *testing.T) {
},
},
},
expected: expectedTFJob(commonv1.CleanPodPolicyRunning, customRestartPolicy, TFJobDefaultPortName, TFJobDefaultPort),
expected: expectedTFJob(commonv1.CleanPodPolicyNone, customRestartPolicy, TFJobDefaultPortName, TFJobDefaultPort),
},
"set replicas with default restartpolicy": {
original: &TFJob{
Expand All @@ -178,7 +178,7 @@ func TestSetDefaultTFJob(t *testing.T) {
},
},
},
expected: expectedTFJob(commonv1.CleanPodPolicyRunning, TFJobDefaultRestartPolicy, TFJobDefaultPortName, TFJobDefaultPort),
expected: expectedTFJob(commonv1.CleanPodPolicyNone, TFJobDefaultRestartPolicy, TFJobDefaultPortName, TFJobDefaultPort),
},
"set replicas with default port": {
original: &TFJob{
Expand All @@ -201,7 +201,7 @@ func TestSetDefaultTFJob(t *testing.T) {
},
},
},
expected: expectedTFJob(commonv1.CleanPodPolicyRunning, customRestartPolicy, "", 0),
expected: expectedTFJob(commonv1.CleanPodPolicyNone, customRestartPolicy, "", 0),
},
"set replicas adding default port": {
original: &TFJob{
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestSetDefaultTFJob(t *testing.T) {
},
},
},
expected: expectedTFJob(commonv1.CleanPodPolicyRunning, customRestartPolicy, customPortName, customPort),
expected: expectedTFJob(commonv1.CleanPodPolicyNone, customRestartPolicy, customPortName, customPort),
},
"set custom cleanpod policy": {
original: &TFJob{
Expand Down Expand Up @@ -273,8 +273,3 @@ func TestSetDefaultTFJob(t *testing.T) {
}
}
}

func cleanPodPolicyPointer(cleanPodPolicy commonv1.CleanPodPolicy) *commonv1.CleanPodPolicy {
c := cleanPodPolicy
return &c
}
4 changes: 2 additions & 2 deletions pkg/apis/kubeflow.org/v1/xgboost_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func setXGBoostJobTypeNamesToCamelCase(xgboostJob *XGBoostJob) {

// SetDefaults_XGBoostJob sets any unspecified values to defaults.
func SetDefaults_XGBoostJob(xgboostJob *XGBoostJob) {
// Set default cleanpod policy to All.
// Set default cleanpod policy to None.
if xgboostJob.Spec.RunPolicy.CleanPodPolicy == nil {
all := commonv1.CleanPodPolicyAll
all := commonv1.CleanPodPolicyNone
xgboostJob.Spec.RunPolicy.CleanPodPolicy = &all
}

Expand Down
34 changes: 29 additions & 5 deletions pkg/apis/kubeflow.org/v1/xgboost_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestSetDefaults_XGBoostJob(t *testing.T) {
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
expected: expectedXGBoostJob(commonv1.CleanPodPolicyNone, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
},
"Set spec with restart policy": {
original: &XGBoostJob{
Expand All @@ -118,7 +118,7 @@ func TestSetDefaults_XGBoostJob(t *testing.T) {
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, commonv1.RestartPolicyOnFailure, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
expected: expectedXGBoostJob(commonv1.CleanPodPolicyNone, commonv1.RestartPolicyOnFailure, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
},
"Set spec with replicas": {
original: &XGBoostJob{
Expand All @@ -140,7 +140,7 @@ func TestSetDefaults_XGBoostJob(t *testing.T) {
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, XGBoostJobDefaultRestartPolicy, 3, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
expected: expectedXGBoostJob(commonv1.CleanPodPolicyNone, XGBoostJobDefaultRestartPolicy, 3, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
},

"Set spec with default node port name and port": {
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestSetDefaults_XGBoostJob(t *testing.T) {
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
expected: expectedXGBoostJob(commonv1.CleanPodPolicyNone, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
},

"Set spec with node port": {
Expand Down Expand Up @@ -196,7 +196,31 @@ func TestSetDefaults_XGBoostJob(t *testing.T) {
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, 9999),
expected: expectedXGBoostJob(commonv1.CleanPodPolicyNone, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, 9999),
},
"set spec with cleanpod policy": {
original: &XGBoostJob{
Spec: XGBoostJobSpec{
RunPolicy: commonv1.RunPolicy{
CleanPodPolicy: cleanPodPolicyPointer(commonv1.CleanPodPolicyAll),
},
XGBReplicaSpecs: map[commonv1.ReplicaType]*commonv1.ReplicaSpec{
XGBoostJobReplicaTypeWorker: &commonv1.ReplicaSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
corev1.Container{
Name: XGBoostJobDefaultContainerName,
Image: testImage,
},
},
},
},
},
},
},
},
expected: expectedXGBoostJob(commonv1.CleanPodPolicyAll, XGBoostJobDefaultRestartPolicy, 1, XGBoostJobDefaultPortName, XGBoostJobDefaultPort),
},
}

Expand Down