diff --git a/controller/cmd/configurator/app/configurator.go b/controller/cmd/configurator/app/configurator.go index e8b4f6a80..d2e03ab1b 100644 --- a/controller/cmd/configurator/app/configurator.go +++ b/controller/cmd/configurator/app/configurator.go @@ -56,13 +56,16 @@ func (c *Configurator) Run(opt *AppOption) error { // Modify the manifest as specified by the kubebench job modSpec := configSpec.ManifestModSpec + // If the namespace in the ManifestModSpec is empty valued, replace it with // configurator's own namespace which is same as the workflow. This is for // cases when the ManifestModSpec is created before namespace is set. + if err := replaceEmptyNamespace(modSpec); err != nil { log.Errorf("Failed to replace empty namespace: %s", err) return err } + modifiedManifest, err := manifestmod.NewManifestModifier(modSpec).ModifyManifest(manifest) if err != nil { log.Errorf("Failed to modify manifest: %s", err) diff --git a/controller/examples/crd.yaml b/controller/examples/crd.yaml index a3cb6f0bf..10f0d6e11 100644 --- a/controller/examples/crd.yaml +++ b/controller/examples/crd.yaml @@ -1,11 +1,12 @@ apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: kubebenchjobs.kubebench.operator + name: kubebenchjobs.kubeflow.org + namespace: kubebench spec: - group: kubebench.operator - version: v1 + group: kubeflow.org names: kind: KubebenchJob plural: kubebenchjobs - scope: Namespaced \ No newline at end of file + scope: Namespaced + version: v1alpha2 \ No newline at end of file diff --git a/controller/examples/job-example.yaml b/controller/examples/job-example.yaml index 309a34989..09cf74b77 100644 --- a/controller/examples/job-example.yaml +++ b/controller/examples/job-example.yaml @@ -1,53 +1,70 @@ -#uncomment lines -apiVersion: kubebench.operator/v1 +apiVersion: kubeflow.org/v1alpha2 kind: KubebenchJob metadata: name: kubebench-job - namespace: default + namespace: kirill-kubebench spec: serviceAccount: default - volumeSpecs: - configVolume: - name: my-config-volume - persistentVolumeClaim: - claimName: kubebench-config-pvc + volumes: + - name: kubebench-config-volume + configMap: + name: kubebench-config-pvc + - name: kubebench-data-volume + persistentVolumeClaim: + claimName: kubebench-data-pvc + managedVolumes: experimentVolume: - name: my-experiment-volume + name: kubebench-experiment-volume + persistentVolumeClaim: + claimName: kubebench-experiment-pvc + workflowVolume: + name: kubebench-workflow-volume persistentVolumeClaim: - claimName: kubebench-exp-pvc - # secretSpecs: # optional - # githubTokenSecret: # optional - # secretName: my-github-token-secret - # secretKey: my-github-token-secret-key - # gcpCredentialsSecret: # optional - # secretName: my-gcp-credentials-secret - # secretKey: my-gcp-credentials-secret-key - jobSpecs: - preJob: # optional - container: # optional between "container" and "resource" - name: my-prejob - image: gcr.io/myprejob-image:latest # change it before using - mainJob: # mandatory - resource: # optional between "container" and "resource" - manifestTemplate: - valueFrom: - ksonnet: # optional, more types in the future - name: kubebench-example-tfcnn-with-monitoring - package: kubebench-examples - registry: /kubebench/config/registry/kubebench - manifestParameters: - valueFrom: - path: tf-cnn/tf-cnn-dummy.yaml - createSuccessCondition: createSuccess # optional - createFailureCondition: createFailure # optional - runSuccessCondition: runSuccess # optional - runFailureCondition: runFailure # optional - #other optional fields: "manifest" - string of raw manifest - postJob: # optional - container: # optional between "container" and "resource" - name: my-postjob - image: gcr.io/kubeflow-images-public/kubebench/kubebench-example-tf-cnn-post-processor:3c75b50 - reportSpecs: # optional - csv: # optional - - inputPath: result.json - outputPath: report.csv \ No newline at end of file + claimName: kubebench-workflow-pvc + workflowAgent: + container: + volumeMounts: + - name: kubebench-config-volume + mountPath: /kubebench/config + tasks: + - name: download-data + container: + name: download-dataset + image: kirill-mlperf-download-image:latest + volumeMounts: + - name: kubebench-data-volume + mountPath: /data + options: + mountManagedVolumes: true + autoWatch: + timeout: 5m + autoDelete: true + numCopies: 1 + - name: preprocess-data + container: + name: preprocess-dataset + image: kirill-mlperf-preprocess-image:latest + volumeMounts: + - name: kubebench-data-volume + mountPath: /data + options: + mountManagedVolumes: true + autoWatch: + timeout: 5m + autoDelete: true + numCopies: 1 + - name: run-training + dependencies: [pre-job-1, pre-job-2] + container: + name: run-training + image: kirill-mlperf-training-image:latest + volumeMounts: + - name: kubebench-data-volume + mountPath: /data + options: + mountManagedVolumes: true + autoWatch: + timeout: 5m + autoDelete: true + numCopies: 1 + diff --git a/controller/examples/mpi-job.yaml b/controller/examples/mpi-job.yaml new file mode 100644 index 000000000..a208251ae --- /dev/null +++ b/controller/examples/mpi-job.yaml @@ -0,0 +1,16 @@ +# This file shows how to run multi-node training benchmarks using an MPIJob, +# specifying GPUs explicitly per replica. +apiVersion: kubeflow.org/v1alpha1 +kind: MPIJob +metadata: + name: training-imagenet +spec: + replicas: 3 + template: + spec: + containers: + - image: docker.io/akado2009/kirill-mlperf-training:latest + name: training-imagenet + resources: + limits: + nvidia.com/gpu: 1 \ No newline at end of file diff --git a/controller/examples/resource-mod.yaml b/controller/examples/resource-mod.yaml new file mode 100644 index 000000000..358bff7ae --- /dev/null +++ b/controller/examples/resource-mod.yaml @@ -0,0 +1,7 @@ +namespace: kubebench +volumes: + - name: efs + nfs: + server: fs-ab134502.efs.us-west-2.amazonaws.com + path: / + readOnly: true diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/doc.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/doc.go deleted file mode 100644 index 95b44dfa8..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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. -*/ - -// This package has the automatically generated typed clients. -package v1 diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/doc.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/doc.go deleted file mode 100644 index 63e2c8a08..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 fake has the automatically generated clients. -package fake diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob.go deleted file mode 100644 index 786059498..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob.go +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 fake - -import ( - kubebenchjob_v1 "github.com/kubeflow/kubebench/controller/pkg/apis/kubebenchjob/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeKubebenchJobs implements KubebenchJobInterface -type FakeKubebenchJobs struct { - Fake *FakeKubebenchV1 - ns string -} - -var kubebenchjobsResource = schema.GroupVersionResource{Group: "kubebench.operator", Version: "v1", Resource: "kubebenchjobs"} - -var kubebenchjobsKind = schema.GroupVersionKind{Group: "kubebench.operator", Version: "v1", Kind: "KubebenchJob"} - -// Get takes name of the kubebenchJob, and returns the corresponding kubebenchJob object, and an error if there is any. -func (c *FakeKubebenchJobs) Get(name string, options v1.GetOptions) (result *kubebenchjob_v1.KubebenchJob, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(kubebenchjobsResource, c.ns, name), &kubebenchjob_v1.KubebenchJob{}) - - if obj == nil { - return nil, err - } - return obj.(*kubebenchjob_v1.KubebenchJob), err -} - -// List takes label and field selectors, and returns the list of KubebenchJobs that match those selectors. -func (c *FakeKubebenchJobs) List(opts v1.ListOptions) (result *kubebenchjob_v1.KubebenchJobList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(kubebenchjobsResource, kubebenchjobsKind, c.ns, opts), &kubebenchjob_v1.KubebenchJobList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &kubebenchjob_v1.KubebenchJobList{} - for _, item := range obj.(*kubebenchjob_v1.KubebenchJobList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested kubebenchJobs. -func (c *FakeKubebenchJobs) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(kubebenchjobsResource, c.ns, opts)) - -} - -// Create takes the representation of a kubebenchJob and creates it. Returns the server's representation of the kubebenchJob, and an error, if there is any. -func (c *FakeKubebenchJobs) Create(kubebenchJob *kubebenchjob_v1.KubebenchJob) (result *kubebenchjob_v1.KubebenchJob, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(kubebenchjobsResource, c.ns, kubebenchJob), &kubebenchjob_v1.KubebenchJob{}) - - if obj == nil { - return nil, err - } - return obj.(*kubebenchjob_v1.KubebenchJob), err -} - -// Update takes the representation of a kubebenchJob and updates it. Returns the server's representation of the kubebenchJob, and an error, if there is any. -func (c *FakeKubebenchJobs) Update(kubebenchJob *kubebenchjob_v1.KubebenchJob) (result *kubebenchjob_v1.KubebenchJob, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(kubebenchjobsResource, c.ns, kubebenchJob), &kubebenchjob_v1.KubebenchJob{}) - - if obj == nil { - return nil, err - } - return obj.(*kubebenchjob_v1.KubebenchJob), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeKubebenchJobs) UpdateStatus(kubebenchJob *kubebenchjob_v1.KubebenchJob) (*kubebenchjob_v1.KubebenchJob, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(kubebenchjobsResource, "status", c.ns, kubebenchJob), &kubebenchjob_v1.KubebenchJob{}) - - if obj == nil { - return nil, err - } - return obj.(*kubebenchjob_v1.KubebenchJob), err -} - -// Delete takes name of the kubebenchJob and deletes it. Returns an error if one occurs. -func (c *FakeKubebenchJobs) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(kubebenchjobsResource, c.ns, name), &kubebenchjob_v1.KubebenchJob{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeKubebenchJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(kubebenchjobsResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &kubebenchjob_v1.KubebenchJobList{}) - return err -} - -// Patch applies the patch and returns the patched kubebenchJob. -func (c *FakeKubebenchJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *kubebenchjob_v1.KubebenchJob, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(kubebenchjobsResource, c.ns, name, data, subresources...), &kubebenchjob_v1.KubebenchJob{}) - - if obj == nil { - return nil, err - } - return obj.(*kubebenchjob_v1.KubebenchJob), err -} diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob_client.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob_client.go deleted file mode 100644 index 397a0f463..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/fake/fake_kubebenchjob_client.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 fake - -import ( - v1 "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeKubebenchV1 struct { - *testing.Fake -} - -func (c *FakeKubebenchV1) KubebenchJobs(namespace string) v1.KubebenchJobInterface { - return &FakeKubebenchJobs{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeKubebenchV1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/generated_expansion.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/generated_expansion.go deleted file mode 100644 index 2e985059c..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/generated_expansion.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 v1 - -type KubebenchJobExpansion interface{} diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob.go deleted file mode 100644 index b6a5115cc..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob.go +++ /dev/null @@ -1,172 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 v1 - -import ( - v1 "github.com/kubeflow/kubebench/controller/pkg/apis/kubebenchjob/v1" - scheme "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned/scheme" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// KubebenchJobsGetter has a method to return a KubebenchJobInterface. -// A group's client should implement this interface. -type KubebenchJobsGetter interface { - KubebenchJobs(namespace string) KubebenchJobInterface -} - -// KubebenchJobInterface has methods to work with KubebenchJob resources. -type KubebenchJobInterface interface { - Create(*v1.KubebenchJob) (*v1.KubebenchJob, error) - Update(*v1.KubebenchJob) (*v1.KubebenchJob, error) - UpdateStatus(*v1.KubebenchJob) (*v1.KubebenchJob, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.KubebenchJob, error) - List(opts meta_v1.ListOptions) (*v1.KubebenchJobList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.KubebenchJob, err error) - KubebenchJobExpansion -} - -// kubebenchJobs implements KubebenchJobInterface -type kubebenchJobs struct { - client rest.Interface - ns string -} - -// newKubebenchJobs returns a KubebenchJobs -func newKubebenchJobs(c *KubebenchV1Client, namespace string) *kubebenchJobs { - return &kubebenchJobs{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the kubebenchJob, and returns the corresponding kubebenchJob object, and an error if there is any. -func (c *kubebenchJobs) Get(name string, options meta_v1.GetOptions) (result *v1.KubebenchJob, err error) { - result = &v1.KubebenchJob{} - err = c.client.Get(). - Namespace(c.ns). - Resource("kubebenchjobs"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of KubebenchJobs that match those selectors. -func (c *kubebenchJobs) List(opts meta_v1.ListOptions) (result *v1.KubebenchJobList, err error) { - result = &v1.KubebenchJobList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("kubebenchjobs"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested kubebenchJobs. -func (c *kubebenchJobs) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("kubebenchjobs"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a kubebenchJob and creates it. Returns the server's representation of the kubebenchJob, and an error, if there is any. -func (c *kubebenchJobs) Create(kubebenchJob *v1.KubebenchJob) (result *v1.KubebenchJob, err error) { - result = &v1.KubebenchJob{} - err = c.client.Post(). - Namespace(c.ns). - Resource("kubebenchjobs"). - Body(kubebenchJob). - Do(). - Into(result) - return -} - -// Update takes the representation of a kubebenchJob and updates it. Returns the server's representation of the kubebenchJob, and an error, if there is any. -func (c *kubebenchJobs) Update(kubebenchJob *v1.KubebenchJob) (result *v1.KubebenchJob, err error) { - result = &v1.KubebenchJob{} - err = c.client.Put(). - Namespace(c.ns). - Resource("kubebenchjobs"). - Name(kubebenchJob.Name). - Body(kubebenchJob). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *kubebenchJobs) UpdateStatus(kubebenchJob *v1.KubebenchJob) (result *v1.KubebenchJob, err error) { - result = &v1.KubebenchJob{} - err = c.client.Put(). - Namespace(c.ns). - Resource("kubebenchjobs"). - Name(kubebenchJob.Name). - SubResource("status"). - Body(kubebenchJob). - Do(). - Into(result) - return -} - -// Delete takes name of the kubebenchJob and deletes it. Returns an error if one occurs. -func (c *kubebenchJobs) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("kubebenchjobs"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *kubebenchJobs) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("kubebenchjobs"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched kubebenchJob. -func (c *kubebenchJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.KubebenchJob, err error) { - result = &v1.KubebenchJob{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("kubebenchjobs"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob_client.go b/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob_client.go deleted file mode 100644 index 4f069fd7e..000000000 --- a/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1/kubebenchjob_client.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2018 The Kubernetes 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 v1 - -import ( - v1 "github.com/kubeflow/kubebench/controller/pkg/apis/kubebenchjob/v1" - "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned/scheme" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - rest "k8s.io/client-go/rest" -) - -type KubebenchV1Interface interface { - RESTClient() rest.Interface - KubebenchJobsGetter -} - -// KubebenchV1Client is used to interact with features provided by the kubebench.operator group. -type KubebenchV1Client struct { - restClient rest.Interface -} - -func (c *KubebenchV1Client) KubebenchJobs(namespace string) KubebenchJobInterface { - return newKubebenchJobs(c, namespace) -} - -// NewForConfig creates a new KubebenchV1Client for the given config. -func NewForConfig(c *rest.Config) (*KubebenchV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &KubebenchV1Client{client}, nil -} - -// NewForConfigOrDie creates a new KubebenchV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *KubebenchV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new KubebenchV1Client for the given RESTClient. -func New(c rest.Interface) *KubebenchV1Client { - return &KubebenchV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *KubebenchV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/controller/pkg/resource/condition/condition.go b/controller/pkg/resource/condition/condition.go index a34b36b6e..7d7a8fd52 100644 --- a/controller/pkg/resource/condition/condition.go +++ b/controller/pkg/resource/condition/condition.go @@ -20,6 +20,7 @@ import ( var supportedResourceConditions = map[string]ResourceConditionInterface{ "Job.v1.batch": NewJobV1Condition(), + "MPIJob.v1alpha1.kubeflow.org": NewMPIJobV1alpha1Condition(), "Deployment.v1beta1.extensions": NewDeploymentV1beta1Condition(), } diff --git a/controller/pkg/resource/condition/job.go b/controller/pkg/resource/condition/job.go index 1f0e42a31..adfb2a3cb 100644 --- a/controller/pkg/resource/condition/job.go +++ b/controller/pkg/resource/condition/job.go @@ -15,6 +15,8 @@ package condition import ( "encoding/json" + mpijob "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v1alpha1" + batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -23,11 +25,17 @@ import ( // JobV1Condition is a condition checker for jobs in batch/v1 type JobV1Condition struct{} +type MPIJobV1alpha1Condition struct{} + // NewJobV1Condition creates a new JobV1Condition func NewJobV1Condition() *JobV1Condition { return &JobV1Condition{} } +func NewMPIJobV1alpha1Condition() *MPIJobV1alpha1Condition { + return &MPIJobV1alpha1Condition{} +} + // CheckCondition checks the status of a given job. // The success condition is met when a "Complete" type condition is observed. // The failure condition is met when a "Failed" type condition is observed. @@ -55,3 +63,25 @@ func (c *JobV1Condition) CheckCondition(resource *unstructured.Unstructured) (Re return result, nil } + +func (c *MPIJobV1alpha1Condition) CheckCondition(resource *unstructured.Unstructured) (ResourceConditionStatus, error) { + var job mpijob.MPIJob + + resStr, err := json.Marshal(resource) + if err != nil { + return ResourceConditionUnknown, err + } + + err = json.Unmarshal(resStr, &job) + if err != nil { + return ResourceConditionUnknown, err + } + var result ResourceConditionStatus + if job.Status.LauncherStatus == mpijob.LauncherFailed { + result = ResourceConditionFailure + } else if job.Status.LauncherStatus == mpijob.LauncherSucceeded { + result = ResourceConditionSuccess + } + + return result, nil +} diff --git a/controller/pkg/resource/mod/modifier.go b/controller/pkg/resource/mod/modifier.go index 5d21d54d4..82678d932 100644 --- a/controller/pkg/resource/mod/modifier.go +++ b/controller/pkg/resource/mod/modifier.go @@ -20,6 +20,7 @@ import ( var newResourceModFuncs = map[string]func() ResourceModifierInterface{ "Job.v1.batch": NewJobV1Modifier, + "MPIJob.v1alpha1.kubeflow.org": NewMPIJobV1alpha1Modifier, "Deployment.v1beta1.extensions": NewDeploymentV1beta1Modifier, } diff --git a/controller/pkg/resource/mod/mpijob.go b/controller/pkg/resource/mod/mpijob.go new file mode 100644 index 000000000..b70d2eb24 --- /dev/null +++ b/controller/pkg/resource/mod/mpijob.go @@ -0,0 +1,46 @@ +// 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 mod + +import ( + mpijob "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v1alpha1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" +) + +type MPIJobV1alpha1Modifier struct{} + +func NewMPIJobV1alpha1Modifier() ResourceModifierInterface { + modifier := &MPIJobV1alpha1Modifier{} + return modifier +} + +func (m *MPIJobV1alpha1Modifier) ModifyResource( + res *unstructured.Unstructured, + modSpec *ResourceModSpec) (*unstructured.Unstructured, error) { + + job := &mpijob.MPIJob{} + converter := runtime.DefaultUnstructuredConverter + if err := converter.FromUnstructured(res.Object, job); err != nil { + return nil, err + } + + job.Spec.Template = ModifyPodTemplateV1(job.Spec.Template, modSpec) + newResObj, err := converter.ToUnstructured(job) + if err != nil { + return nil, err + } + newRes := &unstructured.Unstructured{Object: newResObj} + return newRes, nil + +} diff --git a/go.mod b/go.mod index 94a06c920..b4683df0a 100644 --- a/go.mod +++ b/go.mod @@ -1,53 +1,29 @@ module github.com/kubeflow/kubebench require ( - github.com/PuerkitoBio/purell v1.1.1 - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 - github.com/argoproj/argo v0.0.0-20190215230926-baa3e622121e - github.com/davecgh/go-spew v1.1.1 - github.com/emicklei/go-restful v2.9.0+incompatible + github.com/argoproj/argo v2.3.0+incompatible + github.com/emicklei/go-restful v2.9.5+incompatible // indirect github.com/ghodss/yaml v0.0.0-20190212211648-25d852aebe32 - github.com/go-openapi/jsonpointer v0.18.0 - github.com/go-openapi/jsonreference v0.18.0 - github.com/go-openapi/spec v0.18.0 - github.com/go-openapi/swag v0.18.0 - github.com/gogo/protobuf v1.2.1 - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b - github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef - github.com/golang/protobuf v1.2.0 - github.com/google/btree v1.0.0 - github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf - github.com/googleapis/gnostic v0.2.0 - github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc - github.com/hashicorp/golang-lru v0.5.0 + github.com/go-openapi/spec v0.19.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect + github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect + github.com/golang/protobuf v1.3.1 // indirect + github.com/google/btree v1.0.0 // indirect + github.com/google/gofuzz v1.0.0 // indirect + github.com/googleapis/gnostic v0.2.0 // indirect + github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect github.com/imdario/mergo v0.3.7 - github.com/json-iterator/go v1.1.5 - github.com/konsorten/go-windows-terminal-sequences v1.0.1 - github.com/kubeflow/mpi-operator v0.0.0-20190220000427-2e9727ce1e1b - github.com/kubeflow/pytorch-operator v0.0.0-20190214174027-6807802cee81 - github.com/kubeflow/tf-operator v0.4.0 - github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd - github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 - github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c - github.com/peterbourgon/diskv v2.0.1+incompatible + github.com/json-iterator/go v1.1.6 // indirect + github.com/kubeflow/mpi-operator v0.0.0-20190625165236-2c1e858ce07b + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/sirupsen/logrus v1.3.0 - github.com/spf13/pflag v1.0.3 - golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2 - golang.org/x/net v0.0.0-20190213061140-3a22650c66bd - golang.org/x/oauth2 v0.0.0-20190219183015-4b83411ed2b3 - golang.org/x/sys v0.0.0-20190219203350-90b0e4468f99 - golang.org/x/text v0.3.0 - golang.org/x/time v0.0.0-20181108054448-85acf8d2951c - golang.org/x/tools v0.0.0-20190228203856-589c23e65e65 - google.golang.org/appengine v1.4.0 - gopkg.in/inf.v0 v0.9.1 - gopkg.in/yaml.v2 v2.2.2 + github.com/spf13/pflag v1.0.3 // indirect + golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect + golang.org/x/oauth2 v0.0.0-20190523182746-aaccbc9213b0 // indirect + golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect k8s.io/api v0.0.0-20181004124137-fd83cbc87e76 - k8s.io/apimachinery v0.0.0-20180913025736-6dd46049f395 k8s.io/client-go v9.0.0+incompatible - k8s.io/code-generator v0.0.0-20180823001027-3dcf91f64f63 - k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6 - k8s.io/klog v0.2.0 - k8s.io/kube-openapi v0.0.0-20180509051136-39cb288412c4 + k8s.io/kube-openapi v0.0.0-20180509051136-39cb288412c4 // indirect ) diff --git a/go.sum b/go.sum index b9d09bc0f..1ccf56048 100644 --- a/go.sum +++ b/go.sum @@ -1,72 +1,93 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/argoproj/argo v0.0.0-20190215230926-baa3e622121e/go.mod h1:KJ0MB+tuhtAklR4jkPM10mIZXfRA0peTYJ1sLUnFLVU= +github.com/argoproj/argo v2.3.0+incompatible h1:L1OYZ86Q7NK19ahdl/eJOq78Mlf52wUKGmp7VDNQVz8= +github.com/argoproj/argo v2.3.0+incompatible/go.mod h1:KJ0MB+tuhtAklR4jkPM10mIZXfRA0peTYJ1sLUnFLVU= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful v2.9.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= +github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/ghodss/yaml v0.0.0-20190212211648-25d852aebe32 h1:KAaAf12i9OYioQMQPO27N984uGevaVYe1Lb2Vq/QLQ4= github.com/ghodss/yaml v0.0.0-20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= +github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0 h1:yJW3HCkTHg7NOA+gZ83IPHzUSnUzGXhGmsdiCcMexbA= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= +github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc h1:f8eY6cV/x1x+HLjOp4r72s/31/V2aTUtg5oKRRPf8/Q= github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kubeflow/mpi-operator v0.0.0-20190220000427-2e9727ce1e1b/go.mod h1:6LTr8dOKZqzwn/d0xKmr14xa97g7Zw1T2DhMVluHlWg= -github.com/kubeflow/pytorch-operator v0.0.0-20190214174027-6807802cee81/go.mod h1:zHblV+yTwVG4PCgKTU2wPfOmQ6TJdfT87lDfHrP1a1Y= -github.com/kubeflow/tf-operator v0.4.0/go.mod h1:EBtz5LQoKaHUl/5fV5vD1qXVNVNyn3TrFaH6eVoQ8SY= +github.com/kubeflow/mpi-operator v0.0.0-20190625165236-2c1e858ce07b h1:EYsDg9v5DavUJ9FTdkXLKyuACEFUJt/UywO+8UgCDZQ= +github.com/kubeflow/mpi-operator v0.0.0-20190625165236-2c1e858ce07b/go.mod h1:6LTr8dOKZqzwn/d0xKmr14xa97g7Zw1T2DhMVluHlWg= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c/go.mod h1:HUpKUBZnpzkdx0kD/+Yfuft+uD3zHGtXF/XJB14TUr4= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2 h1:NwxKRvbkH5MsNkvOtPZi3/3kmI8CAzs3mtv+GLQMkNo= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.0.0-20190219183015-4b83411ed2b3/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/oauth2 v0.0.0-20190523182746-aaccbc9213b0 h1:xFEXbcD0oa/xhqQmMXztdZ0bWvexAWds+8c1gRN8nu0= +golang.org/x/oauth2 v0.0.0-20190523182746-aaccbc9213b0/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190219203350-90b0e4468f99 h1:mlL4HvR5ojTCLdWRydhoj7jto5SXLsxLc0b1r/3DNlE= -golang.org/x/sys v0.0.0-20190219203350-90b0e4468f99/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190228203856-589c23e65e65/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/api v0.0.0-20181004124137-fd83cbc87e76 h1:cGc6jt7tNK7a2WfgNKjxjoU/UXXr9Q7JTqvCupZ+6+Y= k8s.io/api v0.0.0-20181004124137-fd83cbc87e76/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= -k8s.io/apimachinery v0.0.0-20180913025736-6dd46049f395/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v9.0.0+incompatible h1:2kqW3X2xQ9SbFvWZjGEHBLlWc1LG9JIJNXWkuqwdZ3A= k8s.io/client-go v9.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= -k8s.io/code-generator v0.0.0-20180823001027-3dcf91f64f63/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v0.2.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/kube-openapi v0.0.0-20180509051136-39cb288412c4 h1:gW+EUB2I96nbxVenV/8ctfbACsHP+yxlT2dhMCsiy+s= k8s.io/kube-openapi v0.0.0-20180509051136-39cb288412c4/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 350377565..326570243 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -14,14 +14,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +export GO111MODULE=on + SCRIPT_DIR=$(dirname $0) ROOT_PKG="github.com/kubeflow/kubebench" -CODEGEN_PATH="$GOPATH/src/$ROOT_PKG/vendor/k8s.io/code-generator" +CODEGEN_PKG="k8s.io/code-generator" +CODEGEN_VERSION=$(awk '/k8s.io\/code-generator/ {print $2}' $GOPATH/src/$ROOT_PKG/go.mod) +CODEGEN_PATH="$GOPATH/pkg/mod/$CODEGEN_PKG@$CODEGEN_VERSION" CRD_NAME="kubebenchjob" CRD_VERSIONS="v1alpha1,v1alpha2" -$CODEGEN_PATH/generate-groups.sh all \ +TMP_DIR=$(mktemp -d) +echo "Creating temporary directory $TMP_DIR" + +mkdir -p $TMP_DIR/$CODEGEN_PKG +cp -r $CODEGEN_PATH/* $TMP_DIR/$CODEGEN_PKG/ +chmod -R +w $TMP_DIR/$CODEGEN_PKG + +bash $TMP_DIR/$CODEGEN_PKG/generate-groups.sh all \ "$ROOT_PKG/controller/pkg/client" \ "$ROOT_PKG/controller/pkg/apis" \ "$CRD_NAME:$CRD_VERSIONS" \ --go-header-file "$SCRIPT_DIR/boilerplate/boilerplate.go.txt" + +echo "Deleting temporary directory $TMP_DIR" +rm -rf $TMP_DIR diff --git a/tools.go b/tools.go new file mode 100644 index 000000000..9f5d05f12 --- /dev/null +++ b/tools.go @@ -0,0 +1,16 @@ +// +build tools + +package kubebench + +import ( + _ "k8s.io/code-generator/cmd/client-gen" + _ "k8s.io/code-generator/cmd/conversion-gen" + _ "k8s.io/code-generator/cmd/deepcopy-gen" + _ "k8s.io/code-generator/cmd/defaulter-gen" + _ "k8s.io/code-generator/cmd/go-to-protobuf" + _ "k8s.io/code-generator/cmd/import-boss" + _ "k8s.io/code-generator/cmd/informer-gen" + _ "k8s.io/code-generator/cmd/lister-gen" + _ "k8s.io/code-generator/cmd/register-gen" + _ "k8s.io/code-generator/cmd/set-gen" +)