From 0e3756a312fc0d1ee3069e863a73a2e9c88b14a3 Mon Sep 17 00:00:00 2001 From: thandayuthapani Date: Thu, 7 Mar 2019 16:32:57 +0530 Subject: [PATCH 1/2] Updated Dependencies for using podGroup --- .../kubernetes-sigs/kube-batch/LICENSE | 201 ++++++++++++++++ .../pkg/apis/scheduling/v1alpha1/doc.go | 18 ++ .../pkg/apis/scheduling/v1alpha1/labels.go | 21 ++ .../pkg/apis/scheduling/v1alpha1/register.go | 57 +++++ .../pkg/apis/scheduling/v1alpha1/types.go | 151 ++++++++++++ .../v1alpha1/zz_generated.deepcopy.go | 216 ++++++++++++++++++ .../client/clientset/versioned/clientset.go | 98 ++++++++ .../pkg/client/clientset/versioned/doc.go | 20 ++ .../client/clientset/versioned/scheme/doc.go | 20 ++ .../clientset/versioned/scheme/register.go | 60 +++++ .../typed/scheduling/v1alpha1/doc.go | 20 ++ .../v1alpha1/generated_expansion.go | 23 ++ .../typed/scheduling/v1alpha1/podgroup.go | 174 ++++++++++++++ .../typed/scheduling/v1alpha1/queue.go | 147 ++++++++++++ .../scheduling/v1alpha1/scheduling_client.go | 95 ++++++++ 15 files changed, 1321 insertions(+) create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/LICENSE create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/doc.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/labels.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/register.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/types.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/clientset.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/doc.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/doc.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/register.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/doc.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/queue.go create mode 100644 vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/LICENSE b/vendor/github.com/kubernetes-sigs/kube-batch/LICENSE new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/doc.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/doc.go new file mode 100644 index 0000000000..8e8da1129f --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2017 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. +*/ + +// +k8s:deepcopy-gen=package +package v1alpha1 diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/labels.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/labels.go new file mode 100644 index 0000000000..0fe02fe0b1 --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/labels.go @@ -0,0 +1,21 @@ +/* +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 v1alpha1 + +// GroupNameAnnotationKey is the annotation key of Pod to identify +// which PodGroup it belongs to. +const GroupNameAnnotationKey = "scheduling.k8s.io/group-name" diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/register.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/register.go new file mode 100644 index 0000000000..0178c20658 --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2017 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +const ( + // GroupName is the group name used in this package. + GroupName = "scheduling.incubator.k8s.io" + + // GroupVersion is the version of scheduling group + GroupVersion = "v1alpha1" +) + +// SchemeGroupVersion is the group version used to register these objects. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion} + +// Resource takes an unqualified resource and returns a Group-qualified GroupResource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &PodGroup{}, + &PodGroupList{}, + &Queue{}, + &QueueList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/types.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/types.go new file mode 100644 index 0000000000..d439edb4cf --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/types.go @@ -0,0 +1,151 @@ +/* +Copyright 2017 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodGroup is a collection of Pod; used for batch workload. +type PodGroup struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Specification of the desired behavior of the pod group. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec PodGroupSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` + + // Status represents the current information about a pod group. + // This data may not be up to date. + // +optional + Status PodGroupStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// PodGroupSpec represents the template of a pod group. +type PodGroupSpec struct { + // MinMember defines the minimal number of members/tasks to run the pod group; + // if there's not enough resources to start all tasks, the scheduler + // will not start anyone. + MinMember int32 `json:"minMember,omitempty" protobuf:"bytes,1,opt,name=minMember"` + + // Queue defines the queue to allocate resource for PodGroup; if queue does not exist, + // the PodGroup will not be scheduled. + Queue string `json:"queue,omitempty" protobuf:"bytes,2,opt,name=queue"` +} + +// PodGroupStatus represents the current state of a pod group. +type PodGroupStatus struct { + // The number of actively running pods. + // +optional + Running int32 `json:"running,omitempty" protobuf:"bytes,3,opt,name=running"` + // The number of pods which reached phase Succeeded. + // +optional + Succeeded int32 `json:"succeeded,omitempty" protobuf:"bytes,3,opt,name=succeeded"` + // The number of pods which reached phase Failed. + // +optional + Failed int32 `json:"failed,omitempty" protobuf:"bytes,3,opt,name=failed"` +} + +// Action is the action that PodGroup controller will take according to the event. +type Action string + +// Event represent the phase of PodGroup, e.g. pod-failed. +type Event string + +const ( + UnschedulableEvent Event = "Unschedulable" + EvictEvent Event = "Evict" + PodFailedEvent Event = "PodFailed" + + RestartAction Action = "restart" +) + +// LifecyclePolicy represents the lifecycle policy of PodGroup. +type LifeCyclePolicy struct { + // The action that will be taken to the PodGroup according to Event. + // One of "Restart", "None". + // Default to None. + // +optional + Action Action + // The Event recorded by scheduler; the controller takes actions + // according to this Event. + // One of "PodFailed", "Unschedulable". + // +optional + Event Event + // Timeout is the grace period for controller to take actions. + // Default to nil (take action immediately). + // +optional + Timeout *metav1.Duration +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodGroupList is a collection of pod groups. +type PodGroupList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // items is the list of PodGroup + Items []PodGroup `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Queue is a queue of PodGroup. +type Queue struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Specification of the desired behavior of the pod group. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec QueueSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` +} + +// QueueSpec represents the template of Queue. +type QueueSpec struct { + Weight int32 `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// QueueList is a collection of queues. +type QueueList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // items is the list of PodGroup + Items []Queue `json:"items" protobuf:"bytes,2,rep,name=items"` +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..fabd3eae6f --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,216 @@ +// +build !ignore_autogenerated + +/* +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LifeCyclePolicy) DeepCopyInto(out *LifeCyclePolicy) { + *out = *in + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(v1.Duration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LifeCyclePolicy. +func (in *LifeCyclePolicy) DeepCopy() *LifeCyclePolicy { + if in == nil { + return nil + } + out := new(LifeCyclePolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodGroup) DeepCopyInto(out *PodGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodGroup. +func (in *PodGroup) DeepCopy() *PodGroup { + if in == nil { + return nil + } + out := new(PodGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodGroup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodGroupList) DeepCopyInto(out *PodGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodGroupList. +func (in *PodGroupList) DeepCopy() *PodGroupList { + if in == nil { + return nil + } + out := new(PodGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodGroupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodGroupSpec) DeepCopyInto(out *PodGroupSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodGroupSpec. +func (in *PodGroupSpec) DeepCopy() *PodGroupSpec { + if in == nil { + return nil + } + out := new(PodGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodGroupStatus) DeepCopyInto(out *PodGroupStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodGroupStatus. +func (in *PodGroupStatus) DeepCopy() *PodGroupStatus { + if in == nil { + return nil + } + out := new(PodGroupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Queue) DeepCopyInto(out *Queue) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Queue. +func (in *Queue) DeepCopy() *Queue { + if in == nil { + return nil + } + out := new(Queue) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Queue) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *QueueList) DeepCopyInto(out *QueueList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Queue, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueList. +func (in *QueueList) DeepCopy() *QueueList { + if in == nil { + return nil + } + out := new(QueueList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *QueueList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *QueueSpec) DeepCopyInto(out *QueueSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueSpec. +func (in *QueueSpec) DeepCopy() *QueueSpec { + if in == nil { + return nil + } + out := new(QueueSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/clientset.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..c1ddfe07ca --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,98 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + schedulingv1alpha1 "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Scheduling() schedulingv1alpha1.SchedulingV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client +} + +// SchedulingV1alpha1 retrieves the SchedulingV1alpha1Client +func (c *Clientset) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface { + return c.schedulingV1alpha1 +} + +// Deprecated: Scheduling retrieves the default version of SchedulingClient. +// Please explicitly pick a version. +func (c *Clientset) Scheduling() schedulingv1alpha1.SchedulingV1alpha1Interface { + return c.schedulingV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.schedulingV1alpha1, err = schedulingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.schedulingV1alpha1 = schedulingv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/doc.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/doc.go new file mode 100644 index 0000000000..41721ca52d --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package versioned diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/doc.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..7dc3756168 --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/register.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..e08eecc63e --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,60 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + schedulingv1alpha1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + + corev1 "k8s.io/api/core/v1" + //PDB defintions + policyv1beta1 "k8s.io/api/policy/v1beta1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + AddToScheme(Scheme) +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +func AddToScheme(scheme *runtime.Scheme) { + schedulingv1alpha1.AddToScheme(scheme) + corev1.AddToScheme(scheme) + policyv1beta1.AddToScheme(scheme) +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/doc.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/doc.go new file mode 100644 index 0000000000..df51baa4d4 --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..f195814928 --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type PodGroupExpansion interface{} + +type QueueExpansion interface{} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go new file mode 100644 index 0000000000..ea0cb3628c --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go @@ -0,0 +1,174 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1" + scheme "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme" + 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" +) + +// PodGroupsGetter has a method to return a PodGroupInterface. +// A group's client should implement this interface. +type PodGroupsGetter interface { + PodGroups(namespace string) PodGroupInterface +} + +// PodGroupInterface has methods to work with PodGroup resources. +type PodGroupInterface interface { + Create(*v1alpha1.PodGroup) (*v1alpha1.PodGroup, error) + Update(*v1alpha1.PodGroup) (*v1alpha1.PodGroup, error) + UpdateStatus(*v1alpha1.PodGroup) (*v1alpha1.PodGroup, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.PodGroup, error) + List(opts v1.ListOptions) (*v1alpha1.PodGroupList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodGroup, err error) + PodGroupExpansion +} + +// podGroups implements PodGroupInterface +type podGroups struct { + client rest.Interface + ns string +} + +// newPodGroups returns a PodGroups +func newPodGroups(c *SchedulingV1alpha1Client, namespace string) *podGroups { + return &podGroups{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podGroup, and returns the corresponding podGroup object, and an error if there is any. +func (c *podGroups) Get(name string, options v1.GetOptions) (result *v1alpha1.PodGroup, err error) { + result = &v1alpha1.PodGroup{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podgroups"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodGroups that match those selectors. +func (c *podGroups) List(opts v1.ListOptions) (result *v1alpha1.PodGroupList, err error) { + result = &v1alpha1.PodGroupList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podGroups. +func (c *podGroups) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a podGroup and creates it. Returns the server's representation of the podGroup, and an error, if there is any. +func (c *podGroups) Create(podGroup *v1alpha1.PodGroup) (result *v1alpha1.PodGroup, err error) { + result = &v1alpha1.PodGroup{} + err = c.client.Post(). + Namespace(c.ns). + Resource("podgroups"). + Body(podGroup). + Do(). + Into(result) + return +} + +// Update takes the representation of a podGroup and updates it. Returns the server's representation of the podGroup, and an error, if there is any. +func (c *podGroups) Update(podGroup *v1alpha1.PodGroup) (result *v1alpha1.PodGroup, err error) { + result = &v1alpha1.PodGroup{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podgroups"). + Name(podGroup.Name). + Body(podGroup). + 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 *podGroups) UpdateStatus(podGroup *v1alpha1.PodGroup) (result *v1alpha1.PodGroup, err error) { + result = &v1alpha1.PodGroup{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podgroups"). + Name(podGroup.Name). + SubResource("status"). + Body(podGroup). + Do(). + Into(result) + return +} + +// Delete takes name of the podGroup and deletes it. Returns an error if one occurs. +func (c *podGroups) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podgroups"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *podGroups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched podGroup. +func (c *podGroups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodGroup, err error) { + result = &v1alpha1.PodGroup{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podgroups"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/queue.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/queue.go new file mode 100644 index 0000000000..77b1b40aeb --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/queue.go @@ -0,0 +1,147 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1" + scheme "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme" + 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" +) + +// QueuesGetter has a method to return a QueueInterface. +// A group's client should implement this interface. +type QueuesGetter interface { + Queues() QueueInterface +} + +// QueueInterface has methods to work with Queue resources. +type QueueInterface interface { + Create(*v1alpha1.Queue) (*v1alpha1.Queue, error) + Update(*v1alpha1.Queue) (*v1alpha1.Queue, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Queue, error) + List(opts v1.ListOptions) (*v1alpha1.QueueList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Queue, err error) + QueueExpansion +} + +// queues implements QueueInterface +type queues struct { + client rest.Interface +} + +// newQueues returns a Queues +func newQueues(c *SchedulingV1alpha1Client) *queues { + return &queues{ + client: c.RESTClient(), + } +} + +// Get takes name of the queue, and returns the corresponding queue object, and an error if there is any. +func (c *queues) Get(name string, options v1.GetOptions) (result *v1alpha1.Queue, err error) { + result = &v1alpha1.Queue{} + err = c.client.Get(). + Resource("queues"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Queues that match those selectors. +func (c *queues) List(opts v1.ListOptions) (result *v1alpha1.QueueList, err error) { + result = &v1alpha1.QueueList{} + err = c.client.Get(). + Resource("queues"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested queues. +func (c *queues) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Resource("queues"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a queue and creates it. Returns the server's representation of the queue, and an error, if there is any. +func (c *queues) Create(queue *v1alpha1.Queue) (result *v1alpha1.Queue, err error) { + result = &v1alpha1.Queue{} + err = c.client.Post(). + Resource("queues"). + Body(queue). + Do(). + Into(result) + return +} + +// Update takes the representation of a queue and updates it. Returns the server's representation of the queue, and an error, if there is any. +func (c *queues) Update(queue *v1alpha1.Queue) (result *v1alpha1.Queue, err error) { + result = &v1alpha1.Queue{} + err = c.client.Put(). + Resource("queues"). + Name(queue.Name). + Body(queue). + Do(). + Into(result) + return +} + +// Delete takes name of the queue and deletes it. Returns an error if one occurs. +func (c *queues) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Resource("queues"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *queues) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Resource("queues"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched queue. +func (c *queues) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Queue, err error) { + result = &v1alpha1.Queue{} + err = c.client.Patch(pt). + Resource("queues"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go new file mode 100644 index 0000000000..d57f01217c --- /dev/null +++ b/vendor/github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go @@ -0,0 +1,95 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1" + "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type SchedulingV1alpha1Interface interface { + RESTClient() rest.Interface + PodGroupsGetter + QueuesGetter +} + +// SchedulingV1alpha1Client is used to interact with features provided by the scheduling group. +type SchedulingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *SchedulingV1alpha1Client) PodGroups(namespace string) PodGroupInterface { + return newPodGroups(c, namespace) +} + +func (c *SchedulingV1alpha1Client) Queues() QueueInterface { + return newQueues(c) +} + +// NewForConfig creates a new SchedulingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*SchedulingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SchedulingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new SchedulingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SchedulingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SchedulingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *SchedulingV1alpha1Client { + return &SchedulingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.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 *SchedulingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} From 66baf2df7aaf442411c724f77d08448c871db4d3 Mon Sep 17 00:00:00 2001 From: thandayuthapani Date: Thu, 7 Mar 2019 16:35:42 +0530 Subject: [PATCH 2/2] Use podGroup instead of PDB in v1beta2 --- Gopkg.lock | 15 +++++ Gopkg.toml | 4 ++ cmd/tf-operator.v1beta1/app/server.go | 22 +++--- cmd/tf-operator.v1beta2/app/server.go | 21 +++--- examples/crd/crd-podgroup.yaml | 39 +++++++++++ .../distributed_tfjob.yaml | 3 + pkg/common/jobcontroller/jobcontroller.go | 67 ++++++++++++++++--- .../tensorflow/controller.go | 4 +- .../tensorflow/controller_test.go | 40 +++++++++-- pkg/controller.v1beta1/tensorflow/job.go | 2 +- pkg/controller.v1beta1/tensorflow/job_test.go | 8 +-- pkg/controller.v1beta1/tensorflow/pod_test.go | 25 ++++++- .../tensorflow/service_test.go | 13 +++- .../tensorflow/status_test.go | 25 ++++++- .../tensorflow/controller.go | 16 +++-- .../tensorflow/controller_test.go | 40 +++++++++-- pkg/controller.v1beta2/tensorflow/job.go | 2 +- pkg/controller.v1beta2/tensorflow/job_test.go | 49 ++++++++++++-- pkg/controller.v1beta2/tensorflow/pod_test.go | 25 ++++++- .../tensorflow/service_test.go | 13 +++- .../tensorflow/status_test.go | 25 ++++++- 21 files changed, 398 insertions(+), 60 deletions(-) create mode 100644 examples/crd/crd-podgroup.yaml diff --git a/Gopkg.lock b/Gopkg.lock index cf89c83c23..1e2a3207ad 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -209,6 +209,19 @@ revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242" version = "v1.0.1" +[[projects]] + digest = "1:680c0fba95a0cff934e350b1ad6774d8229378a3e37d9902e07e2861e82a5908" + name = "github.com/kubernetes-sigs/kube-batch" + packages = [ + "pkg/apis/scheduling/v1alpha1", + "pkg/client/clientset/versioned", + "pkg/client/clientset/versioned/scheme", + "pkg/client/clientset/versioned/typed/scheduling/v1alpha1", + ] + pruneopts = "NUT" + revision = "b0dbd4f2df590237cecee48f463bfb8746cfa357" + version = "v0.3" + [[projects]] branch = "master" digest = "1:84a5a2b67486d5d67060ac393aa255d05d24ed5ee41daecd5635ec22657b6492" @@ -931,6 +944,8 @@ "github.com/go-openapi/spec", "github.com/golang/glog", "github.com/golang/protobuf/proto", + "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1", + "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned", "github.com/onrik/logrus/filename", "github.com/sirupsen/logrus", "github.com/stretchr/testify/assert", diff --git a/Gopkg.toml b/Gopkg.toml index ff4ecc401b..dbd0b4d7c8 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -21,6 +21,10 @@ required = [ name = "github.com/stretchr/testify" version = "1.2.2" +[[constraint]] + name = "github.com/kubernetes-sigs/kube-batch" + version = "v0.3" + [[constraint]] name = "github.com/sirupsen/logrus" version = "v1.0.4" diff --git a/cmd/tf-operator.v1beta1/app/server.go b/cmd/tf-operator.v1beta1/app/server.go index 4a573d8f77..cb2639df04 100644 --- a/cmd/tf-operator.v1beta1/app/server.go +++ b/cmd/tf-operator.v1beta1/app/server.go @@ -27,6 +27,7 @@ import ( controller "github.com/kubeflow/tf-operator/pkg/controller.v1beta1/tensorflow" "github.com/kubeflow/tf-operator/pkg/util/signals" "github.com/kubeflow/tf-operator/pkg/version" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" crdclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" @@ -91,7 +92,7 @@ func Run(opt *options.ServerOption) error { } // Create clients. - kubeClientSet, leaderElectionClientSet, tfJobClientSet, err := createClientSets(kcfg) + kubeClientSet, leaderElectionClientSet, tfJobClientSet, kubeBatchClientSet, err := createClientSets(kcfg) if err != nil { return err } @@ -103,7 +104,7 @@ func Run(opt *options.ServerOption) error { unstructuredInformer := controller.NewUnstructuredTFJobInformer(kcfg, opt.Namespace) // Create tf controller. - tc := controller.NewTFController(unstructuredInformer, kubeClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, *opt) + tc := controller.NewTFController(unstructuredInformer, kubeClientSet, kubeBatchClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, *opt) // Start informer goroutines. go kubeInformerFactory.Start(stopCh) @@ -161,32 +162,37 @@ func Run(opt *options.ServerOption) error { return nil } -func createClientSets(config *restclientset.Config) (kubeclientset.Interface, kubeclientset.Interface, tfjobclientset.Interface, error) { +func createClientSets(config *restclientset.Config) (kubeclientset.Interface, kubeclientset.Interface, tfjobclientset.Interface, kubebatchclient.Interface, error) { crdClient, err := crdclient.NewForConfig(config) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } checkCRDExists(crdClient, v1beta1.TFCRD) kubeClientSet, err := kubeclientset.NewForConfig(restclientset.AddUserAgent(config, "tf-operator")) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } leaderElectionClientSet, err := kubeclientset.NewForConfig(restclientset.AddUserAgent(config, "leader-election")) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } tfJobClientSet, err := tfjobclientset.NewForConfig(config) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return kubeClientSet, leaderElectionClientSet, tfJobClientSet, nil + kubeBatchClientSet, err := kubebatchclient.NewForConfig(restclientset.AddUserAgent(config, "kube-batch")) + if err != nil { + return nil, nil, nil, nil, err + } + + return kubeClientSet, leaderElectionClientSet, tfJobClientSet, kubeBatchClientSet, nil } func checkCRDExists(clientset crdclient.Interface, crdName string) { diff --git a/cmd/tf-operator.v1beta2/app/server.go b/cmd/tf-operator.v1beta2/app/server.go index a8feee911a..7afb19dd80 100644 --- a/cmd/tf-operator.v1beta2/app/server.go +++ b/cmd/tf-operator.v1beta2/app/server.go @@ -27,6 +27,7 @@ import ( controller "github.com/kubeflow/tf-operator/pkg/controller.v1beta2/tensorflow" "github.com/kubeflow/tf-operator/pkg/util/signals" "github.com/kubeflow/tf-operator/pkg/version" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" crdclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" @@ -91,7 +92,7 @@ func Run(opt *options.ServerOption) error { } // Create clients. - kubeClientSet, leaderElectionClientSet, tfJobClientSet, err := createClientSets(kcfg) + kubeClientSet, leaderElectionClientSet, tfJobClientSet, kubeBatchClientSet, err := createClientSets(kcfg) if err != nil { return err } @@ -103,7 +104,7 @@ func Run(opt *options.ServerOption) error { unstructuredInformer := controller.NewUnstructuredTFJobInformer(kcfg, opt.Namespace) // Create tf controller. - tc := controller.NewTFController(unstructuredInformer, kubeClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, *opt) + tc := controller.NewTFController(unstructuredInformer, kubeClientSet, kubeBatchClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, *opt) // Start informer goroutines. go kubeInformerFactory.Start(stopCh) @@ -161,32 +162,36 @@ func Run(opt *options.ServerOption) error { return nil } -func createClientSets(config *restclientset.Config) (kubeclientset.Interface, kubeclientset.Interface, tfjobclientset.Interface, error) { +func createClientSets(config *restclientset.Config) (kubeclientset.Interface, kubeclientset.Interface, tfjobclientset.Interface, kubebatchclient.Interface, error) { crdClient, err := crdclient.NewForConfig(config) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } checkCRDExists(crdClient, v1beta2.TFCRD) kubeClientSet, err := kubeclientset.NewForConfig(restclientset.AddUserAgent(config, "tf-operator")) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } leaderElectionClientSet, err := kubeclientset.NewForConfig(restclientset.AddUserAgent(config, "leader-election")) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } tfJobClientSet, err := tfjobclientset.NewForConfig(config) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return kubeClientSet, leaderElectionClientSet, tfJobClientSet, nil + kubeBatchClientSet, err := kubebatchclient.NewForConfig(restclientset.AddUserAgent(config, "kube-batch")) + if err != nil { + return nil, nil, nil, nil, err + } + return kubeClientSet, leaderElectionClientSet, tfJobClientSet, kubeBatchClientSet, nil } func checkCRDExists(clientset crdclient.Interface, crdName string) { diff --git a/examples/crd/crd-podgroup.yaml b/examples/crd/crd-podgroup.yaml new file mode 100644 index 0000000000..1432fc160f --- /dev/null +++ b/examples/crd/crd-podgroup.yaml @@ -0,0 +1,39 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: podgroups.scheduling.incubator.k8s.io +spec: + group: scheduling.incubator.k8s.io + names: + kind: PodGroup + plural: podgroups + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + minMember: + format: int32 + type: integer + type: object + status: + properties: + succeeded: + format: int32 + type: integer + failed: + format: int32 + type: integer + running: + format: int32 + type: integer + type: object + type: object + version: v1alpha1 diff --git a/examples/distribution_strategy/distributed_tfjob.yaml b/examples/distribution_strategy/distributed_tfjob.yaml index ada28d8021..1e4293ceec 100644 --- a/examples/distribution_strategy/distributed_tfjob.yaml +++ b/examples/distribution_strategy/distributed_tfjob.yaml @@ -10,6 +10,9 @@ spec: replicas: 3 restartPolicy: Never template: + metadata: + annotations: + scheduling.k8s.io/group-name: "distributed-training" spec: containers: - name: tensorflow diff --git a/pkg/common/jobcontroller/jobcontroller.go b/pkg/common/jobcontroller/jobcontroller.go index df76135e58..baf3b0d0a4 100644 --- a/pkg/common/jobcontroller/jobcontroller.go +++ b/pkg/common/jobcontroller/jobcontroller.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" "k8s.io/api/policy/v1beta1" @@ -88,6 +90,9 @@ type JobController struct { // kubeClientSet is a standard kubernetes clientset. KubeClientSet kubeclientset.Interface + //KubeBatchClientSet is a standard kube-batch clientset. + KubeBatchClientSet kubebatchclient.Interface + // podLister can list/get pods from the shared informer's store. PodLister corelisters.PodLister @@ -135,6 +140,7 @@ func NewJobController( reconcilerSyncPeriod metav1.Duration, enableGangScheduling bool, kubeClientSet kubeclientset.Interface, + kubeBatchClientSet kubebatchclient.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, workQueueName string) JobController { @@ -160,14 +166,15 @@ func NewJobController( } jc := JobController{ - Controller: controllerImpl, - Config: jobControllerConfig, - PodControl: realPodControl, - ServiceControl: realServiceControl, - KubeClientSet: kubeClientSet, - Expectations: controller.NewControllerExpectations(), - WorkQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), workQueueName), - Recorder: recorder, + Controller: controllerImpl, + Config: jobControllerConfig, + PodControl: realPodControl, + ServiceControl: realServiceControl, + KubeClientSet: kubeClientSet, + KubeBatchClientSet: kubeBatchClientSet, + Expectations: controller.NewControllerExpectations(), + WorkQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), workQueueName), + Recorder: recorder, } return jc @@ -197,6 +204,31 @@ func (jc *JobController) GenLabels(jobName string) map[string]string { } } +func (jc *JobController) SyncPodGroup(job metav1.Object, minAvailableReplicas int32) (*v1alpha1.PodGroup, error) { + + kubeBatchClientInterface := jc.KubeBatchClientSet + // Check whether podGroup exists or not + podGroup, err := kubeBatchClientInterface.SchedulingV1alpha1().PodGroups(job.GetNamespace()).Get(job.GetName(), metav1.GetOptions{}) + if err == nil { + return podGroup, nil + } + + // create podGroup for gang scheduling by kube-batch + minAvailable := intstr.FromInt(int(minAvailableReplicas)) + createPodGroup := &v1alpha1.PodGroup{ + ObjectMeta: metav1.ObjectMeta{ + Name: job.GetName(), + OwnerReferences: []metav1.OwnerReference{ + *jc.GenOwnerReference(job), + }, + }, + Spec: v1alpha1.PodGroupSpec{ + MinMember: minAvailable.IntVal, + }, + } + return kubeBatchClientInterface.SchedulingV1alpha1().PodGroups(job.GetNamespace()).Create(createPodGroup) +} + // SyncPdb will create a PDB for gang scheduling by kube-arbitrator. func (jc *JobController) SyncPdb(job metav1.Object, minAvailableReplicas int32) (*v1beta1.PodDisruptionBudget, error) { labelJobName := jc.Controller.GetJobNameLabelKey() @@ -231,6 +263,25 @@ func (jc *JobController) SyncPdb(job metav1.Object, minAvailableReplicas int32) return jc.KubeClientSet.PolicyV1beta1().PodDisruptionBudgets(job.GetNamespace()).Create(createPdb) } +func (jc *JobController) DeletePodGroup(job metav1.Object) error { + kubeBatchClientInterface := jc.KubeBatchClientSet + + //check whether podGroup exists or not + _, err := kubeBatchClientInterface.SchedulingV1alpha1().PodGroups(job.GetNamespace()).Get(job.GetName(), metav1.GetOptions{}) + if err != nil && k8serrors.IsNotFound(err) { + return nil + } + + log.Infof("Deleting PodGroup %s", job.GetName()) + + //delete podGroup + err = kubeBatchClientInterface.SchedulingV1alpha1().PodGroups(job.GetNamespace()).Delete(job.GetName(), &metav1.DeleteOptions{}) + if err != nil { + return fmt.Errorf("unable to delete PodGroup: %v", err) + } + return nil +} + func (jc *JobController) DeletePdb(job metav1.Object) error { // Check the pdb exist or not diff --git a/pkg/controller.v1beta1/tensorflow/controller.go b/pkg/controller.v1beta1/tensorflow/controller.go index 8bcae8b491..03b7814b44 100644 --- a/pkg/controller.v1beta1/tensorflow/controller.go +++ b/pkg/controller.v1beta1/tensorflow/controller.go @@ -19,6 +19,7 @@ import ( "fmt" "time" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -98,6 +99,7 @@ func NewTFController( // This variable is for unstructured informer. tfJobInformer tfjobinformersv1beta1.TFJobInformer, kubeClientSet kubeclientset.Interface, + kubeBatchClientSet kubebatchclient.Interface, tfJobClientSet tfjobclientset.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, // This field is not used now but we keep it since it will be used @@ -116,7 +118,7 @@ func NewTFController( // Create base controller log.Info("Creating Job controller") jc := jobcontroller.NewJobController(tc, metav1.Duration{Duration: 15 * time.Second}, - option.EnableGangScheduling, kubeClientSet, kubeInformerFactory, tfv1beta1.Plural) + option.EnableGangScheduling, kubeClientSet, kubeBatchClientSet, kubeInformerFactory, tfv1beta1.Plural) tc.JobController = jc // Set sync handler. tc.syncHandler = tc.syncTFJob diff --git a/pkg/controller.v1beta1/tensorflow/controller_test.go b/pkg/controller.v1beta1/tensorflow/controller_test.go index 6d05180074..dc8497ba16 100644 --- a/pkg/controller.v1beta1/tensorflow/controller_test.go +++ b/pkg/controller.v1beta1/tensorflow/controller_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeinformers "k8s.io/client-go/informers" kubeclientset "k8s.io/client-go/kubernetes" @@ -48,6 +49,7 @@ var ( func newTFController( config *rest.Config, kubeClientSet kubeclientset.Interface, + kubeBatchClientSet kubebatchclient.Interface, tfJobClientSet tfjobclientset.Interface, resyncPeriod controller.ResyncPeriodFunc, option options.ServerOption, @@ -60,7 +62,7 @@ func newTFController( tfJobInformer := NewUnstructuredTFJobInformer(config, metav1.NamespaceAll) - ctr := NewTFController(tfJobInformer, kubeClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, option) + ctr := NewTFController(tfJobInformer, kubeClientSet, kubeBatchClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, option) ctr.PodControl = &controller.FakePodControl{} ctr.ServiceControl = &control.FakeServiceControl{} return ctr, kubeInformerFactory, tfJobInformerFactory @@ -215,6 +217,16 @@ func TestNormalPath(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -223,7 +235,7 @@ func TestNormalPath(t *testing.T) { } option := options.ServerOption{} tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -358,6 +370,16 @@ func TestRun(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -365,7 +387,7 @@ func TestRun(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -391,12 +413,22 @@ func TestSyncPdb(t *testing.T) { GroupVersion: &tfv1beta1.SchemeGroupVersion, }, } + + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) kubeClientSet := fake.NewSimpleClientset() + option := options.ServerOption{ EnableGangScheduling: true, } - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) type testCase struct { tfJob *tfv1beta1.TFJob diff --git a/pkg/controller.v1beta1/tensorflow/job.go b/pkg/controller.v1beta1/tensorflow/job.go index 884b74e6e9..9ac8d591e7 100644 --- a/pkg/controller.v1beta1/tensorflow/job.go +++ b/pkg/controller.v1beta1/tensorflow/job.go @@ -94,7 +94,7 @@ func (tc *TFController) addTFJob(obj interface{}) { // Convert from tfjob object err = unstructuredFromTFJob(obj, tfJob) if err != nil { - logger.Error("Failed to convert the obj: %v", err) + logger.Errorf("Failed to convert the obj: %v", err) return } tc.enqueueTFJob(obj) diff --git a/pkg/controller.v1beta1/tensorflow/job_test.go b/pkg/controller.v1beta1/tensorflow/job_test.go index 68d6ba472d..89b8e44676 100644 --- a/pkg/controller.v1beta1/tensorflow/job_test.go +++ b/pkg/controller.v1beta1/tensorflow/job_test.go @@ -48,7 +48,7 @@ func TestAddTFJob(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, nil, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -107,7 +107,7 @@ func TestCopyLabelsAndAnnotation(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, nil, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.tfJobInformerSynced = testutil.AlwaysReady @@ -286,7 +286,7 @@ func TestDeletePodsAndServices(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, nil, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl fakeServiceControl := &control.FakeServiceControl{} @@ -440,7 +440,7 @@ func TestCleanupTFJob(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, nil, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl fakeServiceControl := &control.FakeServiceControl{} diff --git a/pkg/controller.v1beta1/tensorflow/pod_test.go b/pkg/controller.v1beta1/tensorflow/pod_test.go index ece0150f9e..d1f7819808 100644 --- a/pkg/controller.v1beta1/tensorflow/pod_test.go +++ b/pkg/controller.v1beta1/tensorflow/pod_test.go @@ -19,6 +19,7 @@ import ( "os" "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -40,6 +41,16 @@ func TestAddPod(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -47,7 +58,7 @@ func TestAddPod(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -210,6 +221,16 @@ func TestExitCode(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -217,7 +238,7 @@ func TestExitCode(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.tfJobInformerSynced = testutil.AlwaysReady diff --git a/pkg/controller.v1beta1/tensorflow/service_test.go b/pkg/controller.v1beta1/tensorflow/service_test.go index 18147810a3..f85988d438 100644 --- a/pkg/controller.v1beta1/tensorflow/service_test.go +++ b/pkg/controller.v1beta1/tensorflow/service_test.go @@ -18,6 +18,7 @@ package tensorflow import ( "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -38,6 +39,16 @@ func TestAddService(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -45,7 +56,7 @@ func TestAddService(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady diff --git a/pkg/controller.v1beta1/tensorflow/status_test.go b/pkg/controller.v1beta1/tensorflow/status_test.go index c49b3c9db5..c871e72a69 100644 --- a/pkg/controller.v1beta1/tensorflow/status_test.go +++ b/pkg/controller.v1beta1/tensorflow/status_test.go @@ -18,6 +18,7 @@ package tensorflow import ( "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -40,6 +41,16 @@ func TestFailed(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -47,7 +58,7 @@ func TestFailed(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -366,6 +377,16 @@ func TestStatus(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -373,7 +394,7 @@ func TestStatus(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.Recorder = &record.FakeRecorder{} diff --git a/pkg/controller.v1beta2/tensorflow/controller.go b/pkg/controller.v1beta2/tensorflow/controller.go index 32412647be..3a6aff43e0 100644 --- a/pkg/controller.v1beta2/tensorflow/controller.go +++ b/pkg/controller.v1beta2/tensorflow/controller.go @@ -19,6 +19,7 @@ import ( "fmt" "time" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -98,6 +99,7 @@ func NewTFController( // This variable is for unstructured informer. tfJobInformer tfjobinformersv1beta2.TFJobInformer, kubeClientSet kubeclientset.Interface, + kubeBatchClientSet kubebatchclient.Interface, tfJobClientSet tfjobclientset.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, // This field is not used now but we keep it since it will be used @@ -116,7 +118,7 @@ func NewTFController( // Create base controller log.Info("Creating Job controller") jc := jobcontroller.NewJobController(tc, metav1.Duration{Duration: 15 * time.Second}, - option.EnableGangScheduling, kubeClientSet, kubeInformerFactory, tfv1beta2.Plural) + option.EnableGangScheduling, kubeClientSet, kubeBatchClientSet, kubeInformerFactory, tfv1beta2.Plural) tc.JobController = jc // Set sync handler. tc.syncHandler = tc.syncTFJob @@ -302,9 +304,9 @@ func (tc *TFController) syncTFJob(key string) (bool, error) { if tc.Config.EnableGangScheduling { minAvailableReplicas := getTotalReplicas(tfjob) - _, err := tc.SyncPdb(tfjob, minAvailableReplicas) + _, err := tc.SyncPodGroup(tfjob, minAvailableReplicas) if err != nil { - logger.Warnf("Sync pdb %v: %v", tfjob.Name, err) + logger.Warnf("Sync PodGroup %v: %v", tfjob.Name, err) } } @@ -362,12 +364,12 @@ func (tc *TFController) reconcileTFJobs(tfjob *tfv1beta2.TFJob) error { } if tc.Config.EnableGangScheduling { - tc.Recorder.Event(tfjob, v1.EventTypeNormal, "JobTerminated", "Job is terminated, deleting pdb") - if err := tc.DeletePdb(tfjob); err != nil { - tc.Recorder.Eventf(tfjob, v1.EventTypeWarning, "FailedDeletePdb", "Error deleting: %v", err) + tc.Recorder.Event(tfjob, v1.EventTypeNormal, "JobTerminated", "Job is terminated, deleting PodGroup") + if err := tc.DeletePodGroup(tfjob); err != nil { + tc.Recorder.Eventf(tfjob, v1.EventTypeWarning, "FailedDeletePodGroup", "Error deleting: %v", err) return err } else { - tc.Recorder.Eventf(tfjob, v1.EventTypeNormal, "SuccessfulDeletePdb", "Deleted pdb: %v", tfjob.Name) + tc.Recorder.Eventf(tfjob, v1.EventTypeNormal, "SuccessfulDeletePodGroup", "Deleted pdb: %v", tfjob.Name) } } diff --git a/pkg/controller.v1beta2/tensorflow/controller_test.go b/pkg/controller.v1beta2/tensorflow/controller_test.go index d9fc5e161e..abb758d338 100644 --- a/pkg/controller.v1beta2/tensorflow/controller_test.go +++ b/pkg/controller.v1beta2/tensorflow/controller_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeinformers "k8s.io/client-go/informers" kubeclientset "k8s.io/client-go/kubernetes" @@ -48,6 +49,7 @@ var ( func newTFController( config *rest.Config, kubeClientSet kubeclientset.Interface, + kubeBatchClientSet kubebatchclient.Interface, tfJobClientSet tfjobclientset.Interface, resyncPeriod controller.ResyncPeriodFunc, option options.ServerOption, @@ -60,7 +62,7 @@ func newTFController( tfJobInformer := NewUnstructuredTFJobInformer(config, metav1.NamespaceAll) - ctr := NewTFController(tfJobInformer, kubeClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, option) + ctr := NewTFController(tfJobInformer, kubeClientSet, kubeBatchClientSet, tfJobClientSet, kubeInformerFactory, tfJobInformerFactory, option) ctr.PodControl = &controller.FakePodControl{} ctr.ServiceControl = &control.FakeServiceControl{} return ctr, kubeInformerFactory, tfJobInformerFactory @@ -215,6 +217,16 @@ func TestNormalPath(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -223,7 +235,7 @@ func TestNormalPath(t *testing.T) { } option := options.ServerOption{} tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -358,6 +370,16 @@ func TestRun(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -365,7 +387,7 @@ func TestRun(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -391,12 +413,22 @@ func TestSyncPdb(t *testing.T) { GroupVersion: &tfv1beta2.SchemeGroupVersion, }, } + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) kubeClientSet := fake.NewSimpleClientset() option := options.ServerOption{ EnableGangScheduling: true, } - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, option) type testCase struct { tfJob *tfv1beta2.TFJob diff --git a/pkg/controller.v1beta2/tensorflow/job.go b/pkg/controller.v1beta2/tensorflow/job.go index e938dc4b5f..68200748f0 100644 --- a/pkg/controller.v1beta2/tensorflow/job.go +++ b/pkg/controller.v1beta2/tensorflow/job.go @@ -94,7 +94,7 @@ func (tc *TFController) addTFJob(obj interface{}) { // Convert from tfjob object err = unstructuredFromTFJob(obj, tfJob) if err != nil { - logger.Error("Failed to convert the obj: %v", err) + logger.Errorf("Failed to convert the obj: %v", err) return } tc.enqueueTFJob(obj) diff --git a/pkg/controller.v1beta2/tensorflow/job_test.go b/pkg/controller.v1beta2/tensorflow/job_test.go index 40f7e9ef91..90493d0e61 100644 --- a/pkg/controller.v1beta2/tensorflow/job_test.go +++ b/pkg/controller.v1beta2/tensorflow/job_test.go @@ -18,6 +18,7 @@ import ( "testing" "time" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -41,6 +42,16 @@ func TestAddTFJob(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -48,7 +59,7 @@ func TestAddTFJob(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -100,6 +111,16 @@ func TestCopyLabelsAndAnnotation(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -107,7 +128,7 @@ func TestCopyLabelsAndAnnotation(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.tfJobInformerSynced = testutil.AlwaysReady @@ -279,6 +300,16 @@ func TestDeletePodsAndServices(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -286,7 +317,7 @@ func TestDeletePodsAndServices(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl fakeServiceControl := &control.FakeServiceControl{} @@ -433,6 +464,16 @@ func TestCleanupTFJob(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -440,7 +481,7 @@ func TestCleanupTFJob(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl fakeServiceControl := &control.FakeServiceControl{} diff --git a/pkg/controller.v1beta2/tensorflow/pod_test.go b/pkg/controller.v1beta2/tensorflow/pod_test.go index 882f4a584a..bc8b9cdad6 100644 --- a/pkg/controller.v1beta2/tensorflow/pod_test.go +++ b/pkg/controller.v1beta2/tensorflow/pod_test.go @@ -19,6 +19,7 @@ import ( "os" "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -40,6 +41,16 @@ func TestAddPod(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -47,7 +58,7 @@ func TestAddPod(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -210,6 +221,16 @@ func TestExitCode(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -217,7 +238,7 @@ func TestExitCode(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, kubeInformerFactory, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.tfJobInformerSynced = testutil.AlwaysReady diff --git a/pkg/controller.v1beta2/tensorflow/service_test.go b/pkg/controller.v1beta2/tensorflow/service_test.go index 34894ce79a..74f6529e3a 100644 --- a/pkg/controller.v1beta2/tensorflow/service_test.go +++ b/pkg/controller.v1beta2/tensorflow/service_test.go @@ -18,6 +18,7 @@ package tensorflow import ( "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -38,6 +39,16 @@ func TestAddService(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -45,7 +56,7 @@ func TestAddService(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady diff --git a/pkg/controller.v1beta2/tensorflow/status_test.go b/pkg/controller.v1beta2/tensorflow/status_test.go index ba12f42e45..293b67a9ef 100644 --- a/pkg/controller.v1beta2/tensorflow/status_test.go +++ b/pkg/controller.v1beta2/tensorflow/status_test.go @@ -18,6 +18,7 @@ package tensorflow import ( "testing" + kubebatchclient "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned" "k8s.io/api/core/v1" kubeclientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -40,6 +41,16 @@ func TestFailed(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -47,7 +58,7 @@ func TestFailed(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) ctr.tfJobInformerSynced = testutil.AlwaysReady ctr.PodInformerSynced = testutil.AlwaysReady ctr.ServiceInformerSynced = testutil.AlwaysReady @@ -366,6 +377,16 @@ func TestStatus(t *testing.T) { }, }, ) + + // Prepare the kube-batch clientset and controller for the test. + kubeBatchClientSet := kubebatchclient.NewForConfigOrDie(&rest.Config{ + Host: "", + ContentConfig: rest.ContentConfig{ + GroupVersion: &v1.SchemeGroupVersion, + }, + }, + ) + config := &rest.Config{ Host: "", ContentConfig: rest.ContentConfig{ @@ -373,7 +394,7 @@ func TestStatus(t *testing.T) { }, } tfJobClientSet := tfjobclientset.NewForConfigOrDie(config) - ctr, _, _ := newTFController(config, kubeClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) + ctr, _, _ := newTFController(config, kubeClientSet, kubeBatchClientSet, tfJobClientSet, controller.NoResyncPeriodFunc, options.ServerOption{}) fakePodControl := &controller.FakePodControl{} ctr.PodControl = fakePodControl ctr.Recorder = &record.FakeRecorder{}