diff --git a/pkg/apis/kubeflow/v2beta1/common_types.go b/pkg/apis/kubeflow/v2beta1/common_types.go deleted file mode 100644 index 8c24cd8a..00000000 --- a/pkg/apis/kubeflow/v2beta1/common_types.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2018 The Kubeflow Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package v2beta1 - -import ( - v1 "k8s.io/api/core/v1" -) - -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=true -// ReplicaSpec is a description of the replica -type ReplicaSpec struct { - // Replicas is the desired number of replicas of the given template. - // If unspecified, defaults to 1. - Replicas *int32 `json:"replicas,omitempty"` - - // Template is the object that describes the pod that - // will be created for this replica. RestartPolicy in PodTemplateSpec - // will be overide by RestartPolicy in ReplicaSpec - Template v1.PodTemplateSpec `json:"template,omitempty"` - - // Restart policy for all replicas within the job. - // One of Always, OnFailure, Never and ExitCode. - // Default to Never. - RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"` -} - -// +k8s:openapi-gen=true -// RestartPolicy describes how the replicas should be restarted. -// Only one of the following restart policies may be specified. -// If none of the following policies is specified, the default one -// is RestartPolicyAlways. -type RestartPolicy string - -const ( - RestartPolicyAlways RestartPolicy = "Always" - RestartPolicyOnFailure RestartPolicy = "OnFailure" - RestartPolicyNever RestartPolicy = "Never" - - // RestartPolicyExitCode policy means that user should add exit code by themselves, - // The job operator will check these exit codes to - // determine the behavior when an error occurs: - // - 1-127: permanent error, do not restart. - // - 128-255: retryable error, will restart the pod. - RestartPolicyExitCode RestartPolicy = "ExitCode" -) diff --git a/pkg/apis/kubeflow/v2beta1/constants.go b/pkg/apis/kubeflow/v2beta1/constants.go index fe6fd815..27070bdb 100644 --- a/pkg/apis/kubeflow/v2beta1/constants.go +++ b/pkg/apis/kubeflow/v2beta1/constants.go @@ -26,6 +26,7 @@ const ( ) // merge from common.v1 +// reference https://github.com/kubeflow/common/blob/master/pkg/apis/common/v1/constants.go const ( // ReplicaIndexLabel represents the label key for the replica-index, e.g. 0, 1, 2.. etc diff --git a/pkg/apis/kubeflow/v2beta1/openapi_generated.go b/pkg/apis/kubeflow/v2beta1/openapi_generated.go index 4670532e..02b34df0 100644 --- a/pkg/apis/kubeflow/v2beta1/openapi_generated.go +++ b/pkg/apis/kubeflow/v2beta1/openapi_generated.go @@ -276,13 +276,6 @@ func schema_pkg_apis_kubeflow_v2beta1_MPIJobSpec(ref common.ReferenceCallback) c Format: "int32", }, }, - "launcherCreationPolicy": { - SchemaProps: spec.SchemaProps{ - Description: "launcherCreationPolicy if WaitForWorkersReady, the launcher is created only after all workers are in Ready state", - Type: []string{"string"}, - Format: "", - }, - }, "runPolicy": { SchemaProps: spec.SchemaProps{ Description: "RunPolicy encapsulates various runtime policies of the job.", @@ -311,6 +304,13 @@ func schema_pkg_apis_kubeflow_v2beta1_MPIJobSpec(ref common.ReferenceCallback) c Format: "", }, }, + "launcherCreationPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "launcherCreationPolicy if WaitForWorkersReady, the launcher is created only after all workers are in Ready state. Defaults to AtStartup.", + Type: []string{"string"}, + Format: "", + }, + }, "mpiImplementation": { SchemaProps: spec.SchemaProps{ Description: "MPIImplementation is the MPI implementation. Options are \"OpenMPI\" (default), \"Intel\" and \"MPICH\".", diff --git a/pkg/apis/kubeflow/v2beta1/types.go b/pkg/apis/kubeflow/v2beta1/types.go index e6532e76..8247938c 100644 --- a/pkg/apis/kubeflow/v2beta1/types.go +++ b/pkg/apis/kubeflow/v2beta1/types.go @@ -313,3 +313,45 @@ const ( // The training has failed its execution. JobFailed JobConditionType = "Failed" ) + +// Following is merge from common.v1 +// reference https://github.com/kubeflow/common/blob/master/pkg/apis/common/v1/types.go + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=true +// ReplicaSpec is a description of the replica +type ReplicaSpec struct { + // Replicas is the desired number of replicas of the given template. + // If unspecified, defaults to 1. + Replicas *int32 `json:"replicas,omitempty"` + + // Template is the object that describes the pod that + // will be created for this replica. RestartPolicy in PodTemplateSpec + // will be overide by RestartPolicy in ReplicaSpec + Template v1.PodTemplateSpec `json:"template,omitempty"` + + // Restart policy for all replicas within the job. + // One of Always, OnFailure, Never and ExitCode. + // Default to Never. + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"` +} + +// +k8s:openapi-gen=true +// RestartPolicy describes how the replicas should be restarted. +// Only one of the following restart policies may be specified. +// If none of the following policies is specified, the default one +// is RestartPolicyAlways. +type RestartPolicy string + +const ( + RestartPolicyAlways RestartPolicy = "Always" + RestartPolicyOnFailure RestartPolicy = "OnFailure" + RestartPolicyNever RestartPolicy = "Never" + + // RestartPolicyExitCode policy means that user should add exit code by themselves, + // The job operator will check these exit codes to + // determine the behavior when an error occurs: + // - 1-127: permanent error, do not restart. + // - 128-255: retryable error, will restart the pod. + RestartPolicyExitCode RestartPolicy = "ExitCode" +) \ No newline at end of file