Downgrade v2 API to v2beta1 (#378)

To leave the path open for improving the API without having to release a v3.
This commit is contained in:
Aldo Culquicondor 2021-07-16 11:29:46 -04:00 committed by GitHub
parent d7f7421ba7
commit 70a866ee52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 211 additions and 209 deletions

View File

@ -103,4 +103,4 @@ bin/kubebuilder:
.PHONY: lint .PHONY: lint
lint: bin/golangci-lint ## Run golangci-lint linter lint: bin/golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run --new-from-rev=origin/master $(GOLANGCI_LINT) run --new-from-rev=origin/master
cd v2 && $(GOLANGCI_LINT) run --new-from-rev=origin/master cd v2 && ../$(GOLANGCI_LINT) run --new-from-rev=origin/master

View File

@ -53,6 +53,6 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/kubeflow/mpi-operator/v2/pkg/client github.com/kubeflow/mpi-operator/v2/pkg/apis \ github.com/kubeflow/mpi-operator/v2/pkg/client github.com/kubeflow/mpi-operator/v2/pkg/apis \
kubeflow:v2 --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt kubeflow:v2beta1 --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
popd popd

View File

@ -149,7 +149,7 @@ spec:
properties: properties:
replicas: replicas:
type: integer type: integer
- name: v2 - name: v2beta1
served: true served: true
storage: true storage: true
schema: schema:

View File

@ -18,7 +18,7 @@ import (
"flag" "flag"
"os" "os"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
) )
// ServerOption is the main context object for the controller manager. // ServerOption is the main context object for the controller manager.
@ -50,7 +50,7 @@ func (s *ServerOption) AddFlags(fs *flag.FlagSet) {
fs.StringVar(&s.Kubeconfig, "kubeConfig", "", fs.StringVar(&s.Kubeconfig, "kubeConfig", "",
"Path to a kubeConfig. Only required if out-of-cluster.") "Path to a kubeConfig. Only required if out-of-cluster.")
fs.StringVar(&s.Namespace, "namespace", os.Getenv(v2.EnvKubeflowNamespace), fs.StringVar(&s.Namespace, "namespace", os.Getenv(v2beta1.EnvKubeflowNamespace),
`The namespace to monitor mpijobs. If unset, it monitors all namespaces cluster-wide. `The namespace to monitor mpijobs. If unset, it monitors all namespaces cluster-wide.
If set, it only monitors mpijobs in the given namespace.`) If set, it only monitors mpijobs in the given namespace.`)

View File

@ -159,7 +159,7 @@ func Run(opt *options.ServerOption) error {
kubeInformerFactory.Core().V1().Services(), kubeInformerFactory.Core().V1().Services(),
kubeInformerFactory.Core().V1().Pods(), kubeInformerFactory.Core().V1().Pods(),
podgroupsInformer, podgroupsInformer,
kubeflowInformerFactory.Kubeflow().V2().MPIJobs(), kubeflowInformerFactory.Kubeflow().V2beta1().MPIJobs(),
opt.GangSchedulingName) opt.GangSchedulingName)
go kubeInformerFactory.Start(ctx.Done()) go kubeInformerFactory.Start(ctx.Done())
@ -284,7 +284,7 @@ func createClientSets(config *restclientset.Config) (kubeclientset.Interface, ku
} }
func checkCRDExists(clientset mpijobclientset.Interface, namespace string) bool { func checkCRDExists(clientset mpijobclientset.Interface, namespace string) bool {
_, err := clientset.KubeflowV2().MPIJobs(namespace).List(context.TODO(), metav1.ListOptions{}) _, err := clientset.KubeflowV2beta1().MPIJobs(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil { if err != nil {
klog.Error(err) klog.Error(err)

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package v2 package v2beta1
import common "github.com/kubeflow/common/pkg/apis/common/v1" import common "github.com/kubeflow/common/pkg/apis/common/v1"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package v2 package v2beta1
import ( import (
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package v2 package v2beta1
import ( import (
"testing" "testing"

View File

@ -18,4 +18,4 @@
// Package v1 is the v1 version of the API. // Package v1 is the v1 version of the API.
// +groupName=kubeflow.org // +groupName=kubeflow.org
package v2 package v2beta1

View File

@ -18,7 +18,7 @@
// This file was autogenerated by openapi-gen. Do not edit it manually! // This file was autogenerated by openapi-gen. Do not edit it manually!
package v2 package v2beta1
import ( import (
spec "github.com/go-openapi/spec" spec "github.com/go-openapi/spec"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package v2 package v2beta1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -26,7 +26,7 @@ const (
// Kind is the kind name. // Kind is the kind name.
Kind = "MPIJob" Kind = "MPIJob"
// GroupVersion is the version. // GroupVersion is the version.
GroupVersion = "v2" GroupVersion = "v2beta1"
) )
var ( var (

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package v2 package v2beta1
import ( import (
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"

View File

@ -16,7 +16,7 @@
// Code generated by deepcopy-gen. DO NOT EDIT. // Code generated by deepcopy-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
v1 "github.com/kubeflow/common/pkg/apis/common/v1" v1 "github.com/kubeflow/common/pkg/apis/common/v1"

View File

@ -16,7 +16,7 @@
// Code generated by defaulter-gen. DO NOT EDIT. // Code generated by defaulter-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"

View File

@ -17,11 +17,12 @@ package validation
import ( import (
"fmt" "fmt"
common "github.com/kubeflow/common/pkg/apis/common/v1"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2"
apivalidation "k8s.io/apimachinery/pkg/api/validation" apivalidation "k8s.io/apimachinery/pkg/api/validation"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
common "github.com/kubeflow/common/pkg/apis/common/v1"
kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
) )
var validCleanPolicies = sets.NewString( var validCleanPolicies = sets.NewString(
@ -29,11 +30,11 @@ var validCleanPolicies = sets.NewString(
string(common.CleanPodPolicyRunning), string(common.CleanPodPolicyRunning),
string(common.CleanPodPolicyAll)) string(common.CleanPodPolicyAll))
func ValidateMPIJob(job *v2.MPIJob) field.ErrorList { func ValidateMPIJob(job *kubeflow.MPIJob) field.ErrorList {
return validateMPIJobSpec(&job.Spec, field.NewPath("spec")) return validateMPIJobSpec(&job.Spec, field.NewPath("spec"))
} }
func validateMPIJobSpec(spec *v2.MPIJobSpec, path *field.Path) field.ErrorList { func validateMPIJobSpec(spec *kubeflow.MPIJobSpec, path *field.Path) field.ErrorList {
errs := validateMPIReplicaSpecs(spec.MPIReplicaSpecs, path.Child("mpiReplicaSpecs")) errs := validateMPIReplicaSpecs(spec.MPIReplicaSpecs, path.Child("mpiReplicaSpecs"))
if spec.SlotsPerWorker == nil { if spec.SlotsPerWorker == nil {
errs = append(errs, field.Required(path.Child("slotsPerWorker"), "must have number of slots per worker")) errs = append(errs, field.Required(path.Child("slotsPerWorker"), "must have number of slots per worker"))
@ -48,21 +49,21 @@ func validateMPIJobSpec(spec *v2.MPIJobSpec, path *field.Path) field.ErrorList {
return errs return errs
} }
func validateMPIReplicaSpecs(replicaSpecs map[v2.MPIReplicaType]*common.ReplicaSpec, path *field.Path) field.ErrorList { func validateMPIReplicaSpecs(replicaSpecs map[kubeflow.MPIReplicaType]*common.ReplicaSpec, path *field.Path) field.ErrorList {
var errs field.ErrorList var errs field.ErrorList
if replicaSpecs == nil { if replicaSpecs == nil {
errs = append(errs, field.Required(path, "must have replica specs")) errs = append(errs, field.Required(path, "must have replica specs"))
return errs return errs
} }
errs = append(errs, validateLauncherReplicaSpec(replicaSpecs[v2.MPIReplicaTypeLauncher], path.Key(string(v2.MPIReplicaTypeLauncher)))...) errs = append(errs, validateLauncherReplicaSpec(replicaSpecs[kubeflow.MPIReplicaTypeLauncher], path.Key(string(kubeflow.MPIReplicaTypeLauncher)))...)
errs = append(errs, validateWorkerReplicaSpec(replicaSpecs[v2.MPIReplicaTypeWorker], path.Key(string(v2.MPIReplicaTypeWorker)))...) errs = append(errs, validateWorkerReplicaSpec(replicaSpecs[kubeflow.MPIReplicaTypeWorker], path.Key(string(kubeflow.MPIReplicaTypeWorker)))...)
return errs return errs
} }
func validateLauncherReplicaSpec(spec *common.ReplicaSpec, path *field.Path) field.ErrorList { func validateLauncherReplicaSpec(spec *common.ReplicaSpec, path *field.Path) field.ErrorList {
var errs field.ErrorList var errs field.ErrorList
if spec == nil { if spec == nil {
errs = append(errs, field.Required(path, fmt.Sprintf("must have %s replica spec", v2.MPIReplicaTypeLauncher))) errs = append(errs, field.Required(path, fmt.Sprintf("must have %s replica spec", kubeflow.MPIReplicaTypeLauncher)))
return errs return errs
} }
errs = append(errs, validateReplicaSpec(spec, path)...) errs = append(errs, validateReplicaSpec(spec, path)...)

View File

@ -20,23 +20,23 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"
"github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
) )
func TestValidateMPIJob(t *testing.T) { func TestValidateMPIJob(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
job v2.MPIJob job v2beta1.MPIJob
wantErrs field.ErrorList wantErrs field.ErrorList
}{ }{
"valid": { "valid": {
job: v2.MPIJob{ job: v2beta1.MPIJob{
Spec: v2.MPIJobSpec{ Spec: v2beta1.MPIJobSpec{
SlotsPerWorker: newInt32(2), SlotsPerWorker: newInt32(2),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{ MPIReplicaSpecs: map[v2beta1.MPIReplicaType]*common.ReplicaSpec{
v2.MPIReplicaTypeLauncher: { v2beta1.MPIReplicaTypeLauncher: {
Replicas: newInt32(1), Replicas: newInt32(1),
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
@ -49,12 +49,12 @@ func TestValidateMPIJob(t *testing.T) {
}, },
}, },
"valid with worker": { "valid with worker": {
job: v2.MPIJob{ job: v2beta1.MPIJob{
Spec: v2.MPIJobSpec{ Spec: v2beta1.MPIJobSpec{
SlotsPerWorker: newInt32(2), SlotsPerWorker: newInt32(2),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{ MPIReplicaSpecs: map[v2beta1.MPIReplicaType]*common.ReplicaSpec{
v2.MPIReplicaTypeLauncher: { v2beta1.MPIReplicaTypeLauncher: {
Replicas: newInt32(1), Replicas: newInt32(1),
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
@ -62,7 +62,7 @@ func TestValidateMPIJob(t *testing.T) {
}, },
}, },
}, },
v2.MPIReplicaTypeWorker: { v2beta1.MPIReplicaTypeWorker: {
Replicas: newInt32(3), Replicas: newInt32(3),
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
@ -91,11 +91,11 @@ func TestValidateMPIJob(t *testing.T) {
}, },
}, },
"empty replica specs": { "empty replica specs": {
job: v2.MPIJob{ job: v2beta1.MPIJob{
Spec: v2.MPIJobSpec{ Spec: v2beta1.MPIJobSpec{
SlotsPerWorker: newInt32(2), SlotsPerWorker: newInt32(2),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{}, MPIReplicaSpecs: map[v2beta1.MPIReplicaType]*common.ReplicaSpec{},
}, },
}, },
wantErrs: field.ErrorList{ wantErrs: field.ErrorList{
@ -106,13 +106,13 @@ func TestValidateMPIJob(t *testing.T) {
}, },
}, },
"missing replica spec fields": { "missing replica spec fields": {
job: v2.MPIJob{ job: v2beta1.MPIJob{
Spec: v2.MPIJobSpec{ Spec: v2beta1.MPIJobSpec{
SlotsPerWorker: newInt32(2), SlotsPerWorker: newInt32(2),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{ MPIReplicaSpecs: map[v2beta1.MPIReplicaType]*common.ReplicaSpec{
v2.MPIReplicaTypeLauncher: {}, v2beta1.MPIReplicaTypeLauncher: {},
v2.MPIReplicaTypeWorker: {}, v2beta1.MPIReplicaTypeWorker: {},
}, },
}, },
}, },

View File

@ -19,7 +19,7 @@ package versioned
import ( import (
"fmt" "fmt"
kubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2" kubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2beta1"
discovery "k8s.io/client-go/discovery" discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol" flowcontrol "k8s.io/client-go/util/flowcontrol"
@ -27,19 +27,19 @@ import (
type Interface interface { type Interface interface {
Discovery() discovery.DiscoveryInterface Discovery() discovery.DiscoveryInterface
KubeflowV2() kubeflowv2.KubeflowV2Interface KubeflowV2beta1() kubeflowv2beta1.KubeflowV2beta1Interface
} }
// Clientset contains the clients for groups. Each group has exactly one // Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset. // version included in a Clientset.
type Clientset struct { type Clientset struct {
*discovery.DiscoveryClient *discovery.DiscoveryClient
kubeflowV2 *kubeflowv2.KubeflowV2Client kubeflowV2beta1 *kubeflowv2beta1.KubeflowV2beta1Client
} }
// KubeflowV2 retrieves the KubeflowV2Client // KubeflowV2beta1 retrieves the KubeflowV2beta1Client
func (c *Clientset) KubeflowV2() kubeflowv2.KubeflowV2Interface { func (c *Clientset) KubeflowV2beta1() kubeflowv2beta1.KubeflowV2beta1Interface {
return c.kubeflowV2 return c.kubeflowV2beta1
} }
// Discovery retrieves the DiscoveryClient // Discovery retrieves the DiscoveryClient
@ -63,7 +63,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
} }
var cs Clientset var cs Clientset
var err error var err error
cs.kubeflowV2, err = kubeflowv2.NewForConfig(&configShallowCopy) cs.kubeflowV2beta1, err = kubeflowv2beta1.NewForConfig(&configShallowCopy)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -79,7 +79,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset { func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset var cs Clientset
cs.kubeflowV2 = kubeflowv2.NewForConfigOrDie(c) cs.kubeflowV2beta1 = kubeflowv2beta1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs return &cs
@ -88,7 +88,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
// New creates a new Clientset for the given RESTClient. // New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset { func New(c rest.Interface) *Clientset {
var cs Clientset var cs Clientset
cs.kubeflowV2 = kubeflowv2.New(c) cs.kubeflowV2beta1 = kubeflowv2beta1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs return &cs

View File

@ -18,8 +18,8 @@ package fake
import ( import (
clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned" clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned"
kubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2" kubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2beta1"
fakekubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2/fake" fakekubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2beta1/fake"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"
@ -74,7 +74,7 @@ func (c *Clientset) Tracker() testing.ObjectTracker {
var _ clientset.Interface = &Clientset{} var _ clientset.Interface = &Clientset{}
// KubeflowV2 retrieves the KubeflowV2Client // KubeflowV2beta1 retrieves the KubeflowV2beta1Client
func (c *Clientset) KubeflowV2() kubeflowv2.KubeflowV2Interface { func (c *Clientset) KubeflowV2beta1() kubeflowv2beta1.KubeflowV2beta1Interface {
return &fakekubeflowv2.FakeKubeflowV2{Fake: &c.Fake} return &fakekubeflowv2beta1.FakeKubeflowV2beta1{Fake: &c.Fake}
} }

View File

@ -17,7 +17,7 @@
package fake package fake
import ( import (
kubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
@ -29,7 +29,7 @@ var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme) var codecs = serializer.NewCodecFactory(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{ var localSchemeBuilder = runtime.SchemeBuilder{
kubeflowv2.AddToScheme, kubeflowv2beta1.AddToScheme,
} }
// AddToScheme adds all types of this clientset into the given scheme. This allows composition // AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@ -17,7 +17,7 @@
package scheme package scheme
import ( import (
kubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
@ -29,7 +29,7 @@ var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme) var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{ var localSchemeBuilder = runtime.SchemeBuilder{
kubeflowv2.AddToScheme, kubeflowv2beta1.AddToScheme,
} }
// AddToScheme adds all types of this clientset into the given scheme. This allows composition // AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@ -15,4 +15,4 @@
// Code generated by client-gen. DO NOT EDIT. // Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients. // This package has the automatically generated typed clients.
package v2 package v2beta1

View File

@ -17,22 +17,22 @@
package fake package fake
import ( import (
v2 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/typed/kubeflow/v2beta1"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
) )
type FakeKubeflowV2 struct { type FakeKubeflowV2beta1 struct {
*testing.Fake *testing.Fake
} }
func (c *FakeKubeflowV2) MPIJobs(namespace string) v2.MPIJobInterface { func (c *FakeKubeflowV2beta1) MPIJobs(namespace string) v2beta1.MPIJobInterface {
return &FakeMPIJobs{c, namespace} return &FakeMPIJobs{c, namespace}
} }
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *FakeKubeflowV2) RESTClient() rest.Interface { func (c *FakeKubeflowV2beta1) RESTClient() rest.Interface {
var ret *rest.RESTClient var ret *rest.RESTClient
return ret return ret
} }

View File

@ -19,7 +19,7 @@ package fake
import ( import (
"context" "context"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels" labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
@ -30,29 +30,29 @@ import (
// FakeMPIJobs implements MPIJobInterface // FakeMPIJobs implements MPIJobInterface
type FakeMPIJobs struct { type FakeMPIJobs struct {
Fake *FakeKubeflowV2 Fake *FakeKubeflowV2beta1
ns string ns string
} }
var mpijobsResource = schema.GroupVersionResource{Group: "kubeflow.org", Version: "v2", Resource: "mpijobs"} var mpijobsResource = schema.GroupVersionResource{Group: "kubeflow.org", Version: "v2beta1", Resource: "mpijobs"}
var mpijobsKind = schema.GroupVersionKind{Group: "kubeflow.org", Version: "v2", Kind: "MPIJob"} var mpijobsKind = schema.GroupVersionKind{Group: "kubeflow.org", Version: "v2beta1", Kind: "MPIJob"}
// Get takes name of the mPIJob, and returns the corresponding mPIJob object, and an error if there is any. // Get takes name of the mPIJob, and returns the corresponding mPIJob object, and an error if there is any.
func (c *FakeMPIJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.MPIJob, err error) { func (c *FakeMPIJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.MPIJob, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewGetAction(mpijobsResource, c.ns, name), &v2.MPIJob{}) Invokes(testing.NewGetAction(mpijobsResource, c.ns, name), &v2beta1.MPIJob{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v2.MPIJob), err return obj.(*v2beta1.MPIJob), err
} }
// List takes label and field selectors, and returns the list of MPIJobs that match those selectors. // List takes label and field selectors, and returns the list of MPIJobs that match those selectors.
func (c *FakeMPIJobs) List(ctx context.Context, opts v1.ListOptions) (result *v2.MPIJobList, err error) { func (c *FakeMPIJobs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.MPIJobList, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewListAction(mpijobsResource, mpijobsKind, c.ns, opts), &v2.MPIJobList{}) Invokes(testing.NewListAction(mpijobsResource, mpijobsKind, c.ns, opts), &v2beta1.MPIJobList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
@ -62,8 +62,8 @@ func (c *FakeMPIJobs) List(ctx context.Context, opts v1.ListOptions) (result *v2
if label == nil { if label == nil {
label = labels.Everything() label = labels.Everything()
} }
list := &v2.MPIJobList{ListMeta: obj.(*v2.MPIJobList).ListMeta} list := &v2beta1.MPIJobList{ListMeta: obj.(*v2beta1.MPIJobList).ListMeta}
for _, item := range obj.(*v2.MPIJobList).Items { for _, item := range obj.(*v2beta1.MPIJobList).Items {
if label.Matches(labels.Set(item.Labels)) { if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item) list.Items = append(list.Items, item)
} }
@ -79,43 +79,43 @@ func (c *FakeMPIJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Int
} }
// Create takes the representation of a mPIJob and creates it. Returns the server's representation of the mPIJob, and an error, if there is any. // Create takes the representation of a mPIJob and creates it. Returns the server's representation of the mPIJob, and an error, if there is any.
func (c *FakeMPIJobs) Create(ctx context.Context, mPIJob *v2.MPIJob, opts v1.CreateOptions) (result *v2.MPIJob, err error) { func (c *FakeMPIJobs) Create(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.CreateOptions) (result *v2beta1.MPIJob, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewCreateAction(mpijobsResource, c.ns, mPIJob), &v2.MPIJob{}) Invokes(testing.NewCreateAction(mpijobsResource, c.ns, mPIJob), &v2beta1.MPIJob{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v2.MPIJob), err return obj.(*v2beta1.MPIJob), err
} }
// Update takes the representation of a mPIJob and updates it. Returns the server's representation of the mPIJob, and an error, if there is any. // Update takes the representation of a mPIJob and updates it. Returns the server's representation of the mPIJob, and an error, if there is any.
func (c *FakeMPIJobs) Update(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (result *v2.MPIJob, err error) { func (c *FakeMPIJobs) Update(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (result *v2beta1.MPIJob, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateAction(mpijobsResource, c.ns, mPIJob), &v2.MPIJob{}) Invokes(testing.NewUpdateAction(mpijobsResource, c.ns, mPIJob), &v2beta1.MPIJob{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v2.MPIJob), err return obj.(*v2beta1.MPIJob), err
} }
// UpdateStatus was generated because the type contains a Status member. // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeMPIJobs) UpdateStatus(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (*v2.MPIJob, error) { func (c *FakeMPIJobs) UpdateStatus(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (*v2beta1.MPIJob, error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(mpijobsResource, "status", c.ns, mPIJob), &v2.MPIJob{}) Invokes(testing.NewUpdateSubresourceAction(mpijobsResource, "status", c.ns, mPIJob), &v2beta1.MPIJob{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v2.MPIJob), err return obj.(*v2beta1.MPIJob), err
} }
// Delete takes name of the mPIJob and deletes it. Returns an error if one occurs. // Delete takes name of the mPIJob and deletes it. Returns an error if one occurs.
func (c *FakeMPIJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { func (c *FakeMPIJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake. _, err := c.Fake.
Invokes(testing.NewDeleteAction(mpijobsResource, c.ns, name), &v2.MPIJob{}) Invokes(testing.NewDeleteAction(mpijobsResource, c.ns, name), &v2beta1.MPIJob{})
return err return err
} }
@ -124,17 +124,17 @@ func (c *FakeMPIJobs) Delete(ctx context.Context, name string, opts v1.DeleteOpt
func (c *FakeMPIJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { func (c *FakeMPIJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(mpijobsResource, c.ns, listOpts) action := testing.NewDeleteCollectionAction(mpijobsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v2.MPIJobList{}) _, err := c.Fake.Invokes(action, &v2beta1.MPIJobList{})
return err return err
} }
// Patch applies the patch and returns the patched mPIJob. // Patch applies the patch and returns the patched mPIJob.
func (c *FakeMPIJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.MPIJob, err error) { func (c *FakeMPIJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.MPIJob, err error) {
obj, err := c.Fake. obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(mpijobsResource, c.ns, name, pt, data, subresources...), &v2.MPIJob{}) Invokes(testing.NewPatchSubresourceAction(mpijobsResource, c.ns, name, pt, data, subresources...), &v2beta1.MPIJob{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v2.MPIJob), err return obj.(*v2beta1.MPIJob), err
} }

View File

@ -14,6 +14,6 @@
// Code generated by client-gen. DO NOT EDIT. // Code generated by client-gen. DO NOT EDIT.
package v2 package v2beta1
type MPIJobExpansion interface{} type MPIJobExpansion interface{}

View File

@ -14,30 +14,30 @@
// Code generated by client-gen. DO NOT EDIT. // Code generated by client-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme" "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
) )
type KubeflowV2Interface interface { type KubeflowV2beta1Interface interface {
RESTClient() rest.Interface RESTClient() rest.Interface
MPIJobsGetter MPIJobsGetter
} }
// KubeflowV2Client is used to interact with features provided by the kubeflow.org group. // KubeflowV2beta1Client is used to interact with features provided by the kubeflow.org group.
type KubeflowV2Client struct { type KubeflowV2beta1Client struct {
restClient rest.Interface restClient rest.Interface
} }
func (c *KubeflowV2Client) MPIJobs(namespace string) MPIJobInterface { func (c *KubeflowV2beta1Client) MPIJobs(namespace string) MPIJobInterface {
return newMPIJobs(c, namespace) return newMPIJobs(c, namespace)
} }
// NewForConfig creates a new KubeflowV2Client for the given config. // NewForConfig creates a new KubeflowV2beta1Client for the given config.
func NewForConfig(c *rest.Config) (*KubeflowV2Client, error) { func NewForConfig(c *rest.Config) (*KubeflowV2beta1Client, error) {
config := *c config := *c
if err := setConfigDefaults(&config); err != nil { if err := setConfigDefaults(&config); err != nil {
return nil, err return nil, err
@ -46,12 +46,12 @@ func NewForConfig(c *rest.Config) (*KubeflowV2Client, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &KubeflowV2Client{client}, nil return &KubeflowV2beta1Client{client}, nil
} }
// NewForConfigOrDie creates a new KubeflowV2Client for the given config and // NewForConfigOrDie creates a new KubeflowV2beta1Client for the given config and
// panics if there is an error in the config. // panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *KubeflowV2Client { func NewForConfigOrDie(c *rest.Config) *KubeflowV2beta1Client {
client, err := NewForConfig(c) client, err := NewForConfig(c)
if err != nil { if err != nil {
panic(err) panic(err)
@ -59,13 +59,13 @@ func NewForConfigOrDie(c *rest.Config) *KubeflowV2Client {
return client return client
} }
// New creates a new KubeflowV2Client for the given RESTClient. // New creates a new KubeflowV2beta1Client for the given RESTClient.
func New(c rest.Interface) *KubeflowV2Client { func New(c rest.Interface) *KubeflowV2beta1Client {
return &KubeflowV2Client{c} return &KubeflowV2beta1Client{c}
} }
func setConfigDefaults(config *rest.Config) error { func setConfigDefaults(config *rest.Config) error {
gv := v2.SchemeGroupVersion gv := v2beta1.SchemeGroupVersion
config.GroupVersion = &gv config.GroupVersion = &gv
config.APIPath = "/apis" config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
@ -79,7 +79,7 @@ func setConfigDefaults(config *rest.Config) error {
// RESTClient returns a RESTClient that is used to communicate // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. // with API server by this client implementation.
func (c *KubeflowV2Client) RESTClient() rest.Interface { func (c *KubeflowV2beta1Client) RESTClient() rest.Interface {
if c == nil { if c == nil {
return nil return nil
} }

View File

@ -14,13 +14,13 @@
// Code generated by client-gen. DO NOT EDIT. // Code generated by client-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
"context" "context"
"time" "time"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
scheme "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme" scheme "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
@ -36,15 +36,15 @@ type MPIJobsGetter interface {
// MPIJobInterface has methods to work with MPIJob resources. // MPIJobInterface has methods to work with MPIJob resources.
type MPIJobInterface interface { type MPIJobInterface interface {
Create(ctx context.Context, mPIJob *v2.MPIJob, opts v1.CreateOptions) (*v2.MPIJob, error) Create(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.CreateOptions) (*v2beta1.MPIJob, error)
Update(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (*v2.MPIJob, error) Update(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (*v2beta1.MPIJob, error)
UpdateStatus(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (*v2.MPIJob, error) UpdateStatus(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (*v2beta1.MPIJob, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v2.MPIJob, error) Get(ctx context.Context, name string, opts v1.GetOptions) (*v2beta1.MPIJob, error)
List(ctx context.Context, opts v1.ListOptions) (*v2.MPIJobList, error) List(ctx context.Context, opts v1.ListOptions) (*v2beta1.MPIJobList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.MPIJob, err error) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.MPIJob, err error)
MPIJobExpansion MPIJobExpansion
} }
@ -55,7 +55,7 @@ type mPIJobs struct {
} }
// newMPIJobs returns a MPIJobs // newMPIJobs returns a MPIJobs
func newMPIJobs(c *KubeflowV2Client, namespace string) *mPIJobs { func newMPIJobs(c *KubeflowV2beta1Client, namespace string) *mPIJobs {
return &mPIJobs{ return &mPIJobs{
client: c.RESTClient(), client: c.RESTClient(),
ns: namespace, ns: namespace,
@ -63,8 +63,8 @@ func newMPIJobs(c *KubeflowV2Client, namespace string) *mPIJobs {
} }
// Get takes name of the mPIJob, and returns the corresponding mPIJob object, and an error if there is any. // Get takes name of the mPIJob, and returns the corresponding mPIJob object, and an error if there is any.
func (c *mPIJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.MPIJob, err error) { func (c *mPIJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.MPIJob, err error) {
result = &v2.MPIJob{} result = &v2beta1.MPIJob{}
err = c.client.Get(). err = c.client.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").
@ -76,12 +76,12 @@ func (c *mPIJobs) Get(ctx context.Context, name string, options v1.GetOptions) (
} }
// List takes label and field selectors, and returns the list of MPIJobs that match those selectors. // List takes label and field selectors, and returns the list of MPIJobs that match those selectors.
func (c *mPIJobs) List(ctx context.Context, opts v1.ListOptions) (result *v2.MPIJobList, err error) { func (c *mPIJobs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.MPIJobList, err error) {
var timeout time.Duration var timeout time.Duration
if opts.TimeoutSeconds != nil { if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
} }
result = &v2.MPIJobList{} result = &v2beta1.MPIJobList{}
err = c.client.Get(). err = c.client.Get().
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").
@ -108,8 +108,8 @@ func (c *mPIJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interfa
} }
// Create takes the representation of a mPIJob and creates it. Returns the server's representation of the mPIJob, and an error, if there is any. // Create takes the representation of a mPIJob and creates it. Returns the server's representation of the mPIJob, and an error, if there is any.
func (c *mPIJobs) Create(ctx context.Context, mPIJob *v2.MPIJob, opts v1.CreateOptions) (result *v2.MPIJob, err error) { func (c *mPIJobs) Create(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.CreateOptions) (result *v2beta1.MPIJob, err error) {
result = &v2.MPIJob{} result = &v2beta1.MPIJob{}
err = c.client.Post(). err = c.client.Post().
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").
@ -121,8 +121,8 @@ func (c *mPIJobs) Create(ctx context.Context, mPIJob *v2.MPIJob, opts v1.CreateO
} }
// Update takes the representation of a mPIJob and updates it. Returns the server's representation of the mPIJob, and an error, if there is any. // Update takes the representation of a mPIJob and updates it. Returns the server's representation of the mPIJob, and an error, if there is any.
func (c *mPIJobs) Update(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (result *v2.MPIJob, err error) { func (c *mPIJobs) Update(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (result *v2beta1.MPIJob, err error) {
result = &v2.MPIJob{} result = &v2beta1.MPIJob{}
err = c.client.Put(). err = c.client.Put().
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").
@ -136,8 +136,8 @@ func (c *mPIJobs) Update(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateO
// UpdateStatus was generated because the type contains a Status member. // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *mPIJobs) UpdateStatus(ctx context.Context, mPIJob *v2.MPIJob, opts v1.UpdateOptions) (result *v2.MPIJob, err error) { func (c *mPIJobs) UpdateStatus(ctx context.Context, mPIJob *v2beta1.MPIJob, opts v1.UpdateOptions) (result *v2beta1.MPIJob, err error) {
result = &v2.MPIJob{} result = &v2beta1.MPIJob{}
err = c.client.Put(). err = c.client.Put().
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").
@ -178,8 +178,8 @@ func (c *mPIJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, l
} }
// Patch applies the patch and returns the patched mPIJob. // Patch applies the patch and returns the patched mPIJob.
func (c *mPIJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.MPIJob, err error) { func (c *mPIJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.MPIJob, err error) {
result = &v2.MPIJob{} result = &v2beta1.MPIJob{}
err = c.client.Patch(pt). err = c.client.Patch(pt).
Namespace(c.ns). Namespace(c.ns).
Resource("mpijobs"). Resource("mpijobs").

View File

@ -19,7 +19,7 @@ package externalversions
import ( import (
"fmt" "fmt"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
) )
@ -50,9 +50,9 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool // TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource { switch resource {
// Group=kubeflow.org, Version=v2 // Group=kubeflow.org, Version=v2beta1
case v2.SchemeGroupVersion.WithResource("mpijobs"): case v2beta1.SchemeGroupVersion.WithResource("mpijobs"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Kubeflow().V2().MPIJobs().Informer()}, nil return &genericInformer{resource: resource.GroupResource(), informer: f.Kubeflow().V2beta1().MPIJobs().Informer()}, nil
} }

View File

@ -18,13 +18,13 @@ package kubeflow
import ( import (
internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces" internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/kubeflow/v2beta1"
) )
// Interface provides access to each of this group's versions. // Interface provides access to each of this group's versions.
type Interface interface { type Interface interface {
// V2 provides access to shared informers for resources in V2. // V2beta1 provides access to shared informers for resources in V2beta1.
V2() v2.Interface V2beta1() v2beta1.Interface
} }
type group struct { type group struct {
@ -38,7 +38,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
} }
// V2 returns a new v2.Interface. // V2beta1 returns a new v2beta1.Interface.
func (g *group) V2() v2.Interface { func (g *group) V2beta1() v2beta1.Interface {
return v2.New(g.factory, g.namespace, g.tweakListOptions) return v2beta1.New(g.factory, g.namespace, g.tweakListOptions)
} }

View File

@ -14,7 +14,7 @@
// Code generated by informer-gen. DO NOT EDIT. // Code generated by informer-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces" internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces"

View File

@ -14,16 +14,16 @@
// Code generated by informer-gen. DO NOT EDIT. // Code generated by informer-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
"context" "context"
time "time" time "time"
kubeflowv2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflowv2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
versioned "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned" versioned "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned"
internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces" internalinterfaces "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/internalinterfaces"
v2 "github.com/kubeflow/mpi-operator/v2/pkg/client/listers/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/client/listers/kubeflow/v2beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"
@ -34,7 +34,7 @@ import (
// MPIJobs. // MPIJobs.
type MPIJobInformer interface { type MPIJobInformer interface {
Informer() cache.SharedIndexInformer Informer() cache.SharedIndexInformer
Lister() v2.MPIJobLister Lister() v2beta1.MPIJobLister
} }
type mPIJobInformer struct { type mPIJobInformer struct {
@ -60,16 +60,16 @@ func NewFilteredMPIJobInformer(client versioned.Interface, namespace string, res
if tweakListOptions != nil { if tweakListOptions != nil {
tweakListOptions(&options) tweakListOptions(&options)
} }
return client.KubeflowV2().MPIJobs(namespace).List(context.TODO(), options) return client.KubeflowV2beta1().MPIJobs(namespace).List(context.TODO(), options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil { if tweakListOptions != nil {
tweakListOptions(&options) tweakListOptions(&options)
} }
return client.KubeflowV2().MPIJobs(namespace).Watch(context.TODO(), options) return client.KubeflowV2beta1().MPIJobs(namespace).Watch(context.TODO(), options)
}, },
}, },
&kubeflowv2.MPIJob{}, &kubeflowv2beta1.MPIJob{},
resyncPeriod, resyncPeriod,
indexers, indexers,
) )
@ -80,9 +80,9 @@ func (f *mPIJobInformer) defaultInformer(client versioned.Interface, resyncPerio
} }
func (f *mPIJobInformer) Informer() cache.SharedIndexInformer { func (f *mPIJobInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&kubeflowv2.MPIJob{}, f.defaultInformer) return f.factory.InformerFor(&kubeflowv2beta1.MPIJob{}, f.defaultInformer)
} }
func (f *mPIJobInformer) Lister() v2.MPIJobLister { func (f *mPIJobInformer) Lister() v2beta1.MPIJobLister {
return v2.NewMPIJobLister(f.Informer().GetIndexer()) return v2beta1.NewMPIJobLister(f.Informer().GetIndexer())
} }

View File

@ -14,7 +14,7 @@
// Code generated by lister-gen. DO NOT EDIT. // Code generated by lister-gen. DO NOT EDIT.
package v2 package v2beta1
// MPIJobListerExpansion allows custom methods to be added to // MPIJobListerExpansion allows custom methods to be added to
// MPIJobLister. // MPIJobLister.

View File

@ -14,10 +14,10 @@
// Code generated by lister-gen. DO NOT EDIT. // Code generated by lister-gen. DO NOT EDIT.
package v2 package v2beta1
import ( import (
v2 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" v2beta1 "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@ -28,7 +28,7 @@ import (
type MPIJobLister interface { type MPIJobLister interface {
// List lists all MPIJobs in the indexer. // List lists all MPIJobs in the indexer.
// Objects returned here must be treated as read-only. // Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2.MPIJob, err error) List(selector labels.Selector) (ret []*v2beta1.MPIJob, err error)
// MPIJobs returns an object that can list and get MPIJobs. // MPIJobs returns an object that can list and get MPIJobs.
MPIJobs(namespace string) MPIJobNamespaceLister MPIJobs(namespace string) MPIJobNamespaceLister
MPIJobListerExpansion MPIJobListerExpansion
@ -45,9 +45,9 @@ func NewMPIJobLister(indexer cache.Indexer) MPIJobLister {
} }
// List lists all MPIJobs in the indexer. // List lists all MPIJobs in the indexer.
func (s *mPIJobLister) List(selector labels.Selector) (ret []*v2.MPIJob, err error) { func (s *mPIJobLister) List(selector labels.Selector) (ret []*v2beta1.MPIJob, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) { err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2.MPIJob)) ret = append(ret, m.(*v2beta1.MPIJob))
}) })
return ret, err return ret, err
} }
@ -62,10 +62,10 @@ func (s *mPIJobLister) MPIJobs(namespace string) MPIJobNamespaceLister {
type MPIJobNamespaceLister interface { type MPIJobNamespaceLister interface {
// List lists all MPIJobs in the indexer for a given namespace. // List lists all MPIJobs in the indexer for a given namespace.
// Objects returned here must be treated as read-only. // Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2.MPIJob, err error) List(selector labels.Selector) (ret []*v2beta1.MPIJob, err error)
// Get retrieves the MPIJob from the indexer for a given namespace and name. // Get retrieves the MPIJob from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only. // Objects returned here must be treated as read-only.
Get(name string) (*v2.MPIJob, error) Get(name string) (*v2beta1.MPIJob, error)
MPIJobNamespaceListerExpansion MPIJobNamespaceListerExpansion
} }
@ -77,21 +77,21 @@ type mPIJobNamespaceLister struct {
} }
// List lists all MPIJobs in the indexer for a given namespace. // List lists all MPIJobs in the indexer for a given namespace.
func (s mPIJobNamespaceLister) List(selector labels.Selector) (ret []*v2.MPIJob, err error) { func (s mPIJobNamespaceLister) List(selector labels.Selector) (ret []*v2beta1.MPIJob, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v2.MPIJob)) ret = append(ret, m.(*v2beta1.MPIJob))
}) })
return ret, err return ret, err
} }
// Get retrieves the MPIJob from the indexer for a given namespace and name. // Get retrieves the MPIJob from the indexer for a given namespace and name.
func (s mPIJobNamespaceLister) Get(name string) (*v2.MPIJob, error) { func (s mPIJobNamespaceLister) Get(name string) (*v2beta1.MPIJob, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !exists { if !exists {
return nil, errors.NewNotFound(v2.Resource("mpijob"), name) return nil, errors.NewNotFound(v2beta1.Resource("mpijob"), name)
} }
return obj.(*v2.MPIJob), nil return obj.(*v2beta1.MPIJob), nil
} }

View File

@ -55,12 +55,12 @@ import (
podgroupslists "volcano.sh/apis/pkg/client/listers/scheduling/v1beta1" podgroupslists "volcano.sh/apis/pkg/client/listers/scheduling/v1beta1"
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"
kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
"github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/validation" "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/validation"
clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned" clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme" "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/kubeflow/v2" informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions/kubeflow/v2beta1"
listers "github.com/kubeflow/mpi-operator/v2/pkg/client/listers/kubeflow/v2" listers "github.com/kubeflow/mpi-operator/v2/pkg/client/listers/kubeflow/v2beta1"
) )
const ( const (
@ -1030,7 +1030,7 @@ func (c *MPIJobController) handleObjectUpdate(old, new interface{}) {
// doUpdateJobStatus updates the status of the given MPIJob by call apiServer. // doUpdateJobStatus updates the status of the given MPIJob by call apiServer.
func (c *MPIJobController) doUpdateJobStatus(mpiJob *kubeflow.MPIJob) error { func (c *MPIJobController) doUpdateJobStatus(mpiJob *kubeflow.MPIJob) error {
_, err := c.kubeflowClient.KubeflowV2().MPIJobs(mpiJob.Namespace).UpdateStatus(context.TODO(), mpiJob, metav1.UpdateOptions{}) _, err := c.kubeflowClient.KubeflowV2beta1().MPIJobs(mpiJob.Namespace).UpdateStatus(context.TODO(), mpiJob, metav1.UpdateOptions{})
return err return err
} }

View File

@ -19,7 +19,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"
kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
) )
const ( const (

View File

@ -36,7 +36,7 @@ import (
volcanoinformers "volcano.sh/apis/pkg/client/informers/externalversions" volcanoinformers "volcano.sh/apis/pkg/client/informers/externalversions"
common "github.com/kubeflow/common/pkg/apis/common/v1" common "github.com/kubeflow/common/pkg/apis/common/v1"
kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2" kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/fake" "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/fake"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme" "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions" informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions"
@ -190,7 +190,7 @@ func (f *fixture) newController(gangSchedulerName string) (*MPIJobController, in
k8sI.Core().V1().Services(), k8sI.Core().V1().Services(),
k8sI.Core().V1().Pods(), k8sI.Core().V1().Pods(),
podgroupsInformer, podgroupsInformer,
i.Kubeflow().V2().MPIJobs(), i.Kubeflow().V2beta1().MPIJobs(),
gangSchedulerName, gangSchedulerName,
) )
@ -238,7 +238,7 @@ func (f *fixture) newController(gangSchedulerName string) (*MPIJobController, in
} }
for _, mpiJob := range f.mpiJobLister { for _, mpiJob := range f.mpiJobLister {
err := i.Kubeflow().V2().MPIJobs().Informer().GetIndexer().Add(mpiJob) err := i.Kubeflow().V2beta1().MPIJobs().Informer().GetIndexer().Add(mpiJob)
if err != nil { if err != nil {
fmt.Println("Failed to create mpijob") fmt.Println("Failed to create mpijob")
} }

View File

@ -22,12 +22,6 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
common "github.com/kubeflow/common/pkg/apis/common/v1"
"github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2"
clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions"
"github.com/kubeflow/mpi-operator/v2/pkg/controller"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
@ -36,6 +30,13 @@ import (
kubeinformers "k8s.io/client-go/informers" kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/reference" "k8s.io/client-go/tools/reference"
common "github.com/kubeflow/common/pkg/apis/common/v1"
kubeflow "github.com/kubeflow/mpi-operator/v2/pkg/apis/kubeflow/v2beta1"
clientset "github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned"
"github.com/kubeflow/mpi-operator/v2/pkg/client/clientset/versioned/scheme"
informers "github.com/kubeflow/mpi-operator/v2/pkg/client/informers/externalversions"
"github.com/kubeflow/mpi-operator/v2/pkg/controller"
) )
const ( const (
@ -48,16 +49,16 @@ func TestMPIJobSuccess(t *testing.T) {
s := newTestSetup(ctx, t) s := newTestSetup(ctx, t)
startController(ctx, s.kClient, s.mpiClient) startController(ctx, s.kClient, s.mpiClient)
mpiJob := &v2.MPIJob{ mpiJob := &kubeflow.MPIJob{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "job", Name: "job",
Namespace: s.namespace, Namespace: s.namespace,
}, },
Spec: v2.MPIJobSpec{ Spec: kubeflow.MPIJobSpec{
SlotsPerWorker: newInt32(1), SlotsPerWorker: newInt32(1),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{ MPIReplicaSpecs: map[kubeflow.MPIReplicaType]*common.ReplicaSpec{
v2.MPIReplicaTypeLauncher: { kubeflow.MPIReplicaTypeLauncher: {
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
Containers: []corev1.Container{ Containers: []corev1.Container{
@ -69,7 +70,7 @@ func TestMPIJobSuccess(t *testing.T) {
}, },
}, },
}, },
v2.MPIReplicaTypeWorker: { kubeflow.MPIReplicaTypeWorker: {
Replicas: newInt32(2), Replicas: newInt32(2),
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
@ -86,7 +87,7 @@ func TestMPIJobSuccess(t *testing.T) {
}, },
} }
var err error var err error
mpiJob, err = s.mpiClient.KubeflowV2().MPIJobs(s.namespace).Create(ctx, mpiJob, metav1.CreateOptions{}) mpiJob, err = s.mpiClient.KubeflowV2beta1().MPIJobs(s.namespace).Create(ctx, mpiJob, metav1.CreateOptions{})
if err != nil { if err != nil {
t.Fatalf("Failed sending job to apiserver: %v", err) t.Fatalf("Failed sending job to apiserver: %v", err)
} }
@ -98,8 +99,8 @@ func TestMPIJobSuccess(t *testing.T) {
podsByRole := validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 2) podsByRole := validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 2)
validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{ validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(v2.MPIReplicaTypeLauncher): {}, common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {},
common.ReplicaType(v2.MPIReplicaTypeWorker): {}, common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {},
}) })
s.events.verify(t) s.events.verify(t)
@ -108,8 +109,8 @@ func TestMPIJobSuccess(t *testing.T) {
t.Fatalf("Updating worker Pods to Running phase: %v", err) t.Fatalf("Updating worker Pods to Running phase: %v", err)
} }
validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{ validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(v2.MPIReplicaTypeLauncher): {}, common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {},
common.ReplicaType(v2.MPIReplicaTypeWorker): { common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {
Active: 2, Active: 2,
}, },
}) })
@ -122,10 +123,10 @@ func TestMPIJobSuccess(t *testing.T) {
t.Fatalf("Updating launcher Pods to Running phase: %v", err) t.Fatalf("Updating launcher Pods to Running phase: %v", err)
} }
validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{ validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(v2.MPIReplicaTypeLauncher): { common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {
Active: 1, Active: 1,
}, },
common.ReplicaType(v2.MPIReplicaTypeWorker): { common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {
Active: 2, Active: 2,
}, },
}) })
@ -141,10 +142,10 @@ func TestMPIJobSuccess(t *testing.T) {
} }
validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 0) validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 0)
validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{ validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(v2.MPIReplicaTypeLauncher): { common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {
Succeeded: 1, Succeeded: 1,
}, },
common.ReplicaType(v2.MPIReplicaTypeWorker): {}, common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {},
}) })
s.events.verify(t) s.events.verify(t)
} }
@ -155,16 +156,16 @@ func TestMPIJobFailure(t *testing.T) {
s := newTestSetup(ctx, t) s := newTestSetup(ctx, t)
startController(ctx, s.kClient, s.mpiClient) startController(ctx, s.kClient, s.mpiClient)
mpiJob := &v2.MPIJob{ mpiJob := &kubeflow.MPIJob{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "job", Name: "job",
Namespace: s.namespace, Namespace: s.namespace,
}, },
Spec: v2.MPIJobSpec{ Spec: kubeflow.MPIJobSpec{
SlotsPerWorker: newInt32(1), SlotsPerWorker: newInt32(1),
CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning), CleanPodPolicy: newCleanPodPolicy(common.CleanPodPolicyRunning),
MPIReplicaSpecs: map[v2.MPIReplicaType]*common.ReplicaSpec{ MPIReplicaSpecs: map[kubeflow.MPIReplicaType]*common.ReplicaSpec{
v2.MPIReplicaTypeLauncher: { kubeflow.MPIReplicaTypeLauncher: {
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
Containers: []corev1.Container{ Containers: []corev1.Container{
@ -176,7 +177,7 @@ func TestMPIJobFailure(t *testing.T) {
}, },
}, },
}, },
v2.MPIReplicaTypeWorker: { kubeflow.MPIReplicaTypeWorker: {
Replicas: newInt32(2), Replicas: newInt32(2),
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
@ -194,7 +195,7 @@ func TestMPIJobFailure(t *testing.T) {
} }
var err error var err error
mpiJob, err = s.mpiClient.KubeflowV2().MPIJobs(s.namespace).Create(ctx, mpiJob, metav1.CreateOptions{}) mpiJob, err = s.mpiClient.KubeflowV2beta1().MPIJobs(s.namespace).Create(ctx, mpiJob, metav1.CreateOptions{})
if err != nil { if err != nil {
t.Fatalf("Failed sending job to apiserver: %v", err) t.Fatalf("Failed sending job to apiserver: %v", err)
} }
@ -218,10 +219,10 @@ func TestMPIJobFailure(t *testing.T) {
err = updatePodsToPhase(ctx, s.kClient, podsByRole["launcher"], corev1.PodFailed) err = updatePodsToPhase(ctx, s.kClient, podsByRole["launcher"], corev1.PodFailed)
validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 0) validateMPIJobDependencies(ctx, t, s.kClient, mpiJob, 0)
validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{ validateMPIJobStatus(ctx, t, s.mpiClient, mpiJob, map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(v2.MPIReplicaTypeLauncher): { common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {
Failed: 1, Failed: 1,
}, },
common.ReplicaType(v2.MPIReplicaTypeWorker): {}, common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {},
}) })
s.events.verify(t) s.events.verify(t)
} }
@ -238,7 +239,7 @@ func startController(ctx context.Context, kClient kubernetes.Interface, mpiClien
kubeInformerFactory.Core().V1().Services(), kubeInformerFactory.Core().V1().Services(),
kubeInformerFactory.Core().V1().Pods(), kubeInformerFactory.Core().V1().Pods(),
nil, nil,
mpiInformerFactory.Kubeflow().V2().MPIJobs(), mpiInformerFactory.Kubeflow().V2beta1().MPIJobs(),
"") "")
go kubeInformerFactory.Start(ctx.Done()) go kubeInformerFactory.Start(ctx.Done())
@ -247,7 +248,7 @@ func startController(ctx context.Context, kClient kubernetes.Interface, mpiClien
go ctrl.Run(1, ctx.Done()) go ctrl.Run(1, ctx.Done())
} }
func validateMPIJobDependencies(ctx context.Context, t *testing.T, kubeClient kubernetes.Interface, job *v2.MPIJob, workers int) map[string][]corev1.Pod { func validateMPIJobDependencies(ctx context.Context, t *testing.T, kubeClient kubernetes.Interface, job *kubeflow.MPIJob, workers int) map[string][]corev1.Pod {
t.Helper() t.Helper()
var ( var (
svc *corev1.Service svc *corev1.Service
@ -336,11 +337,11 @@ func validateMPIJobDependencies(ctx context.Context, t *testing.T, kubeClient ku
return podsByRole return podsByRole
} }
func validateMPIJobStatus(ctx context.Context, t *testing.T, client clientset.Interface, job *v2.MPIJob, want map[common.ReplicaType]*common.ReplicaStatus) { func validateMPIJobStatus(ctx context.Context, t *testing.T, client clientset.Interface, job *kubeflow.MPIJob, want map[common.ReplicaType]*common.ReplicaStatus) {
t.Helper() t.Helper()
var got map[common.ReplicaType]*common.ReplicaStatus var got map[common.ReplicaType]*common.ReplicaStatus
if err := wait.Poll(waitInterval, wait.ForeverTestTimeout, func() (bool, error) { if err := wait.Poll(waitInterval, wait.ForeverTestTimeout, func() (bool, error) {
newJob, err := client.KubeflowV2().MPIJobs(job.Namespace).Get(ctx, job.Name, metav1.GetOptions{}) newJob, err := client.KubeflowV2beta1().MPIJobs(job.Namespace).Get(ctx, job.Name, metav1.GetOptions{})
if err != nil { if err != nil {
return false, err return false, err
} }
@ -386,7 +387,7 @@ func diffCounts(gotMap map[string][]corev1.Pod, want map[string]int) string {
})) }))
} }
func getServiceForJob(ctx context.Context, client kubernetes.Interface, job *v2.MPIJob) (*corev1.Service, error) { func getServiceForJob(ctx context.Context, client kubernetes.Interface, job *kubeflow.MPIJob) (*corev1.Service, error) {
result, err := client.CoreV1().Services(job.Namespace).List(ctx, metav1.ListOptions{}) result, err := client.CoreV1().Services(job.Namespace).List(ctx, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
@ -399,7 +400,7 @@ func getServiceForJob(ctx context.Context, client kubernetes.Interface, job *v2.
return nil, nil return nil, nil
} }
func getConfigMapForJob(ctx context.Context, client kubernetes.Interface, job *v2.MPIJob) (*corev1.ConfigMap, error) { func getConfigMapForJob(ctx context.Context, client kubernetes.Interface, job *kubeflow.MPIJob) (*corev1.ConfigMap, error) {
result, err := client.CoreV1().ConfigMaps(job.Namespace).List(ctx, metav1.ListOptions{}) result, err := client.CoreV1().ConfigMaps(job.Namespace).List(ctx, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
@ -412,7 +413,7 @@ func getConfigMapForJob(ctx context.Context, client kubernetes.Interface, job *v
return nil, nil return nil, nil
} }
func getSecretForJob(ctx context.Context, client kubernetes.Interface, job *v2.MPIJob) (*corev1.Secret, error) { func getSecretForJob(ctx context.Context, client kubernetes.Interface, job *kubeflow.MPIJob) (*corev1.Secret, error) {
result, err := client.CoreV1().Secrets(job.Namespace).List(ctx, metav1.ListOptions{}) result, err := client.CoreV1().Secrets(job.Namespace).List(ctx, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
@ -425,7 +426,7 @@ func getSecretForJob(ctx context.Context, client kubernetes.Interface, job *v2.M
return nil, nil return nil, nil
} }
func getPodsForJob(ctx context.Context, client kubernetes.Interface, job *v2.MPIJob) ([]corev1.Pod, error) { func getPodsForJob(ctx context.Context, client kubernetes.Interface, job *kubeflow.MPIJob) ([]corev1.Pod, error) {
result, err := client.CoreV1().Pods(job.Namespace).List(ctx, metav1.ListOptions{}) result, err := client.CoreV1().Pods(job.Namespace).List(ctx, metav1.ListOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
@ -447,7 +448,7 @@ func newCleanPodPolicy(policy common.CleanPodPolicy) *common.CleanPodPolicy {
return &policy return &policy
} }
func eventForJob(event corev1.Event, job *v2.MPIJob) corev1.Event { func eventForJob(event corev1.Event, job *kubeflow.MPIJob) corev1.Event {
event.Namespace = job.Namespace event.Namespace = job.Namespace
event.Source.Component = "mpi-job-controller" event.Source.Component = "mpi-job-controller"
ref, err := reference.GetReference(scheme.Scheme, job) ref, err := reference.GetReference(scheme.Scheme, job)