From 6614ec99986b9a1803e905493720f1adce6b98ca Mon Sep 17 00:00:00 2001 From: Klaus Ma Date: Sun, 5 Jan 2020 17:31:33 +0800 Subject: [PATCH] Added v1beta1 API. Signed-off-by: Klaus Ma --- hack/update-gencode.sh | 4 +- pkg/apis/scheduling/register.go | 2 +- pkg/apis/scheduling/types.go | 21 +- .../v1alpha1/zz_generated.conversion.go | 2 +- .../v1alpha2/zz_generated.conversion.go | 60 ++- pkg/apis/scheduling/v1beta1/conversion.go | 32 ++ pkg/apis/scheduling/v1beta1/doc.go | 20 + pkg/apis/scheduling/v1beta1/labels.go | 25 ++ pkg/apis/scheduling/v1beta1/register.go | 58 +++ pkg/apis/scheduling/v1beta1/types.go | 278 +++++++++++++ .../v1beta1/zz_generated.conversion.go | 388 ++++++++++++++++++ .../v1beta1/zz_generated.deepcopy.go | 255 ++++++++++++ pkg/apis/scheduling/zz_generated.deepcopy.go | 16 - pkg/client/clientset/versioned/clientset.go | 30 +- .../versioned/fake/clientset_generated.go | 17 +- .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/scheduling/v1beta1/doc.go | 20 + .../typed/scheduling/v1beta1/fake/doc.go | 20 + .../scheduling/v1beta1/fake/fake_podgroup.go | 140 +++++++ .../scheduling/v1beta1/fake/fake_queue.go | 131 ++++++ .../v1beta1/fake/fake_scheduling_client.go | 44 ++ .../scheduling/v1beta1/generated_expansion.go | 23 ++ .../typed/scheduling/v1beta1/podgroup.go | 191 +++++++++ .../typed/scheduling/v1beta1/queue.go | 180 ++++++++ .../scheduling/v1beta1/scheduling_client.go | 95 +++++ .../informers/externalversions/generic.go | 7 + .../externalversions/scheduling/interface.go | 8 + .../scheduling/v1beta1/interface.go | 52 +++ .../scheduling/v1beta1/podgroup.go | 89 ++++ .../scheduling/v1beta1/queue.go | 88 ++++ .../scheduling/v1beta1/expansion_generated.go | 31 ++ .../listers/scheduling/v1beta1/podgroup.go | 94 +++++ .../listers/scheduling/v1beta1/queue.go | 65 +++ pkg/controllers/apis/job_info.go | 20 - pkg/controllers/apis/request.go | 43 ++ pkg/webhooks/converters/jobs/converter.go | 96 +++++ pkg/webhooks/router/admission.go | 67 +++ pkg/webhooks/router/converter.go | 17 + pkg/webhooks/router/factory.go | 36 -- pkg/webhooks/router/interface.go | 16 + pkg/webhooks/schema/schema.go | 16 + pkg/webhooks/util/util.go | 16 + 43 files changed, 2676 insertions(+), 141 deletions(-) create mode 100644 pkg/apis/scheduling/v1beta1/conversion.go create mode 100644 pkg/apis/scheduling/v1beta1/doc.go create mode 100644 pkg/apis/scheduling/v1beta1/labels.go create mode 100644 pkg/apis/scheduling/v1beta1/register.go create mode 100644 pkg/apis/scheduling/v1beta1/types.go create mode 100644 pkg/apis/scheduling/v1beta1/zz_generated.conversion.go create mode 100644 pkg/apis/scheduling/v1beta1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_podgroup.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_queue.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_scheduling_client.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/podgroup.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/queue.go create mode 100644 pkg/client/clientset/versioned/typed/scheduling/v1beta1/scheduling_client.go create mode 100644 pkg/client/informers/externalversions/scheduling/v1beta1/interface.go create mode 100644 pkg/client/informers/externalversions/scheduling/v1beta1/podgroup.go create mode 100644 pkg/client/informers/externalversions/scheduling/v1beta1/queue.go create mode 100644 pkg/client/listers/scheduling/v1beta1/expansion_generated.go create mode 100644 pkg/client/listers/scheduling/v1beta1/podgroup.go create mode 100644 pkg/client/listers/scheduling/v1beta1/queue.go create mode 100644 pkg/controllers/apis/request.go create mode 100644 pkg/webhooks/converters/jobs/converter.go create mode 100644 pkg/webhooks/router/admission.go create mode 100644 pkg/webhooks/router/converter.go delete mode 100644 pkg/webhooks/router/factory.go diff --git a/hack/update-gencode.sh b/hack/update-gencode.sh index 815648a3b1a..e05fc47f9b0 100755 --- a/hack/update-gencode.sh +++ b/hack/update-gencode.sh @@ -29,12 +29,12 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ volcano.sh/volcano/pkg/client volcano.sh/volcano/pkg/apis \ - "batch:v1alpha1 bus:v1alpha1 scheduling:v1alpha1,v1alpha2" \ + "batch:v1alpha1 bus:v1alpha1 scheduling:v1alpha1,v1alpha2,v1beta1" \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt "${CODEGEN_PKG}/generate-internal-groups.sh" "deepcopy,conversion" \ volcano.sh/volcano/pkg/apis/ volcano.sh/volcano/pkg/apis volcano.sh/volcano/pkg/apis\ - "scheduling:v1alpha1,v1alpha2" \ + "scheduling:v1alpha1,v1alpha2,v1beta1" \ --output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt diff --git a/pkg/apis/scheduling/register.go b/pkg/apis/scheduling/register.go index 2e7e863ecd9..e214a4e0302 100644 --- a/pkg/apis/scheduling/register.go +++ b/pkg/apis/scheduling/register.go @@ -28,7 +28,7 @@ var ( ) // GroupName is the group name used in this package. -const GroupName = "scheduling.sigs.dev" +const GroupName = "scheduling.volcano.sh" // SchemeGroupVersion is the group version used to register these objects. var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} diff --git a/pkg/apis/scheduling/types.go b/pkg/apis/scheduling/types.go index b6b1e296d10..ec74fe6b7d9 100644 --- a/pkg/apis/scheduling/types.go +++ b/pkg/apis/scheduling/types.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 The Volcano Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -243,6 +243,9 @@ type Queue struct { // QueueStatus represents the status of Queue. type QueueStatus struct { + // State is status of queue + State QueueState + // The number of 'Unknown' PodGroup in this queue. Unknown int32 // The number of 'Pending' PodGroup in this queue. @@ -251,15 +254,14 @@ type QueueStatus struct { Running int32 // The number of `Inqueue` PodGroup in this queue. Inqueue int32 - // State is status of queue - State QueueState } // QueueSpec represents the template of Queue. type QueueSpec struct { Weight int32 Capability v1.ResourceList - // State controller the status of queue + + // Depreicated: replaced by status.State State QueueState // Reclaimable indicate whether the queue can be reclaimed by other queue Reclaimable *bool @@ -278,14 +280,3 @@ type QueueList struct { // items is the list of PodGroup Items []Queue } - -// QueueRequest struct -type QueueRequest struct { - // Name is queue name - Name string - - // Event is event of queue - Event QueueEvent - // Action is action to be performed - Action QueueAction -} diff --git a/pkg/apis/scheduling/v1alpha1/zz_generated.conversion.go b/pkg/apis/scheduling/v1alpha1/zz_generated.conversion.go index c0ee56fd6cf..5db7d4efa6c 100644 --- a/pkg/apis/scheduling/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/scheduling/v1alpha1/zz_generated.conversion.go @@ -383,10 +383,10 @@ func Convert_v1alpha1_QueueStatus_To_scheduling_QueueStatus(in *QueueStatus, out } func autoConvert_scheduling_QueueStatus_To_v1alpha1_QueueStatus(in *scheduling.QueueStatus, out *QueueStatus, s conversion.Scope) error { + // WARNING: in.State requires manual conversion: does not exist in peer-type out.Unknown = in.Unknown out.Pending = in.Pending out.Running = in.Running // WARNING: in.Inqueue requires manual conversion: does not exist in peer-type - // WARNING: in.State requires manual conversion: does not exist in peer-type return nil } diff --git a/pkg/apis/scheduling/v1alpha2/zz_generated.conversion.go b/pkg/apis/scheduling/v1alpha2/zz_generated.conversion.go index 0a8b37acabb..52083ac9188 100644 --- a/pkg/apis/scheduling/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/scheduling/v1alpha2/zz_generated.conversion.go @@ -106,16 +106,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*QueueRequest)(nil), (*scheduling.QueueRequest)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_QueueRequest_To_scheduling_QueueRequest(a.(*QueueRequest), b.(*scheduling.QueueRequest), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*scheduling.QueueRequest)(nil), (*QueueRequest)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_scheduling_QueueRequest_To_v1alpha2_QueueRequest(a.(*scheduling.QueueRequest), b.(*QueueRequest), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*QueueSpec)(nil), (*scheduling.QueueSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha2_QueueSpec_To_scheduling_QueueSpec(a.(*QueueSpec), b.(*scheduling.QueueSpec), scope) }); err != nil { @@ -311,7 +301,17 @@ func Convert_scheduling_Queue_To_v1alpha2_Queue(in *scheduling.Queue, out *Queue func autoConvert_v1alpha2_QueueList_To_scheduling_QueueList(in *QueueList, out *scheduling.QueueList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]scheduling.Queue)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]scheduling.Queue, len(*in)) + for i := range *in { + if err := Convert_v1alpha2_Queue_To_scheduling_Queue(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -322,7 +322,17 @@ func Convert_v1alpha2_QueueList_To_scheduling_QueueList(in *QueueList, out *sche func autoConvert_scheduling_QueueList_To_v1alpha2_QueueList(in *scheduling.QueueList, out *QueueList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]Queue)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Queue, len(*in)) + for i := range *in { + if err := Convert_scheduling_Queue_To_v1alpha2_Queue(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -331,30 +341,6 @@ func Convert_scheduling_QueueList_To_v1alpha2_QueueList(in *scheduling.QueueList return autoConvert_scheduling_QueueList_To_v1alpha2_QueueList(in, out, s) } -func autoConvert_v1alpha2_QueueRequest_To_scheduling_QueueRequest(in *QueueRequest, out *scheduling.QueueRequest, s conversion.Scope) error { - out.Name = in.Name - out.Event = scheduling.QueueEvent(in.Event) - out.Action = scheduling.QueueAction(in.Action) - return nil -} - -// Convert_v1alpha2_QueueRequest_To_scheduling_QueueRequest is an autogenerated conversion function. -func Convert_v1alpha2_QueueRequest_To_scheduling_QueueRequest(in *QueueRequest, out *scheduling.QueueRequest, s conversion.Scope) error { - return autoConvert_v1alpha2_QueueRequest_To_scheduling_QueueRequest(in, out, s) -} - -func autoConvert_scheduling_QueueRequest_To_v1alpha2_QueueRequest(in *scheduling.QueueRequest, out *QueueRequest, s conversion.Scope) error { - out.Name = in.Name - out.Event = QueueEvent(in.Event) - out.Action = QueueAction(in.Action) - return nil -} - -// Convert_scheduling_QueueRequest_To_v1alpha2_QueueRequest is an autogenerated conversion function. -func Convert_scheduling_QueueRequest_To_v1alpha2_QueueRequest(in *scheduling.QueueRequest, out *QueueRequest, s conversion.Scope) error { - return autoConvert_scheduling_QueueRequest_To_v1alpha2_QueueRequest(in, out, s) -} - func autoConvert_v1alpha2_QueueSpec_To_scheduling_QueueSpec(in *QueueSpec, out *scheduling.QueueSpec, s conversion.Scope) error { out.Weight = in.Weight out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) @@ -396,11 +382,11 @@ func Convert_v1alpha2_QueueStatus_To_scheduling_QueueStatus(in *QueueStatus, out } func autoConvert_scheduling_QueueStatus_To_v1alpha2_QueueStatus(in *scheduling.QueueStatus, out *QueueStatus, s conversion.Scope) error { + out.State = QueueState(in.State) out.Unknown = in.Unknown out.Pending = in.Pending out.Running = in.Running out.Inqueue = in.Inqueue - out.State = QueueState(in.State) return nil } diff --git a/pkg/apis/scheduling/v1beta1/conversion.go b/pkg/apis/scheduling/v1beta1/conversion.go new file mode 100644 index 00000000000..85e83606a42 --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/conversion.go @@ -0,0 +1,32 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 + +import ( + unsafe "unsafe" + + v1 "k8s.io/api/core/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + scheduling "volcano.sh/volcano/pkg/apis/scheduling" +) + +func Convert_scheduling_QueueSpec_To_v1beta1_QueueSpec(in *scheduling.QueueSpec, out *QueueSpec, s conversion.Scope) error { + out.Weight = in.Weight + out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) + + return nil +} diff --git a/pkg/apis/scheduling/v1beta1/doc.go b/pkg/apis/scheduling/v1beta1/doc.go new file mode 100644 index 00000000000..b119599815b --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Volcano 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 +// +k8s:conversion-gen=volcano.sh/volcano/pkg/apis/scheduling + +package v1beta1 diff --git a/pkg/apis/scheduling/v1beta1/labels.go b/pkg/apis/scheduling/v1beta1/labels.go new file mode 100644 index 00000000000..2c9e5901933 --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/labels.go @@ -0,0 +1,25 @@ +/* +Copyright 2019 The Volcano 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 v1beta1 + +// KubeGroupNameAnnotationKey is the annotation key of Pod to identify +// which PodGroup it belongs to. +const KubeGroupNameAnnotationKey = "scheduling.k8s.io/group-name" + +// VolcanoGroupNameAnnotationKey is the annotation key of Pod to identify +// which PodGroup it belongs to. +const VolcanoGroupNameAnnotationKey = "scheduling.volcano.sh/group-name" diff --git a/pkg/apis/scheduling/v1beta1/register.go b/pkg/apis/scheduling/v1beta1/register.go new file mode 100644 index 00000000000..1ccd58e1feb --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2019 The Volcano 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 v1beta1 + +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) + localSchemeBuilder = &SchemeBuilder + AddToScheme = SchemeBuilder.AddToScheme +) + +const ( + // GroupName is the group name used in this package. + GroupName = "scheduling.volcano.sh" + + // GroupVersion is the version of scheduling group + GroupVersion = "v1alpha2" +) + +// 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/pkg/apis/scheduling/v1beta1/types.go b/pkg/apis/scheduling/v1beta1/types.go new file mode 100644 index 00000000000..d6bb8a7aad7 --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/types.go @@ -0,0 +1,278 @@ +/* +Copyright 2019 The Volcano 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 v1beta1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PodGroupPhase is the phase of a pod group at the current time. +type PodGroupPhase string + +// QueueState is state type of queue +type QueueState string + +const ( + // QueueStateOpen indicate `Open` state of queue + QueueStateOpen QueueState = "Open" + // QueueStateClosed indicate `Closed` state of queue + QueueStateClosed QueueState = "Closed" + // QueueStateClosing indicate `Closing` state of queue + QueueStateClosing QueueState = "Closing" + // QueueStateUnknown indicate `Unknown` state of queue + QueueStateUnknown QueueState = "Unknown" +) + +// These are the valid phase of podGroups. +const ( + // PodPending means the pod group has been accepted by the system, but scheduler can not allocate + // enough resources to it. + PodGroupPending PodGroupPhase = "Pending" + + // PodRunning means `spec.minMember` pods of PodGroups has been in running phase. + PodGroupRunning PodGroupPhase = "Running" + + // PodGroupUnknown means part of `spec.minMember` pods are running but the other part can not + // be scheduled, e.g. not enough resource; scheduler will wait for related controller to recover it. + PodGroupUnknown PodGroupPhase = "Unknown" + + // PodGroupInqueue means controllers can start to create pods, + // is a new state between PodGroupPending and PodGroupRunning + PodGroupInqueue PodGroupPhase = "Inqueue" +) + +type PodGroupConditionType string + +const ( + // PodGroupUnschedulableType is Unschedulable event type + PodGroupUnschedulableType PodGroupConditionType = "Unschedulable" + + // PodGroupScheduled is scheduled event type + PodGroupScheduled PodGroupConditionType = "Scheduled" +) + +type PodGroupConditionDetail string + +const ( + // PodGroupReady is that PodGroup has reached scheduling restriction + PodGroupReady PodGroupConditionDetail = "pod group is ready" + // PodGroupNotReady is that PodGroup has not yet reached the scheduling restriction + PodGroupNotReady PodGroupConditionDetail = "pod group is not ready" +) + +// PodGroupCondition contains details for the current state of this pod group. +type PodGroupCondition struct { + // Type is the type of the condition + Type PodGroupConditionType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"` + + // Status is the status of the condition. + Status v1.ConditionStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"` + + // The ID of condition transition. + TransitionID string `json:"transitionID,omitempty" protobuf:"bytes,3,opt,name=transitionID"` + + // Last time the phase transitioned from another to current phase. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` + + // Unique, one-word, CamelCase reason for the phase's last transition. + // +optional + Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"` + + // Human-readable message indicating details about last transition. + // +optional + Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"` +} + +const ( + // PodFailedReason is probed if pod of PodGroup failed + PodFailedReason string = "PodFailed" + + // PodDeletedReason is probed if pod of PodGroup deleted + PodDeletedReason string = "PodDeleted" + + // NotEnoughResourcesReason is probed if there're not enough resources to schedule pods + NotEnoughResourcesReason string = "NotEnoughResources" + + // NotEnoughPodsReason is probed if there're not enough tasks compared to `spec.minMember` + NotEnoughPodsReason string = "NotEnoughTasks" +) + +// QueueEvent represent the phase of queue +type QueueEvent string + +const ( + // QueueOutOfSyncEvent is triggered if PodGroup/Queue were updated + QueueOutOfSyncEvent QueueEvent = "OutOfSync" + // QueueCommandIssuedEvent is triggered if a command is raised by user + QueueCommandIssuedEvent QueueEvent = "CommandIssued" +) + +// QueueAction is the action that queue controller will take according to the event. +type QueueAction string + +const ( + // SyncQueueAction is the action to sync queue status. + SyncQueueAction QueueAction = "SyncQueue" + // OpenQueueAction is the action to open queue + OpenQueueAction QueueAction = "OpenQueue" + // CloseQueueAction is the action to close queue + CloseQueueAction QueueAction = "CloseQueue" +) + +// +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. Defaults to `default` Queue with the lowest weight. + // +optional + Queue string `json:"queue,omitempty" protobuf:"bytes,2,opt,name=queue"` + + // If specified, indicates the PodGroup's priority. "system-node-critical" and + // "system-cluster-critical" are two special keywords which indicate the + // highest priorities with the former being the highest priority. Any other + // name must be defined by creating a PriorityClass object with that name. + // If not specified, the PodGroup priority will be default or zero if there is no + // default. + // +optional + PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,3,opt,name=priorityClassName"` + + // MinResources defines the minimal resource of members/tasks to run the pod group; + // if there's not enough resources to start all tasks, the scheduler + // will not start anyone. + MinResources *v1.ResourceList `json:"minResources,omitempty" protobuf:"bytes,4,opt,name=minResources"` +} + +// PodGroupStatus represents the current state of a pod group. +type PodGroupStatus struct { + // Current phase of PodGroup. + Phase PodGroupPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase"` + + // The conditions of PodGroup. + // +optional + Conditions []PodGroupCondition `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"` + + // 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,4,opt,name=succeeded"` + + // The number of pods which reached phase Failed. + // +optional + Failed int32 `json:"failed,omitempty" protobuf:"bytes,5,opt,name=failed"` +} + +// +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 queue. + // 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"` + + // The status of queue. + // +optional + Status QueueStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// QueueStatus represents the status of Queue. +type QueueStatus struct { + // State is state of queue + State QueueState `json:"state,omitempty" protobuf:"bytes,1,opt,name=state"` + + // The number of 'Unknown' PodGroup in this queue. + Unknown int32 `json:"unknown,omitempty" protobuf:"bytes,2,opt,name=unknown"` + // The number of 'Pending' PodGroup in this queue. + Pending int32 `json:"pending,omitempty" protobuf:"bytes,3,opt,name=pending"` + // The number of 'Running' PodGroup in this queue. + Running int32 `json:"running,omitempty" protobuf:"bytes,4,opt,name=running"` + // The number of `Inqueue` PodGroup in this queue. + Inqueue int32 `json:"inqueue,omitempty" protobuf:"bytes,5,opt,name=inqueue"` +} + +// QueueSpec represents the template of Queue. +type QueueSpec struct { + Weight int32 `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"` + Capability v1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"` +} + +// +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/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go b/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go new file mode 100644 index 00000000000..689d6c2dc41 --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/zz_generated.conversion.go @@ -0,0 +1,388 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 The Volcano 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 conversion-gen. DO NOT EDIT. + +package v1beta1 + +import ( + unsafe "unsafe" + + v1 "k8s.io/api/core/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + scheduling "volcano.sh/volcano/pkg/apis/scheduling" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*PodGroup)(nil), (*scheduling.PodGroup)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_PodGroup_To_scheduling_PodGroup(a.(*PodGroup), b.(*scheduling.PodGroup), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.PodGroup)(nil), (*PodGroup)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_PodGroup_To_v1beta1_PodGroup(a.(*scheduling.PodGroup), b.(*PodGroup), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodGroupCondition)(nil), (*scheduling.PodGroupCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_PodGroupCondition_To_scheduling_PodGroupCondition(a.(*PodGroupCondition), b.(*scheduling.PodGroupCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.PodGroupCondition)(nil), (*PodGroupCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_PodGroupCondition_To_v1beta1_PodGroupCondition(a.(*scheduling.PodGroupCondition), b.(*PodGroupCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodGroupList)(nil), (*scheduling.PodGroupList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_PodGroupList_To_scheduling_PodGroupList(a.(*PodGroupList), b.(*scheduling.PodGroupList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.PodGroupList)(nil), (*PodGroupList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_PodGroupList_To_v1beta1_PodGroupList(a.(*scheduling.PodGroupList), b.(*PodGroupList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodGroupSpec)(nil), (*scheduling.PodGroupSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec(a.(*PodGroupSpec), b.(*scheduling.PodGroupSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.PodGroupSpec)(nil), (*PodGroupSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec(a.(*scheduling.PodGroupSpec), b.(*PodGroupSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PodGroupStatus)(nil), (*scheduling.PodGroupStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus(a.(*PodGroupStatus), b.(*scheduling.PodGroupStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.PodGroupStatus)(nil), (*PodGroupStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus(a.(*scheduling.PodGroupStatus), b.(*PodGroupStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Queue)(nil), (*scheduling.Queue)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Queue_To_scheduling_Queue(a.(*Queue), b.(*scheduling.Queue), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.Queue)(nil), (*Queue)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_Queue_To_v1beta1_Queue(a.(*scheduling.Queue), b.(*Queue), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*QueueList)(nil), (*scheduling.QueueList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_QueueList_To_scheduling_QueueList(a.(*QueueList), b.(*scheduling.QueueList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.QueueList)(nil), (*QueueList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_QueueList_To_v1beta1_QueueList(a.(*scheduling.QueueList), b.(*QueueList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*QueueSpec)(nil), (*scheduling.QueueSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_QueueSpec_To_scheduling_QueueSpec(a.(*QueueSpec), b.(*scheduling.QueueSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.QueueSpec)(nil), (*QueueSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_QueueSpec_To_v1beta1_QueueSpec(a.(*scheduling.QueueSpec), b.(*QueueSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*QueueStatus)(nil), (*scheduling.QueueStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_QueueStatus_To_scheduling_QueueStatus(a.(*QueueStatus), b.(*scheduling.QueueStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*scheduling.QueueStatus)(nil), (*QueueStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_scheduling_QueueStatus_To_v1beta1_QueueStatus(a.(*scheduling.QueueStatus), b.(*QueueStatus), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1beta1_PodGroup_To_scheduling_PodGroup(in *PodGroup, out *scheduling.PodGroup, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_PodGroup_To_scheduling_PodGroup is an autogenerated conversion function. +func Convert_v1beta1_PodGroup_To_scheduling_PodGroup(in *PodGroup, out *scheduling.PodGroup, s conversion.Scope) error { + return autoConvert_v1beta1_PodGroup_To_scheduling_PodGroup(in, out, s) +} + +func autoConvert_scheduling_PodGroup_To_v1beta1_PodGroup(in *scheduling.PodGroup, out *PodGroup, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_scheduling_PodGroup_To_v1beta1_PodGroup is an autogenerated conversion function. +func Convert_scheduling_PodGroup_To_v1beta1_PodGroup(in *scheduling.PodGroup, out *PodGroup, s conversion.Scope) error { + return autoConvert_scheduling_PodGroup_To_v1beta1_PodGroup(in, out, s) +} + +func autoConvert_v1beta1_PodGroupCondition_To_scheduling_PodGroupCondition(in *PodGroupCondition, out *scheduling.PodGroupCondition, s conversion.Scope) error { + out.Type = scheduling.PodGroupConditionType(in.Type) + out.Status = v1.ConditionStatus(in.Status) + out.TransitionID = in.TransitionID + out.LastTransitionTime = in.LastTransitionTime + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +// Convert_v1beta1_PodGroupCondition_To_scheduling_PodGroupCondition is an autogenerated conversion function. +func Convert_v1beta1_PodGroupCondition_To_scheduling_PodGroupCondition(in *PodGroupCondition, out *scheduling.PodGroupCondition, s conversion.Scope) error { + return autoConvert_v1beta1_PodGroupCondition_To_scheduling_PodGroupCondition(in, out, s) +} + +func autoConvert_scheduling_PodGroupCondition_To_v1beta1_PodGroupCondition(in *scheduling.PodGroupCondition, out *PodGroupCondition, s conversion.Scope) error { + out.Type = PodGroupConditionType(in.Type) + out.Status = v1.ConditionStatus(in.Status) + out.TransitionID = in.TransitionID + out.LastTransitionTime = in.LastTransitionTime + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +// Convert_scheduling_PodGroupCondition_To_v1beta1_PodGroupCondition is an autogenerated conversion function. +func Convert_scheduling_PodGroupCondition_To_v1beta1_PodGroupCondition(in *scheduling.PodGroupCondition, out *PodGroupCondition, s conversion.Scope) error { + return autoConvert_scheduling_PodGroupCondition_To_v1beta1_PodGroupCondition(in, out, s) +} + +func autoConvert_v1beta1_PodGroupList_To_scheduling_PodGroupList(in *PodGroupList, out *scheduling.PodGroupList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]scheduling.PodGroup)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1beta1_PodGroupList_To_scheduling_PodGroupList is an autogenerated conversion function. +func Convert_v1beta1_PodGroupList_To_scheduling_PodGroupList(in *PodGroupList, out *scheduling.PodGroupList, s conversion.Scope) error { + return autoConvert_v1beta1_PodGroupList_To_scheduling_PodGroupList(in, out, s) +} + +func autoConvert_scheduling_PodGroupList_To_v1beta1_PodGroupList(in *scheduling.PodGroupList, out *PodGroupList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]PodGroup)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_scheduling_PodGroupList_To_v1beta1_PodGroupList is an autogenerated conversion function. +func Convert_scheduling_PodGroupList_To_v1beta1_PodGroupList(in *scheduling.PodGroupList, out *PodGroupList, s conversion.Scope) error { + return autoConvert_scheduling_PodGroupList_To_v1beta1_PodGroupList(in, out, s) +} + +func autoConvert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec(in *PodGroupSpec, out *scheduling.PodGroupSpec, s conversion.Scope) error { + out.MinMember = in.MinMember + out.Queue = in.Queue + out.PriorityClassName = in.PriorityClassName + out.MinResources = (*v1.ResourceList)(unsafe.Pointer(in.MinResources)) + return nil +} + +// Convert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec is an autogenerated conversion function. +func Convert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec(in *PodGroupSpec, out *scheduling.PodGroupSpec, s conversion.Scope) error { + return autoConvert_v1beta1_PodGroupSpec_To_scheduling_PodGroupSpec(in, out, s) +} + +func autoConvert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec(in *scheduling.PodGroupSpec, out *PodGroupSpec, s conversion.Scope) error { + out.MinMember = in.MinMember + out.Queue = in.Queue + out.PriorityClassName = in.PriorityClassName + out.MinResources = (*v1.ResourceList)(unsafe.Pointer(in.MinResources)) + return nil +} + +// Convert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec is an autogenerated conversion function. +func Convert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec(in *scheduling.PodGroupSpec, out *PodGroupSpec, s conversion.Scope) error { + return autoConvert_scheduling_PodGroupSpec_To_v1beta1_PodGroupSpec(in, out, s) +} + +func autoConvert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus(in *PodGroupStatus, out *scheduling.PodGroupStatus, s conversion.Scope) error { + out.Phase = scheduling.PodGroupPhase(in.Phase) + out.Conditions = *(*[]scheduling.PodGroupCondition)(unsafe.Pointer(&in.Conditions)) + out.Running = in.Running + out.Succeeded = in.Succeeded + out.Failed = in.Failed + return nil +} + +// Convert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus is an autogenerated conversion function. +func Convert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus(in *PodGroupStatus, out *scheduling.PodGroupStatus, s conversion.Scope) error { + return autoConvert_v1beta1_PodGroupStatus_To_scheduling_PodGroupStatus(in, out, s) +} + +func autoConvert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus(in *scheduling.PodGroupStatus, out *PodGroupStatus, s conversion.Scope) error { + out.Phase = PodGroupPhase(in.Phase) + out.Conditions = *(*[]PodGroupCondition)(unsafe.Pointer(&in.Conditions)) + out.Running = in.Running + out.Succeeded = in.Succeeded + out.Failed = in.Failed + return nil +} + +// Convert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus is an autogenerated conversion function. +func Convert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus(in *scheduling.PodGroupStatus, out *PodGroupStatus, s conversion.Scope) error { + return autoConvert_scheduling_PodGroupStatus_To_v1beta1_PodGroupStatus(in, out, s) +} + +func autoConvert_v1beta1_Queue_To_scheduling_Queue(in *Queue, out *scheduling.Queue, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_QueueSpec_To_scheduling_QueueSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_QueueStatus_To_scheduling_QueueStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_Queue_To_scheduling_Queue is an autogenerated conversion function. +func Convert_v1beta1_Queue_To_scheduling_Queue(in *Queue, out *scheduling.Queue, s conversion.Scope) error { + return autoConvert_v1beta1_Queue_To_scheduling_Queue(in, out, s) +} + +func autoConvert_scheduling_Queue_To_v1beta1_Queue(in *scheduling.Queue, out *Queue, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_scheduling_QueueSpec_To_v1beta1_QueueSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_scheduling_QueueStatus_To_v1beta1_QueueStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_scheduling_Queue_To_v1beta1_Queue is an autogenerated conversion function. +func Convert_scheduling_Queue_To_v1beta1_Queue(in *scheduling.Queue, out *Queue, s conversion.Scope) error { + return autoConvert_scheduling_Queue_To_v1beta1_Queue(in, out, s) +} + +func autoConvert_v1beta1_QueueList_To_scheduling_QueueList(in *QueueList, out *scheduling.QueueList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]scheduling.Queue, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Queue_To_scheduling_Queue(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_QueueList_To_scheduling_QueueList is an autogenerated conversion function. +func Convert_v1beta1_QueueList_To_scheduling_QueueList(in *QueueList, out *scheduling.QueueList, s conversion.Scope) error { + return autoConvert_v1beta1_QueueList_To_scheduling_QueueList(in, out, s) +} + +func autoConvert_scheduling_QueueList_To_v1beta1_QueueList(in *scheduling.QueueList, out *QueueList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Queue, len(*in)) + for i := range *in { + if err := Convert_scheduling_Queue_To_v1beta1_Queue(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_scheduling_QueueList_To_v1beta1_QueueList is an autogenerated conversion function. +func Convert_scheduling_QueueList_To_v1beta1_QueueList(in *scheduling.QueueList, out *QueueList, s conversion.Scope) error { + return autoConvert_scheduling_QueueList_To_v1beta1_QueueList(in, out, s) +} + +func autoConvert_v1beta1_QueueSpec_To_scheduling_QueueSpec(in *QueueSpec, out *scheduling.QueueSpec, s conversion.Scope) error { + out.Weight = in.Weight + out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) + return nil +} + +// Convert_v1beta1_QueueSpec_To_scheduling_QueueSpec is an autogenerated conversion function. +func Convert_v1beta1_QueueSpec_To_scheduling_QueueSpec(in *QueueSpec, out *scheduling.QueueSpec, s conversion.Scope) error { + return autoConvert_v1beta1_QueueSpec_To_scheduling_QueueSpec(in, out, s) +} + +func autoConvert_scheduling_QueueSpec_To_v1beta1_QueueSpec(in *scheduling.QueueSpec, out *QueueSpec, s conversion.Scope) error { + out.Weight = in.Weight + out.Capability = *(*v1.ResourceList)(unsafe.Pointer(&in.Capability)) + // WARNING: in.State requires manual conversion: does not exist in peer-type + return nil +} + +func autoConvert_v1beta1_QueueStatus_To_scheduling_QueueStatus(in *QueueStatus, out *scheduling.QueueStatus, s conversion.Scope) error { + out.State = scheduling.QueueState(in.State) + out.Unknown = in.Unknown + out.Pending = in.Pending + out.Running = in.Running + out.Inqueue = in.Inqueue + return nil +} + +// Convert_v1beta1_QueueStatus_To_scheduling_QueueStatus is an autogenerated conversion function. +func Convert_v1beta1_QueueStatus_To_scheduling_QueueStatus(in *QueueStatus, out *scheduling.QueueStatus, s conversion.Scope) error { + return autoConvert_v1beta1_QueueStatus_To_scheduling_QueueStatus(in, out, s) +} + +func autoConvert_scheduling_QueueStatus_To_v1beta1_QueueStatus(in *scheduling.QueueStatus, out *QueueStatus, s conversion.Scope) error { + out.State = QueueState(in.State) + out.Unknown = in.Unknown + out.Pending = in.Pending + out.Running = in.Running + out.Inqueue = in.Inqueue + return nil +} + +// Convert_scheduling_QueueStatus_To_v1beta1_QueueStatus is an autogenerated conversion function. +func Convert_scheduling_QueueStatus_To_v1beta1_QueueStatus(in *scheduling.QueueStatus, out *QueueStatus, s conversion.Scope) error { + return autoConvert_scheduling_QueueStatus_To_v1beta1_QueueStatus(in, out, s) +} diff --git a/pkg/apis/scheduling/v1beta1/zz_generated.deepcopy.go b/pkg/apis/scheduling/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..48dd5d1ad57 --- /dev/null +++ b/pkg/apis/scheduling/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,255 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 The Volcano 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 v1beta1 + +import ( + v1 "k8s.io/api/core/v1" + resource "k8s.io/apimachinery/pkg/api/resource" + 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 *PodGroup) DeepCopyInto(out *PodGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.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 *PodGroupCondition) DeepCopyInto(out *PodGroupCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodGroupCondition. +func (in *PodGroupCondition) DeepCopy() *PodGroupCondition { + if in == nil { + return nil + } + out := new(PodGroupCondition) + in.DeepCopyInto(out) + return out +} + +// 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 + if in.MinResources != nil { + in, out := &in.MinResources, &out.MinResources + *out = new(v1.ResourceList) + if **in != nil { + in, out := *in, *out + *out = make(map[v1.ResourceName]resource.Quantity, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + } + 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 + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]PodGroupCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + 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) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + 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 + if in.Capability != nil { + in, out := &in.Capability, &out.Capability + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + 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 +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *QueueStatus) DeepCopyInto(out *QueueStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueStatus. +func (in *QueueStatus) DeepCopy() *QueueStatus { + if in == nil { + return nil + } + out := new(QueueStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/scheduling/zz_generated.deepcopy.go b/pkg/apis/scheduling/zz_generated.deepcopy.go index e0873b3024f..532d164703a 100644 --- a/pkg/apis/scheduling/zz_generated.deepcopy.go +++ b/pkg/apis/scheduling/zz_generated.deepcopy.go @@ -215,22 +215,6 @@ func (in *QueueList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *QueueRequest) DeepCopyInto(out *QueueRequest) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueueRequest. -func (in *QueueRequest) DeepCopy() *QueueRequest { - if in == nil { - return nil - } - out := new(QueueRequest) - in.DeepCopyInto(out) - return out -} - // 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 diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 3e2e956999c..42697eb09be 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -26,6 +26,7 @@ import ( busv1alpha1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/bus/v1alpha1" schedulingv1alpha1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1alpha1" schedulingv1alpha2 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1alpha2" + schedulingv1beta1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1beta1" ) type Interface interface { @@ -37,9 +38,10 @@ type Interface interface { // Deprecated: please explicitly pick a version if possible. Bus() busv1alpha1.BusV1alpha1Interface SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface - // Deprecated: please explicitly pick a version if possible. - Scheduling() schedulingv1alpha1.SchedulingV1alpha1Interface SchedulingV1alpha2() schedulingv1alpha2.SchedulingV1alpha2Interface + SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface + // Deprecated: please explicitly pick a version if possible. + Scheduling() schedulingv1beta1.SchedulingV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -50,6 +52,7 @@ type Clientset struct { busV1alpha1 *busv1alpha1.BusV1alpha1Client schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client schedulingV1alpha2 *schedulingv1alpha2.SchedulingV1alpha2Client + schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1Client } // BatchV1alpha1 retrieves the BatchV1alpha1Client @@ -79,17 +82,22 @@ func (c *Clientset) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1In 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 -} - // SchedulingV1alpha2 retrieves the SchedulingV1alpha2Client func (c *Clientset) SchedulingV1alpha2() schedulingv1alpha2.SchedulingV1alpha2Interface { return c.schedulingV1alpha2 } +// SchedulingV1beta1 retrieves the SchedulingV1beta1Client +func (c *Clientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface { + return c.schedulingV1beta1 +} + +// Deprecated: Scheduling retrieves the default version of SchedulingClient. +// Please explicitly pick a version. +func (c *Clientset) Scheduling() schedulingv1beta1.SchedulingV1beta1Interface { + return c.schedulingV1beta1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -122,6 +130,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.schedulingV1beta1, err = schedulingv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -138,6 +150,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.busV1alpha1 = busv1alpha1.NewForConfigOrDie(c) cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c) cs.schedulingV1alpha2 = schedulingv1alpha2.NewForConfigOrDie(c) + cs.schedulingV1beta1 = schedulingv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -150,6 +163,7 @@ func New(c rest.Interface) *Clientset { cs.busV1alpha1 = busv1alpha1.New(c) cs.schedulingV1alpha1 = schedulingv1alpha1.New(c) cs.schedulingV1alpha2 = schedulingv1alpha2.New(c) + cs.schedulingV1beta1 = schedulingv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index d4f5e50ffa1..ffea7675b62 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -33,6 +33,8 @@ import ( fakeschedulingv1alpha1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1alpha1/fake" schedulingv1alpha2 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1alpha2" fakeschedulingv1alpha2 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1alpha2/fake" + schedulingv1beta1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1beta1" + fakeschedulingv1beta1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -102,12 +104,17 @@ func (c *Clientset) SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1In return &fakeschedulingv1alpha1.FakeSchedulingV1alpha1{Fake: &c.Fake} } -// Scheduling retrieves the SchedulingV1alpha1Client -func (c *Clientset) Scheduling() schedulingv1alpha1.SchedulingV1alpha1Interface { - return &fakeschedulingv1alpha1.FakeSchedulingV1alpha1{Fake: &c.Fake} -} - // SchedulingV1alpha2 retrieves the SchedulingV1alpha2Client func (c *Clientset) SchedulingV1alpha2() schedulingv1alpha2.SchedulingV1alpha2Interface { return &fakeschedulingv1alpha2.FakeSchedulingV1alpha2{Fake: &c.Fake} } + +// SchedulingV1beta1 retrieves the SchedulingV1beta1Client +func (c *Clientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface { + return &fakeschedulingv1beta1.FakeSchedulingV1beta1{Fake: &c.Fake} +} + +// Scheduling retrieves the SchedulingV1beta1Client +func (c *Clientset) Scheduling() schedulingv1beta1.SchedulingV1beta1Interface { + return &fakeschedulingv1beta1.FakeSchedulingV1beta1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 3d1a6b72e4e..782a310420c 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -28,6 +28,7 @@ import ( busv1alpha1 "volcano.sh/volcano/pkg/apis/bus/v1alpha1" schedulingv1alpha1 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1" schedulingv1alpha2 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha2" + schedulingv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" ) var scheme = runtime.NewScheme() @@ -38,6 +39,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ busv1alpha1.AddToScheme, schedulingv1alpha1.AddToScheme, schedulingv1alpha2.AddToScheme, + schedulingv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 2310a85b3d9..d7e2b92e8bc 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -28,6 +28,7 @@ import ( busv1alpha1 "volcano.sh/volcano/pkg/apis/bus/v1alpha1" schedulingv1alpha1 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1" schedulingv1alpha2 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha2" + schedulingv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" ) var Scheme = runtime.NewScheme() @@ -38,6 +39,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ busv1alpha1.AddToScheme, schedulingv1alpha1.AddToScheme, schedulingv1alpha2.AddToScheme, + schedulingv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/doc.go new file mode 100644 index 00000000000..8939985d6d1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/doc.go new file mode 100644 index 00000000000..19a8e6cea3e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Volcano 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 fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_podgroup.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_podgroup.go new file mode 100644 index 00000000000..39e8e5e282b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_podgroup.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 The Volcano 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 fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" +) + +// FakePodGroups implements PodGroupInterface +type FakePodGroups struct { + Fake *FakeSchedulingV1beta1 + ns string +} + +var podgroupsResource = schema.GroupVersionResource{Group: "scheduling", Version: "v1beta1", Resource: "podgroups"} + +var podgroupsKind = schema.GroupVersionKind{Group: "scheduling", Version: "v1beta1", Kind: "PodGroup"} + +// Get takes name of the podGroup, and returns the corresponding podGroup object, and an error if there is any. +func (c *FakePodGroups) Get(name string, options v1.GetOptions) (result *v1beta1.PodGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(podgroupsResource, c.ns, name), &v1beta1.PodGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PodGroup), err +} + +// List takes label and field selectors, and returns the list of PodGroups that match those selectors. +func (c *FakePodGroups) List(opts v1.ListOptions) (result *v1beta1.PodGroupList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(podgroupsResource, podgroupsKind, c.ns, opts), &v1beta1.PodGroupList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.PodGroupList{ListMeta: obj.(*v1beta1.PodGroupList).ListMeta} + for _, item := range obj.(*v1beta1.PodGroupList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested podGroups. +func (c *FakePodGroups) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(podgroupsResource, c.ns, opts)) + +} + +// 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 *FakePodGroups) Create(podGroup *v1beta1.PodGroup) (result *v1beta1.PodGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(podgroupsResource, c.ns, podGroup), &v1beta1.PodGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PodGroup), err +} + +// 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 *FakePodGroups) Update(podGroup *v1beta1.PodGroup) (result *v1beta1.PodGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(podgroupsResource, c.ns, podGroup), &v1beta1.PodGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PodGroup), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePodGroups) UpdateStatus(podGroup *v1beta1.PodGroup) (*v1beta1.PodGroup, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(podgroupsResource, "status", c.ns, podGroup), &v1beta1.PodGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PodGroup), err +} + +// Delete takes name of the podGroup and deletes it. Returns an error if one occurs. +func (c *FakePodGroups) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(podgroupsResource, c.ns, name), &v1beta1.PodGroup{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePodGroups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(podgroupsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.PodGroupList{}) + return err +} + +// Patch applies the patch and returns the patched podGroup. +func (c *FakePodGroups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PodGroup, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podgroupsResource, c.ns, name, pt, data, subresources...), &v1beta1.PodGroup{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PodGroup), err +} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_queue.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_queue.go new file mode 100644 index 00000000000..ed41577aef5 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_queue.go @@ -0,0 +1,131 @@ +/* +Copyright 2020 The Volcano 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 fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" +) + +// FakeQueues implements QueueInterface +type FakeQueues struct { + Fake *FakeSchedulingV1beta1 +} + +var queuesResource = schema.GroupVersionResource{Group: "scheduling", Version: "v1beta1", Resource: "queues"} + +var queuesKind = schema.GroupVersionKind{Group: "scheduling", Version: "v1beta1", Kind: "Queue"} + +// Get takes name of the queue, and returns the corresponding queue object, and an error if there is any. +func (c *FakeQueues) Get(name string, options v1.GetOptions) (result *v1beta1.Queue, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(queuesResource, name), &v1beta1.Queue{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Queue), err +} + +// List takes label and field selectors, and returns the list of Queues that match those selectors. +func (c *FakeQueues) List(opts v1.ListOptions) (result *v1beta1.QueueList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(queuesResource, queuesKind, opts), &v1beta1.QueueList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.QueueList{ListMeta: obj.(*v1beta1.QueueList).ListMeta} + for _, item := range obj.(*v1beta1.QueueList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested queues. +func (c *FakeQueues) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(queuesResource, opts)) +} + +// 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 *FakeQueues) Create(queue *v1beta1.Queue) (result *v1beta1.Queue, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(queuesResource, queue), &v1beta1.Queue{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Queue), err +} + +// 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 *FakeQueues) Update(queue *v1beta1.Queue) (result *v1beta1.Queue, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(queuesResource, queue), &v1beta1.Queue{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Queue), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeQueues) UpdateStatus(queue *v1beta1.Queue) (*v1beta1.Queue, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(queuesResource, "status", queue), &v1beta1.Queue{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Queue), err +} + +// Delete takes name of the queue and deletes it. Returns an error if one occurs. +func (c *FakeQueues) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(queuesResource, name), &v1beta1.Queue{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeQueues) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(queuesResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.QueueList{}) + return err +} + +// Patch applies the patch and returns the patched queue. +func (c *FakeQueues) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Queue, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(queuesResource, name, pt, data, subresources...), &v1beta1.Queue{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Queue), err +} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_scheduling_client.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_scheduling_client.go new file mode 100644 index 00000000000..210f7808dd3 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/fake/fake_scheduling_client.go @@ -0,0 +1,44 @@ +/* +Copyright 2020 The Volcano 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 fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1beta1 "volcano.sh/volcano/pkg/client/clientset/versioned/typed/scheduling/v1beta1" +) + +type FakeSchedulingV1beta1 struct { + *testing.Fake +} + +func (c *FakeSchedulingV1beta1) PodGroups(namespace string) v1beta1.PodGroupInterface { + return &FakePodGroups{c, namespace} +} + +func (c *FakeSchedulingV1beta1) Queues() v1beta1.QueueInterface { + return &FakeQueues{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSchedulingV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/generated_expansion.go new file mode 100644 index 00000000000..91ef27d84b6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 + +type PodGroupExpansion interface{} + +type QueueExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/podgroup.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/podgroup.go new file mode 100644 index 00000000000..6773f9f9ff3 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/podgroup.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 + +import ( + "time" + + 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" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" + scheme "volcano.sh/volcano/pkg/client/clientset/versioned/scheme" +) + +// 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(*v1beta1.PodGroup) (*v1beta1.PodGroup, error) + Update(*v1beta1.PodGroup) (*v1beta1.PodGroup, error) + UpdateStatus(*v1beta1.PodGroup) (*v1beta1.PodGroup, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.PodGroup, error) + List(opts v1.ListOptions) (*v1beta1.PodGroupList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PodGroup, err error) + PodGroupExpansion +} + +// podGroups implements PodGroupInterface +type podGroups struct { + client rest.Interface + ns string +} + +// newPodGroups returns a PodGroups +func newPodGroups(c *SchedulingV1beta1Client, 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 *v1beta1.PodGroup, err error) { + result = &v1beta1.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 *v1beta1.PodGroupList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PodGroupList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podGroups. +func (c *podGroups) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + 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 *v1beta1.PodGroup) (result *v1beta1.PodGroup, err error) { + result = &v1beta1.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 *v1beta1.PodGroup) (result *v1beta1.PodGroup, err error) { + result = &v1beta1.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 *v1beta1.PodGroup) (result *v1beta1.PodGroup, err error) { + result = &v1beta1.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 { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("podgroups"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + 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 *v1beta1.PodGroup, err error) { + result = &v1beta1.PodGroup{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podgroups"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/queue.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/queue.go new file mode 100644 index 00000000000..2f7bad79923 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/queue.go @@ -0,0 +1,180 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 + +import ( + "time" + + 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" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" + scheme "volcano.sh/volcano/pkg/client/clientset/versioned/scheme" +) + +// 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(*v1beta1.Queue) (*v1beta1.Queue, error) + Update(*v1beta1.Queue) (*v1beta1.Queue, error) + UpdateStatus(*v1beta1.Queue) (*v1beta1.Queue, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Queue, error) + List(opts v1.ListOptions) (*v1beta1.QueueList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Queue, err error) + QueueExpansion +} + +// queues implements QueueInterface +type queues struct { + client rest.Interface +} + +// newQueues returns a Queues +func newQueues(c *SchedulingV1beta1Client) *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 *v1beta1.Queue, err error) { + result = &v1beta1.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 *v1beta1.QueueList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.QueueList{} + err = c.client.Get(). + Resource("queues"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested queues. +func (c *queues) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("queues"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + 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 *v1beta1.Queue) (result *v1beta1.Queue, err error) { + result = &v1beta1.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 *v1beta1.Queue) (result *v1beta1.Queue, err error) { + result = &v1beta1.Queue{} + err = c.client.Put(). + Resource("queues"). + Name(queue.Name). + Body(queue). + 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 *queues) UpdateStatus(queue *v1beta1.Queue) (result *v1beta1.Queue, err error) { + result = &v1beta1.Queue{} + err = c.client.Put(). + Resource("queues"). + Name(queue.Name). + SubResource("status"). + 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 { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("queues"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + 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 *v1beta1.Queue, err error) { + result = &v1beta1.Queue{} + err = c.client.Patch(pt). + Resource("queues"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/scheduling/v1beta1/scheduling_client.go b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/scheduling_client.go new file mode 100644 index 00000000000..5a04d4b1217 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/scheduling/v1beta1/scheduling_client.go @@ -0,0 +1,95 @@ +/* +Copyright 2020 The Volcano 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 v1beta1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" + "volcano.sh/volcano/pkg/client/clientset/versioned/scheme" +) + +type SchedulingV1beta1Interface interface { + RESTClient() rest.Interface + PodGroupsGetter + QueuesGetter +} + +// SchedulingV1beta1Client is used to interact with features provided by the scheduling group. +type SchedulingV1beta1Client struct { + restClient rest.Interface +} + +func (c *SchedulingV1beta1Client) PodGroups(namespace string) PodGroupInterface { + return newPodGroups(c, namespace) +} + +func (c *SchedulingV1beta1Client) Queues() QueueInterface { + return newQueues(c) +} + +// NewForConfig creates a new SchedulingV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*SchedulingV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &SchedulingV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new SchedulingV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SchedulingV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SchedulingV1beta1Client for the given RESTClient. +func New(c rest.Interface) *SchedulingV1beta1Client { + return &SchedulingV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.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 *SchedulingV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index f66c695d017..c0d6aabcd76 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -27,6 +27,7 @@ import ( busv1alpha1 "volcano.sh/volcano/pkg/apis/bus/v1alpha1" schedulingv1alpha1 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha1" v1alpha2 "volcano.sh/volcano/pkg/apis/scheduling/v1alpha2" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -75,6 +76,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("queues"): return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1alpha2().Queues().Informer()}, nil + // Group=scheduling, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("podgroups"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1beta1().PodGroups().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("queues"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1beta1().Queues().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/scheduling/interface.go b/pkg/client/informers/externalversions/scheduling/interface.go index 13715a27553..4461fd51de0 100644 --- a/pkg/client/informers/externalversions/scheduling/interface.go +++ b/pkg/client/informers/externalversions/scheduling/interface.go @@ -22,6 +22,7 @@ import ( internalinterfaces "volcano.sh/volcano/pkg/client/informers/externalversions/internalinterfaces" v1alpha1 "volcano.sh/volcano/pkg/client/informers/externalversions/scheduling/v1alpha1" v1alpha2 "volcano.sh/volcano/pkg/client/informers/externalversions/scheduling/v1alpha2" + v1beta1 "volcano.sh/volcano/pkg/client/informers/externalversions/scheduling/v1beta1" ) // Interface provides access to each of this group's versions. @@ -30,6 +31,8 @@ type Interface interface { V1alpha1() v1alpha1.Interface // V1alpha2 provides access to shared informers for resources in V1alpha2. V1alpha2() v1alpha2.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -52,3 +55,8 @@ func (g *group) V1alpha1() v1alpha1.Interface { func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/scheduling/v1beta1/interface.go b/pkg/client/informers/externalversions/scheduling/v1beta1/interface.go new file mode 100644 index 00000000000..99095995c0b --- /dev/null +++ b/pkg/client/informers/externalversions/scheduling/v1beta1/interface.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Volcano 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "volcano.sh/volcano/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // PodGroups returns a PodGroupInformer. + PodGroups() PodGroupInformer + // Queues returns a QueueInformer. + Queues() QueueInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// PodGroups returns a PodGroupInformer. +func (v *version) PodGroups() PodGroupInformer { + return &podGroupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Queues returns a QueueInformer. +func (v *version) Queues() QueueInformer { + return &queueInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/scheduling/v1beta1/podgroup.go b/pkg/client/informers/externalversions/scheduling/v1beta1/podgroup.go new file mode 100644 index 00000000000..5b597af99e1 --- /dev/null +++ b/pkg/client/informers/externalversions/scheduling/v1beta1/podgroup.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The Volcano 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + schedulingv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" + versioned "volcano.sh/volcano/pkg/client/clientset/versioned" + internalinterfaces "volcano.sh/volcano/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "volcano.sh/volcano/pkg/client/listers/scheduling/v1beta1" +) + +// PodGroupInformer provides access to a shared informer and lister for +// PodGroups. +type PodGroupInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.PodGroupLister +} + +type podGroupInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPodGroupInformer constructs a new informer for PodGroup type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPodGroupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPodGroupInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPodGroupInformer constructs a new informer for PodGroup type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPodGroupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SchedulingV1beta1().PodGroups(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SchedulingV1beta1().PodGroups(namespace).Watch(options) + }, + }, + &schedulingv1beta1.PodGroup{}, + resyncPeriod, + indexers, + ) +} + +func (f *podGroupInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPodGroupInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *podGroupInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&schedulingv1beta1.PodGroup{}, f.defaultInformer) +} + +func (f *podGroupInformer) Lister() v1beta1.PodGroupLister { + return v1beta1.NewPodGroupLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/scheduling/v1beta1/queue.go b/pkg/client/informers/externalversions/scheduling/v1beta1/queue.go new file mode 100644 index 00000000000..e0dc3e5dee0 --- /dev/null +++ b/pkg/client/informers/externalversions/scheduling/v1beta1/queue.go @@ -0,0 +1,88 @@ +/* +Copyright 2020 The Volcano 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + schedulingv1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" + versioned "volcano.sh/volcano/pkg/client/clientset/versioned" + internalinterfaces "volcano.sh/volcano/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "volcano.sh/volcano/pkg/client/listers/scheduling/v1beta1" +) + +// QueueInformer provides access to a shared informer and lister for +// Queues. +type QueueInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.QueueLister +} + +type queueInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewQueueInformer constructs a new informer for Queue type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewQueueInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredQueueInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredQueueInformer constructs a new informer for Queue type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredQueueInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SchedulingV1beta1().Queues().List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SchedulingV1beta1().Queues().Watch(options) + }, + }, + &schedulingv1beta1.Queue{}, + resyncPeriod, + indexers, + ) +} + +func (f *queueInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredQueueInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *queueInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&schedulingv1beta1.Queue{}, f.defaultInformer) +} + +func (f *queueInformer) Lister() v1beta1.QueueLister { + return v1beta1.NewQueueLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/scheduling/v1beta1/expansion_generated.go b/pkg/client/listers/scheduling/v1beta1/expansion_generated.go new file mode 100644 index 00000000000..32b2eae20e2 --- /dev/null +++ b/pkg/client/listers/scheduling/v1beta1/expansion_generated.go @@ -0,0 +1,31 @@ +/* +Copyright 2020 The Volcano 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +// PodGroupListerExpansion allows custom methods to be added to +// PodGroupLister. +type PodGroupListerExpansion interface{} + +// PodGroupNamespaceListerExpansion allows custom methods to be added to +// PodGroupNamespaceLister. +type PodGroupNamespaceListerExpansion interface{} + +// QueueListerExpansion allows custom methods to be added to +// QueueLister. +type QueueListerExpansion interface{} diff --git a/pkg/client/listers/scheduling/v1beta1/podgroup.go b/pkg/client/listers/scheduling/v1beta1/podgroup.go new file mode 100644 index 00000000000..4e5cb145d59 --- /dev/null +++ b/pkg/client/listers/scheduling/v1beta1/podgroup.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 The Volcano 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" +) + +// PodGroupLister helps list PodGroups. +type PodGroupLister interface { + // List lists all PodGroups in the indexer. + List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) + // PodGroups returns an object that can list and get PodGroups. + PodGroups(namespace string) PodGroupNamespaceLister + PodGroupListerExpansion +} + +// podGroupLister implements the PodGroupLister interface. +type podGroupLister struct { + indexer cache.Indexer +} + +// NewPodGroupLister returns a new PodGroupLister. +func NewPodGroupLister(indexer cache.Indexer) PodGroupLister { + return &podGroupLister{indexer: indexer} +} + +// List lists all PodGroups in the indexer. +func (s *podGroupLister) List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.PodGroup)) + }) + return ret, err +} + +// PodGroups returns an object that can list and get PodGroups. +func (s *podGroupLister) PodGroups(namespace string) PodGroupNamespaceLister { + return podGroupNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PodGroupNamespaceLister helps list and get PodGroups. +type PodGroupNamespaceLister interface { + // List lists all PodGroups in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) + // Get retrieves the PodGroup from the indexer for a given namespace and name. + Get(name string) (*v1beta1.PodGroup, error) + PodGroupNamespaceListerExpansion +} + +// podGroupNamespaceLister implements the PodGroupNamespaceLister +// interface. +type podGroupNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PodGroups in the indexer for a given namespace. +func (s podGroupNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.PodGroup, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.PodGroup)) + }) + return ret, err +} + +// Get retrieves the PodGroup from the indexer for a given namespace and name. +func (s podGroupNamespaceLister) Get(name string) (*v1beta1.PodGroup, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("podgroup"), name) + } + return obj.(*v1beta1.PodGroup), nil +} diff --git a/pkg/client/listers/scheduling/v1beta1/queue.go b/pkg/client/listers/scheduling/v1beta1/queue.go new file mode 100644 index 00000000000..4615ee9b989 --- /dev/null +++ b/pkg/client/listers/scheduling/v1beta1/queue.go @@ -0,0 +1,65 @@ +/* +Copyright 2020 The Volcano 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "volcano.sh/volcano/pkg/apis/scheduling/v1beta1" +) + +// QueueLister helps list Queues. +type QueueLister interface { + // List lists all Queues in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Queue, err error) + // Get retrieves the Queue from the index for a given name. + Get(name string) (*v1beta1.Queue, error) + QueueListerExpansion +} + +// queueLister implements the QueueLister interface. +type queueLister struct { + indexer cache.Indexer +} + +// NewQueueLister returns a new QueueLister. +func NewQueueLister(indexer cache.Indexer) QueueLister { + return &queueLister{indexer: indexer} +} + +// List lists all Queues in the indexer. +func (s *queueLister) List(selector labels.Selector) (ret []*v1beta1.Queue, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Queue)) + }) + return ret, err +} + +// Get retrieves the Queue from the index for a given name. +func (s *queueLister) Get(name string) (*v1beta1.Queue, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("queue"), name) + } + return obj.(*v1beta1.Queue), nil +} diff --git a/pkg/controllers/apis/job_info.go b/pkg/controllers/apis/job_info.go index 2affdb8f4da..88f41223af3 100644 --- a/pkg/controllers/apis/job_info.go +++ b/pkg/controllers/apis/job_info.go @@ -133,23 +133,3 @@ func (ji *JobInfo) DeletePod(pod *v1.Pod) error { return nil } - -//Request struct -type Request struct { - Namespace string - JobName string - TaskName string - - Event batch.Event - ExitCode int32 - Action batch.Action - JobVersion int32 -} - -//String function returns the request in string format -func (r Request) String() string { - return fmt.Sprintf( - "Job: %s/%s, Task:%s, Event:%s, ExitCode:%d, Action:%s, JobVersion: %d", - r.Namespace, r.JobName, r.TaskName, r.Event, r.ExitCode, r.Action, r.JobVersion) - -} diff --git a/pkg/controllers/apis/request.go b/pkg/controllers/apis/request.go new file mode 100644 index 00000000000..03e6f7bc861 --- /dev/null +++ b/pkg/controllers/apis/request.go @@ -0,0 +1,43 @@ +/* +Copyright 2019 The Volcano 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 apis + +import ( + "fmt" + + batch "volcano.sh/volcano/pkg/apis/batch/v1alpha1" +) + +//Request struct +type Request struct { + Namespace string + JobName string + TaskName string + QueueName string + + Event batch.Event + ExitCode int32 + Action batch.Action + JobVersion int32 +} + +//String function returns the request in string format +func (r Request) String() string { + return fmt.Sprintf( + "Job: %s/%s, Task:%s, Event:%s, ExitCode:%d, Action:%s, JobVersion: %d", + r.Namespace, r.JobName, r.TaskName, r.Event, r.ExitCode, r.Action, r.JobVersion) +} diff --git a/pkg/webhooks/converters/jobs/converter.go b/pkg/webhooks/converters/jobs/converter.go new file mode 100644 index 00000000000..56f9c328c97 --- /dev/null +++ b/pkg/webhooks/converters/jobs/converter.go @@ -0,0 +1,96 @@ +/* +Copyright 2019 The Volcano 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 jobs + +import ( + "fmt" + + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog" +) + +func convert(Object *unstructured.Unstructured, toVersion string) (*unstructured.Unstructured, metav1.Status) { + klog.V(3).Info("converting crd") + + convertedObject := Object.DeepCopy() + fromVersion := Object.GetAPIVersion() + + if toVersion == fromVersion { + return nil, statusErrorWithMessage("conversion from a version to itself should not call the webhook: %s", toVersion) + } + + klog.Infof("Do Job converting from <%s> to <%s>", fromVersion, toVersion) + + return convertedObject, statusSucceed() +} + +// doConversion converts the requested object given the conversion function and returns a conversion response. +// failures will be reported as Reason in the conversion response. +func doConversion(convertRequest *v1beta1.ConversionRequest) *v1beta1.ConversionResponse { + var convertedObjects []runtime.RawExtension + for _, obj := range convertRequest.Objects { + cr := unstructured.Unstructured{} + if err := cr.UnmarshalJSON(obj.Raw); err != nil { + klog.Error(err) + return conversionResponseFailureWithMessagef("failed to unmarshall object (%v) with error: %v", string(obj.Raw), err) + } + convertedCR, status := convert(&cr, convertRequest.DesiredAPIVersion) + if status.Status != metav1.StatusSuccess { + klog.Error(status.String()) + return &v1beta1.ConversionResponse{ + Result: status, + } + } + convertedCR.SetAPIVersion(convertRequest.DesiredAPIVersion) + convertedObjects = append(convertedObjects, runtime.RawExtension{Object: convertedCR}) + } + return &v1beta1.ConversionResponse{ + ConvertedObjects: convertedObjects, + Result: statusSucceed(), + } +} + +// convertFunc is the user defined function for any conversion. The code in this file is a +// template that can be use for any CR conversion given this function. +type convertFunc func(Object *unstructured.Unstructured, version string) (*unstructured.Unstructured, metav1.Status) + +// conversionResponseFailureWithMessagef is a helper function to create an AdmissionResponse +// with a formatted embedded error message. +func conversionResponseFailureWithMessagef(msg string, params ...interface{}) *v1beta1.ConversionResponse { + return &v1beta1.ConversionResponse{ + Result: metav1.Status{ + Message: fmt.Sprintf(msg, params...), + Status: metav1.StatusFailure, + }, + } +} + +func statusErrorWithMessage(msg string, params ...interface{}) metav1.Status { + return metav1.Status{ + Message: fmt.Sprintf(msg, params...), + Status: metav1.StatusFailure, + } +} + +func statusSucceed() metav1.Status { + return metav1.Status{ + Status: metav1.StatusSuccess, + } +} diff --git a/pkg/webhooks/router/admission.go b/pkg/webhooks/router/admission.go new file mode 100644 index 00000000000..995e84653b7 --- /dev/null +++ b/pkg/webhooks/router/admission.go @@ -0,0 +1,67 @@ +/* +Copyright 2019 The Volcano 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. +*/ +/* +Copyright 2019 The Volcano 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 router + +import ( + "fmt" + "net/http" + "sync" +) + +type AdmissionHandler func(w http.ResponseWriter, r *http.Request) + +var admissionMap = make(map[string]*AdmissionService) +var admissionMutex sync.Mutex + +func RegisterAdmission(service *AdmissionService) error { + admissionMutex.Lock() + defer admissionMutex.Unlock() + + if _, found := admissionMap[service.Path]; found { + return fmt.Errorf("duplicated admission service for %s", service.Path) + } + + // Also register handler to the service. + service.Handler = func(w http.ResponseWriter, r *http.Request) { + Serve(w, r, service.Func) + } + + admissionMap[service.Path] = service + + return nil +} + +func ForEachAdmission(handler func(*AdmissionService)) { + for _, f := range admissionMap { + handler(f) + } +} diff --git a/pkg/webhooks/router/converter.go b/pkg/webhooks/router/converter.go new file mode 100644 index 00000000000..e735a2054eb --- /dev/null +++ b/pkg/webhooks/router/converter.go @@ -0,0 +1,17 @@ +/* +Copyright 2019 The Volcano 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 router diff --git a/pkg/webhooks/router/factory.go b/pkg/webhooks/router/factory.go deleted file mode 100644 index 6461fefea31..00000000000 --- a/pkg/webhooks/router/factory.go +++ /dev/null @@ -1,36 +0,0 @@ -package router - -import ( - "fmt" - "net/http" - "sync" -) - -type AdmissionHandler func(w http.ResponseWriter, r *http.Request) - -var admissionMap = make(map[string]*AdmissionService) -var admissionMutex sync.Mutex - -func RegisterAdmission(service *AdmissionService) error { - admissionMutex.Lock() - defer admissionMutex.Unlock() - - if _, found := admissionMap[service.Path]; found { - return fmt.Errorf("duplicated admission service for %s", service.Path) - } - - // Also register handler to the service. - service.Handler = func(w http.ResponseWriter, r *http.Request) { - Serve(w, r, service.Func) - } - - admissionMap[service.Path] = service - - return nil -} - -func ForEachAdmission(handler func(*AdmissionService)) { - for _, f := range admissionMap { - handler(f) - } -} diff --git a/pkg/webhooks/router/interface.go b/pkg/webhooks/router/interface.go index 050ddb276b0..e3f3de8d4e2 100644 --- a/pkg/webhooks/router/interface.go +++ b/pkg/webhooks/router/interface.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Volcano 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 router import ( diff --git a/pkg/webhooks/schema/schema.go b/pkg/webhooks/schema/schema.go index 20d60005bbd..beb64a5924b 100644 --- a/pkg/webhooks/schema/schema.go +++ b/pkg/webhooks/schema/schema.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Volcano 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 schema import ( diff --git a/pkg/webhooks/util/util.go b/pkg/webhooks/util/util.go index 388039806a8..9a1ce636528 100644 --- a/pkg/webhooks/util/util.go +++ b/pkg/webhooks/util/util.go @@ -1,3 +1,19 @@ +/* +Copyright 2019 The Volcano 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 util import "k8s.io/api/admission/v1beta1"