From 457a6435ec42cb1a2b00f8f2fe1a292f31692098 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 29 Sep 2020 13:45:38 +0800 Subject: [PATCH] capacity scheduling on framework api define --- hack/update-codegen.sh | 2 +- manifests/capacityscheduling/crd.yaml | 34 ++++ .../elasticquota-example.yaml | 14 ++ .../capacityscheduling/scheduler-config.yaml | 24 +++ pkg/apis/config/register.go | 1 + pkg/apis/config/types.go | 11 +- pkg/apis/config/v1beta1/defaults.go | 8 + pkg/apis/config/v1beta1/register.go | 1 + pkg/apis/config/v1beta1/types.go | 12 +- .../config/v1beta1/zz_generated.conversion.go | 30 +++ .../config/v1beta1/zz_generated.deepcopy.go | 30 +++ .../config/v1beta1/zz_generated.defaults.go | 5 + pkg/apis/config/zz_generated.deepcopy.go | 30 +++ .../v1alpha1/zz_generated.defaults.go | 33 ---- pkg/apis/{podgroup => scheduling}/register.go | 2 +- .../{podgroup => scheduling}/v1alpha1/doc.go | 2 +- .../v1alpha1/register.go | 6 +- .../v1alpha1/types.go | 54 ++++++ .../v1alpha1/zz_generated.deepcopy.go | 114 +++++++++++ pkg/controller/podgroup.go | 38 ++-- pkg/controller/podgroup_test.go | 8 +- .../clientset/versioned/clientset.go | 2 +- .../versioned/fake/clientset_generated.go | 4 +- .../clientset/versioned/fake/register.go | 2 +- .../clientset/versioned/scheme/register.go | 2 +- .../{podgroup => scheduling}/v1alpha1/doc.go | 0 .../typed/scheduling/v1alpha1/elasticquota.go | 178 ++++++++++++++++++ .../v1alpha1/fake/doc.go | 0 .../v1alpha1/fake/fake_elasticquota.go | 130 +++++++++++++ .../v1alpha1/fake/fake_podgroup.go | 2 +- .../v1alpha1/fake/fake_scheduling_client.go} | 6 +- .../v1alpha1/generated_expansion.go | 2 + .../v1alpha1/podgroup.go | 2 +- .../v1alpha1/scheduling_client.go} | 7 +- .../informers/externalversions/factory.go | 8 +- .../informers/externalversions/generic.go | 4 +- .../{podgroup => scheduling}/interface.go | 4 +- .../scheduling/v1alpha1/elasticquota.go | 90 +++++++++ .../v1alpha1/interface.go | 7 + .../v1alpha1/podgroup.go | 8 +- .../scheduling/v1alpha1/elasticquota.go | 99 ++++++++++ .../v1alpha1/expansion_generated.go | 8 + .../v1alpha1/podgroup.go | 2 +- pkg/util/podgroup.go | 2 +- 44 files changed, 943 insertions(+), 85 deletions(-) create mode 100644 manifests/capacityscheduling/crd.yaml create mode 100644 manifests/capacityscheduling/elasticquota-example.yaml create mode 100644 manifests/capacityscheduling/scheduler-config.yaml delete mode 100644 pkg/apis/podgroup/v1alpha1/zz_generated.defaults.go rename pkg/apis/{podgroup => scheduling}/register.go (97%) rename pkg/apis/{podgroup => scheduling}/v1alpha1/doc.go (88%) rename pkg/apis/{podgroup => scheduling}/v1alpha1/register.go (89%) rename pkg/apis/{podgroup => scheduling}/v1alpha1/types.go (69%) rename pkg/apis/{podgroup => scheduling}/v1alpha1/zz_generated.deepcopy.go (54%) rename pkg/generated/clientset/versioned/typed/{podgroup => scheduling}/v1alpha1/doc.go (100%) create mode 100644 pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/elasticquota.go rename pkg/generated/clientset/versioned/typed/{podgroup => scheduling}/v1alpha1/fake/doc.go (100%) create mode 100644 pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_elasticquota.go rename pkg/generated/clientset/versioned/typed/{podgroup => scheduling}/v1alpha1/fake/fake_podgroup.go (98%) rename pkg/generated/clientset/versioned/typed/{podgroup/v1alpha1/fake/fake_podgroup_client.go => scheduling/v1alpha1/fake/fake_scheduling_client.go} (86%) rename pkg/generated/clientset/versioned/typed/{podgroup => scheduling}/v1alpha1/generated_expansion.go (94%) rename pkg/generated/clientset/versioned/typed/{podgroup => scheduling}/v1alpha1/podgroup.go (98%) rename pkg/generated/clientset/versioned/typed/{podgroup/v1alpha1/podgroup_client.go => scheduling/v1alpha1/scheduling_client.go} (91%) rename pkg/generated/informers/externalversions/{podgroup => scheduling}/interface.go (96%) create mode 100644 pkg/generated/informers/externalversions/scheduling/v1alpha1/elasticquota.go rename pkg/generated/informers/externalversions/{podgroup => scheduling}/v1alpha1/interface.go (83%) rename pkg/generated/informers/externalversions/{podgroup => scheduling}/v1alpha1/podgroup.go (92%) create mode 100644 pkg/generated/listers/scheduling/v1alpha1/elasticquota.go rename pkg/generated/listers/{podgroup => scheduling}/v1alpha1/expansion_generated.go (75%) rename pkg/generated/listers/{podgroup => scheduling}/v1alpha1/podgroup.go (97%) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 22fd299d03..c03f15faf1 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -33,5 +33,5 @@ bash "${CODEGEN_PKG}"/generate-groups.sh \ all \ sigs.k8s.io/scheduler-plugins/pkg/generated \ sigs.k8s.io/scheduler-plugins/pkg/apis \ - podgroup:v1alpha1 \ + "scheduling:v1alpha1" \ --go-header-file "${SCRIPT_ROOT}"/hack/boilerplate/boilerplate.generatego.txt diff --git a/manifests/capacityscheduling/crd.yaml b/manifests/capacityscheduling/crd.yaml new file mode 100644 index 0000000000..1e18af3f6a --- /dev/null +++ b/manifests/capacityscheduling/crd.yaml @@ -0,0 +1,34 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: elasticquotas.scheduling.sigs.k8s.io +spec: + group: scheduling.sigs.k8s.io + versions: + - name: v1alpha1 + served: true + storage: true + scope: Namespaced + names: + plural: elasticquotas + singular: elasticquota + kind: ElasticQuota + shortNames: + - eq + - eqs + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + min: + type: object + max: + type: object + status: + type: object + properties: + used: + type: object \ No newline at end of file diff --git a/manifests/capacityscheduling/elasticquota-example.yaml b/manifests/capacityscheduling/elasticquota-example.yaml new file mode 100644 index 0000000000..b0cfb9f3f0 --- /dev/null +++ b/manifests/capacityscheduling/elasticquota-example.yaml @@ -0,0 +1,14 @@ +apiVersion: scheduling.sigs.k8s.io/v1alpha1 +kind: ElasticQuota +metadata: + name: test + namespace: test +spec: + max: + cpu: 20 + memory: 40Gi + nvidia.com/gpu: 2 + min: + cpu: 10 + memory: 20Gi + nvidia.com/gpu: 1 \ No newline at end of file diff --git a/manifests/capacityscheduling/scheduler-config.yaml b/manifests/capacityscheduling/scheduler-config.yaml new file mode 100644 index 0000000000..00afe46e19 --- /dev/null +++ b/manifests/capacityscheduling/scheduler-config.yaml @@ -0,0 +1,24 @@ +apiVersion: kubescheduler.config.k8s.io/v1beta1 +kind: KubeSchedulerConfiguration +leaderElection: + leaderElect: false +clientConnection: + kubeconfig: "REPLACE_ME_WITH_KUBE_CONFIG_PATH" +profiles: +- schedulerName: default-scheduler + plugins: + preFilter: + enabled: + - name: CapacityScheduling + postFilter: + enabled: + - name: CapacityScheduling + disabled: + - name: "*" + reserve: + enabled: + - name: CapacityScheduling + pluginConfig: + - name: CapacityScheduling + args: + kubeConfigPath: "REPLACE_ME_WITH_KUBE_CONFIG_PATH" \ No newline at end of file diff --git a/pkg/apis/config/register.go b/pkg/apis/config/register.go index 517eed06db..ad437b7ce7 100644 --- a/pkg/apis/config/register.go +++ b/pkg/apis/config/register.go @@ -39,6 +39,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &CoschedulingArgs{}, &NodeResourcesAllocatableArgs{}, + &CapacitySchedulingArgs{}, ) return nil } diff --git a/pkg/apis/config/types.go b/pkg/apis/config/types.go index 2eed927fd2..1b8734dd64 100644 --- a/pkg/apis/config/types.go +++ b/pkg/apis/config/types.go @@ -51,7 +51,7 @@ type NodeResourcesAllocatableArgs struct { // Resources to be considered when scoring. // Allowed weights start from 1. - // An example resource set might includes "cpu" (millicores) and "memory" (bytes) + // An example resource set might include "cpu" (millicores) and "memory" (bytes) // with weights of 1<<20 and 1 respectfully. That would mean 1 MiB has equivalent // weight as 1 millicore. Resources []schedulerconfig.ResourceSpec `json:"resources,omitempty"` @@ -59,3 +59,12 @@ type NodeResourcesAllocatableArgs struct { // Whether to prioritize nodes with least or most allocatable resources. Mode *ModeType `json:"mode,omitempty"` } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type CapacitySchedulingArgs struct { + metav1.TypeMeta + + // KubeConfigPath is the path of kubeconfig. + KubeConfigPath *string +} diff --git a/pkg/apis/config/v1beta1/defaults.go b/pkg/apis/config/v1beta1/defaults.go index 2cec0f598b..57d8819515 100644 --- a/pkg/apis/config/v1beta1/defaults.go +++ b/pkg/apis/config/v1beta1/defaults.go @@ -35,6 +35,8 @@ var ( defaultNodeResourcesAllocatableResourcesToWeightMap = []schedulerconfig.ResourceSpec{ {Name: "cpu", Weight: 1 << 20}, {Name: "memory", Weight: 1}, } + + defaultKubeConfigPath string = "/etc/kubernetes/scheduler.conf" ) func SetDefaults_CoschedulingArgs(obj *CoschedulingArgs) { @@ -58,3 +60,9 @@ func SetDefaults_NodeResourcesAllocatableArgs(obj *NodeResourcesAllocatableArgs) obj.Mode = &defaultNodeResourcesAllocatableMode } } + +func SetDefaults_CapacitySchedulingArgs(obj *CapacitySchedulingArgs) { + if obj.KubeConfigPath == nil { + obj.KubeConfigPath = &defaultKubeConfigPath + } +} diff --git a/pkg/apis/config/v1beta1/register.go b/pkg/apis/config/v1beta1/register.go index 293ee02929..41a2610248 100644 --- a/pkg/apis/config/v1beta1/register.go +++ b/pkg/apis/config/v1beta1/register.go @@ -39,6 +39,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &CoschedulingArgs{}, &NodeResourcesAllocatableArgs{}, + &CapacitySchedulingArgs{}, ) return nil } diff --git a/pkg/apis/config/v1beta1/types.go b/pkg/apis/config/v1beta1/types.go index 33a3a8aed7..5e9e91d91b 100644 --- a/pkg/apis/config/v1beta1/types.go +++ b/pkg/apis/config/v1beta1/types.go @@ -52,7 +52,7 @@ type NodeResourcesAllocatableArgs struct { // Resources to be considered when scoring. // Allowed weights start from 1. - // An example resource set might includes "cpu" (millicores) and "memory" (bytes) + // An example resource set might include "cpu" (millicores) and "memory" (bytes) // with weights of 1<<20 and 1 respectfully. That would mean 1 MiB has equivalent // weight as 1 millicore. Resources []schedulerconfig.ResourceSpec `json:"resources,omitempty"` @@ -60,3 +60,13 @@ type NodeResourcesAllocatableArgs struct { // Whether to prioritize nodes with least or most allocatable resources. Mode *ModeType `json:"mode,omitempty"` } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CapacitySchedulingArgs defines the scheduling parameters for CapacityScheduling plugin. +type CapacitySchedulingArgs struct { + metav1.TypeMeta `json:",inline"` + + // KubeConfigPath is the path of kubeconfig. + KubeConfigPath *string `json:"kubeconfigpath,omitempty"` +} diff --git a/pkg/apis/config/v1beta1/zz_generated.conversion.go b/pkg/apis/config/v1beta1/zz_generated.conversion.go index 525cf833f2..59d7589577 100644 --- a/pkg/apis/config/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/config/v1beta1/zz_generated.conversion.go @@ -36,6 +36,16 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*CapacitySchedulingArgs)(nil), (*config.CapacitySchedulingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CapacitySchedulingArgs_To_config_CapacitySchedulingArgs(a.(*CapacitySchedulingArgs), b.(*config.CapacitySchedulingArgs), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.CapacitySchedulingArgs)(nil), (*CapacitySchedulingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_CapacitySchedulingArgs_To_v1beta1_CapacitySchedulingArgs(a.(*config.CapacitySchedulingArgs), b.(*CapacitySchedulingArgs), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*CoschedulingArgs)(nil), (*config.CoschedulingArgs)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_CoschedulingArgs_To_config_CoschedulingArgs(a.(*CoschedulingArgs), b.(*config.CoschedulingArgs), scope) }); err != nil { @@ -59,6 +69,26 @@ func RegisterConversions(s *runtime.Scheme) error { return nil } +func autoConvert_v1beta1_CapacitySchedulingArgs_To_config_CapacitySchedulingArgs(in *CapacitySchedulingArgs, out *config.CapacitySchedulingArgs, s conversion.Scope) error { + out.KubeConfigPath = (*string)(unsafe.Pointer(in.KubeConfigPath)) + return nil +} + +// Convert_v1beta1_CapacitySchedulingArgs_To_config_CapacitySchedulingArgs is an autogenerated conversion function. +func Convert_v1beta1_CapacitySchedulingArgs_To_config_CapacitySchedulingArgs(in *CapacitySchedulingArgs, out *config.CapacitySchedulingArgs, s conversion.Scope) error { + return autoConvert_v1beta1_CapacitySchedulingArgs_To_config_CapacitySchedulingArgs(in, out, s) +} + +func autoConvert_config_CapacitySchedulingArgs_To_v1beta1_CapacitySchedulingArgs(in *config.CapacitySchedulingArgs, out *CapacitySchedulingArgs, s conversion.Scope) error { + out.KubeConfigPath = (*string)(unsafe.Pointer(in.KubeConfigPath)) + return nil +} + +// Convert_config_CapacitySchedulingArgs_To_v1beta1_CapacitySchedulingArgs is an autogenerated conversion function. +func Convert_config_CapacitySchedulingArgs_To_v1beta1_CapacitySchedulingArgs(in *config.CapacitySchedulingArgs, out *CapacitySchedulingArgs, s conversion.Scope) error { + return autoConvert_config_CapacitySchedulingArgs_To_v1beta1_CapacitySchedulingArgs(in, out, s) +} + func autoConvert_v1beta1_CoschedulingArgs_To_config_CoschedulingArgs(in *CoschedulingArgs, out *config.CoschedulingArgs, s conversion.Scope) error { out.PermitWaitingTimeSeconds = (*int64)(unsafe.Pointer(in.PermitWaitingTimeSeconds)) out.PodGroupGCIntervalSeconds = (*int64)(unsafe.Pointer(in.PodGroupGCIntervalSeconds)) diff --git a/pkg/apis/config/v1beta1/zz_generated.deepcopy.go b/pkg/apis/config/v1beta1/zz_generated.deepcopy.go index b5b4340235..f850722ad6 100644 --- a/pkg/apis/config/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1beta1/zz_generated.deepcopy.go @@ -25,6 +25,36 @@ import ( v1 "k8s.io/kube-scheduler/config/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapacitySchedulingArgs) DeepCopyInto(out *CapacitySchedulingArgs) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.KubeConfigPath != nil { + in, out := &in.KubeConfigPath, &out.KubeConfigPath + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacitySchedulingArgs. +func (in *CapacitySchedulingArgs) DeepCopy() *CapacitySchedulingArgs { + if in == nil { + return nil + } + out := new(CapacitySchedulingArgs) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CapacitySchedulingArgs) 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 *CoschedulingArgs) DeepCopyInto(out *CoschedulingArgs) { *out = *in diff --git a/pkg/apis/config/v1beta1/zz_generated.defaults.go b/pkg/apis/config/v1beta1/zz_generated.defaults.go index f4ac4ba083..5988443fd4 100644 --- a/pkg/apis/config/v1beta1/zz_generated.defaults.go +++ b/pkg/apis/config/v1beta1/zz_generated.defaults.go @@ -28,6 +28,7 @@ import ( // Public to allow building arbitrary schemes. // All generated defaulters are covering - they call all nested defaulters. func RegisterDefaults(scheme *runtime.Scheme) error { + scheme.AddTypeDefaultingFunc(&CapacitySchedulingArgs{}, func(obj interface{}) { SetObjectDefaults_CapacitySchedulingArgs(obj.(*CapacitySchedulingArgs)) }) scheme.AddTypeDefaultingFunc(&CoschedulingArgs{}, func(obj interface{}) { SetObjectDefaults_CoschedulingArgs(obj.(*CoschedulingArgs)) }) scheme.AddTypeDefaultingFunc(&NodeResourcesAllocatableArgs{}, func(obj interface{}) { SetObjectDefaults_NodeResourcesAllocatableArgs(obj.(*NodeResourcesAllocatableArgs)) @@ -35,6 +36,10 @@ func RegisterDefaults(scheme *runtime.Scheme) error { return nil } +func SetObjectDefaults_CapacitySchedulingArgs(in *CapacitySchedulingArgs) { + SetDefaults_CapacitySchedulingArgs(in) +} + func SetObjectDefaults_CoschedulingArgs(in *CoschedulingArgs) { SetDefaults_CoschedulingArgs(in) } diff --git a/pkg/apis/config/zz_generated.deepcopy.go b/pkg/apis/config/zz_generated.deepcopy.go index dee02e9aa1..077a97a314 100644 --- a/pkg/apis/config/zz_generated.deepcopy.go +++ b/pkg/apis/config/zz_generated.deepcopy.go @@ -25,6 +25,36 @@ import ( v1 "k8s.io/kube-scheduler/config/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapacitySchedulingArgs) DeepCopyInto(out *CapacitySchedulingArgs) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.KubeConfigPath != nil { + in, out := &in.KubeConfigPath, &out.KubeConfigPath + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapacitySchedulingArgs. +func (in *CapacitySchedulingArgs) DeepCopy() *CapacitySchedulingArgs { + if in == nil { + return nil + } + out := new(CapacitySchedulingArgs) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CapacitySchedulingArgs) 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 *CoschedulingArgs) DeepCopyInto(out *CoschedulingArgs) { *out = *in diff --git a/pkg/apis/podgroup/v1alpha1/zz_generated.defaults.go b/pkg/apis/podgroup/v1alpha1/zz_generated.defaults.go deleted file mode 100644 index aed374dab6..0000000000 --- a/pkg/apis/podgroup/v1alpha1/zz_generated.defaults.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by defaulter-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// RegisterDefaults adds defaulters functions to the given scheme. -// Public to allow building arbitrary schemes. -// All generated defaulters are covering - they call all nested defaulters. -func RegisterDefaults(scheme *runtime.Scheme) error { - // TODO: add default value for some fields. - return nil -} diff --git a/pkg/apis/podgroup/register.go b/pkg/apis/scheduling/register.go similarity index 97% rename from pkg/apis/podgroup/register.go rename to pkg/apis/scheduling/register.go index d802416592..372c894d0c 100644 --- a/pkg/apis/podgroup/register.go +++ b/pkg/apis/scheduling/register.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package podgroup +package scheduling // GroupName is the group name used in this package const ( diff --git a/pkg/apis/podgroup/v1alpha1/doc.go b/pkg/apis/scheduling/v1alpha1/doc.go similarity index 88% rename from pkg/apis/podgroup/v1alpha1/doc.go rename to pkg/apis/scheduling/v1alpha1/doc.go index 8f099f2cbd..45b993f4d0 100644 --- a/pkg/apis/podgroup/v1alpha1/doc.go +++ b/pkg/apis/scheduling/v1alpha1/doc.go @@ -18,4 +18,4 @@ limitations under the License. // +groupName=scheduling.sigs.k8s.io // Package v1alpha1 is the v1alpha1 version of the API. -package v1alpha1 // import "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" +package v1alpha1 diff --git a/pkg/apis/podgroup/v1alpha1/register.go b/pkg/apis/scheduling/v1alpha1/register.go similarity index 89% rename from pkg/apis/podgroup/v1alpha1/register.go rename to pkg/apis/scheduling/v1alpha1/register.go index eddfe78f1b..a42b8cf92c 100644 --- a/pkg/apis/podgroup/v1alpha1/register.go +++ b/pkg/apis/scheduling/v1alpha1/register.go @@ -21,11 +21,11 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling" ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: podgroup.GroupName, Version: "v1alpha1"} +var SchemeGroupVersion = schema.GroupVersion{Group: scheduling.GroupName, Version: "v1alpha1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { @@ -47,6 +47,8 @@ var ( // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, + &ElasticQuota{}, + &ElasticQuotaList{}, &PodGroup{}, &PodGroupList{}, ) diff --git a/pkg/apis/podgroup/v1alpha1/types.go b/pkg/apis/scheduling/v1alpha1/types.go similarity index 69% rename from pkg/apis/podgroup/v1alpha1/types.go rename to pkg/apis/scheduling/v1alpha1/types.go index 76fa1a4968..4a0c77ca47 100644 --- a/pkg/apis/podgroup/v1alpha1/types.go +++ b/pkg/apis/scheduling/v1alpha1/types.go @@ -21,6 +21,60 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ElasticQuota sets elastic quota restrictions per namespace +type ElasticQuota struct { + metav1.TypeMeta `json:",inline"` + + // Standard object's metadata. + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // ElasticQuotaSpec defines the Min and Max for Quota. + // +optional + Spec ElasticQuotaSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` + + // ElasticQuotaStatus defines the observed use. + // +optional + Status ElasticQuotaStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// ElasticQuotaSpec defines the Min and Max for Quota. +type ElasticQuotaSpec struct { + // Min is the set of desired guaranteed limits for each named resource. + // +optional + Min v1.ResourceList `json:"min,omitempty" protobuf:"bytes,1,rep,name=min, casttype=ResourceList,castkey=ResourceName"` + + // Max is the set of desired max limits for each named resource. The usage of max is based on the resource configurations of + // successfully scheduled pods. + // +optional + Max v1.ResourceList `json:"max,omitempty" protobuf:"bytes,2,rep,name=max, casttype=ResourceList,castkey=ResourceName"` +} + +// ElasticQuotaStatus defines the observed use. +type ElasticQuotaStatus struct { + // Used is the current observed total usage of the resource in the namespace. + // +optional + Used v1.ResourceList `json:"used,omitempty" protobuf:"bytes,1,rep,name=used,casttype=ResourceList,castkey=ResourceName"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ElasticQuotaList is a list of ElasticQuota items. +type ElasticQuotaList struct { + metav1.TypeMeta `json:",inline"` + + // Standard list metadata. + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Items is a list of ElasticQuota objects. + Items []ElasticQuota `json:"items" protobuf:"bytes,2,rep,name=items"` +} + // PodGroupPhase is the phase of a pod group at the current time. type PodGroupPhase string diff --git a/pkg/apis/podgroup/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go similarity index 54% rename from pkg/apis/podgroup/v1alpha1/zz_generated.deepcopy.go rename to pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go index e535d966c3..28fd843a32 100644 --- a/pkg/apis/podgroup/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/scheduling/v1alpha1/zz_generated.deepcopy.go @@ -26,6 +26,120 @@ import ( 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 *ElasticQuota) DeepCopyInto(out *ElasticQuota) { + *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 ElasticQuota. +func (in *ElasticQuota) DeepCopy() *ElasticQuota { + if in == nil { + return nil + } + out := new(ElasticQuota) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ElasticQuota) 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 *ElasticQuotaList) DeepCopyInto(out *ElasticQuotaList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ElasticQuota, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElasticQuotaList. +func (in *ElasticQuotaList) DeepCopy() *ElasticQuotaList { + if in == nil { + return nil + } + out := new(ElasticQuotaList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ElasticQuotaList) 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 *ElasticQuotaSpec) DeepCopyInto(out *ElasticQuotaSpec) { + *out = *in + if in.Min != nil { + in, out := &in.Min, &out.Min + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Max != nil { + in, out := &in.Max, &out.Max + *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 ElasticQuotaSpec. +func (in *ElasticQuotaSpec) DeepCopy() *ElasticQuotaSpec { + if in == nil { + return nil + } + out := new(ElasticQuotaSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ElasticQuotaStatus) DeepCopyInto(out *ElasticQuotaStatus) { + *out = *in + if in.Used != nil { + in, out := &in.Used, &out.Used + *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 ElasticQuotaStatus. +func (in *ElasticQuotaStatus) DeepCopy() *ElasticQuotaStatus { + if in == nil { + return nil + } + out := new(ElasticQuotaStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodGroup) DeepCopyInto(out *PodGroup) { *out = *in diff --git a/pkg/controller/podgroup.go b/pkg/controller/podgroup.go index 89edc9d69b..a65be61991 100644 --- a/pkg/controller/podgroup.go +++ b/pkg/controller/podgroup.go @@ -38,10 +38,10 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - pgv1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" - pgclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" - pginformer "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/podgroup/v1alpha1" - pglister "sigs.k8s.io/scheduler-plugins/pkg/generated/listers/podgroup/v1alpha1" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" + schedulingclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" + schedulinginformer "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/scheduling/v1alpha1" + schedulinglister "sigs.k8s.io/scheduler-plugins/pkg/generated/listers/scheduling/v1alpha1" "sigs.k8s.io/scheduler-plugins/pkg/util" ) @@ -49,18 +49,18 @@ import ( type PodGroupController struct { eventRecorder record.EventRecorder pgQueue workqueue.RateLimitingInterface - pgLister pglister.PodGroupLister + pgLister schedulinglister.PodGroupLister podLister corelister.PodLister pgListerSynced cache.InformerSynced podListerSynced cache.InformerSynced - pgClient pgclientset.Interface + pgClient schedulingclientset.Interface } // NewPodGroupController returns a new *PodGroupController func NewPodGroupController(client kubernetes.Interface, - pgInformer pginformer.PodGroupInformer, + pgInformer schedulinginformer.PodGroupInformer, podInformer coreinformer.PodInformer, - pgClient pgclientset.Interface) *PodGroupController { + pgClient schedulingclientset.Interface) *PodGroupController { broadcaster := record.NewBroadcaster() broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: client.CoreV1().Events(v1.NamespaceAll)}) @@ -112,8 +112,8 @@ func (ctrl *PodGroupController) pgAdded(obj interface{}) { runtime.HandleError(err) return } - pg := obj.(*pgv1.PodGroup) - if pg.Status.Phase == pgv1.PodGroupFinished || pg.Status.Phase == pgv1.PodGroupFailed { + pg := obj.(*schedulingv1alpha1.PodGroup) + if pg.Status.Phase == schedulingv1alpha1.PodGroupFinished || pg.Status.Phase == schedulingv1alpha1.PodGroupFailed { return } // If startScheduleTime - createTime > 2days, do not enqueue again because pod may have been GCed @@ -183,7 +183,7 @@ func (ctrl *PodGroupController) sync() { } // syncHandle syncs pod group and convert status -func (ctrl *PodGroupController) syncHandler(ctx context.Context, pg *pgv1.PodGroup) { +func (ctrl *PodGroupController) syncHandler(ctx context.Context, pg *schedulingv1alpha1.PodGroup) { key, err := cache.MetaNamespaceKeyFunc(pg) if err != nil { runtime.HandleError(err) @@ -199,7 +199,7 @@ func (ctrl *PodGroupController) syncHandler(ctx context.Context, pg *pgv1.PodGro pgCopy := pg.DeepCopy() if string(pgCopy.Status.Phase) == "" { - pgCopy.Status.Phase = pgv1.PodGroupPending + pgCopy.Status.Phase = schedulingv1alpha1.PodGroupPending } selector := labels.Set(map[string]string{util.PodGroupLabel: pgCopy.Name}).AsSelector() @@ -229,20 +229,20 @@ func (ctrl *PodGroupController) syncHandler(ctx context.Context, pg *pgv1.PodGro pgCopy.Status.Succeeded = succeeded pgCopy.Status.Running = running - if pgCopy.Status.Scheduled >= pgCopy.Spec.MinMember && pgCopy.Status.Phase == pgv1.PodGroupScheduling { - pgCopy.Status.Phase = pgv1.PodGroupScheduled + if pgCopy.Status.Scheduled >= pgCopy.Spec.MinMember && pgCopy.Status.Phase == schedulingv1alpha1.PodGroupScheduling { + pgCopy.Status.Phase = schedulingv1alpha1.PodGroupScheduled } - if pgCopy.Status.Succeeded+pgCopy.Status.Running >= pg.Spec.MinMember && pgCopy.Status.Phase == pgv1.PodGroupScheduled { - pgCopy.Status.Phase = pgv1.PodGroupRunning + if pgCopy.Status.Succeeded+pgCopy.Status.Running >= pg.Spec.MinMember && pgCopy.Status.Phase == schedulingv1alpha1.PodGroupScheduled { + pgCopy.Status.Phase = schedulingv1alpha1.PodGroupRunning } // Final state of pod group if pgCopy.Status.Failed != 0 && pgCopy.Status.Failed+pgCopy.Status.Running+pgCopy.Status.Succeeded >= pg.Spec. MinMember { - pgCopy.Status.Phase = pgv1.PodGroupFailed + pgCopy.Status.Phase = schedulingv1alpha1.PodGroupFailed } if pgCopy.Status.Succeeded >= pg.Spec.MinMember { - pgCopy.Status.Phase = pgv1.PodGroupFinished + pgCopy.Status.Phase = schedulingv1alpha1.PodGroupFinished } err = ctrl.patchPodGroup(pg, pgCopy) @@ -251,7 +251,7 @@ func (ctrl *PodGroupController) syncHandler(ctx context.Context, pg *pgv1.PodGro } } -func (ctrl *PodGroupController) patchPodGroup(old, new *pgv1.PodGroup) error { +func (ctrl *PodGroupController) patchPodGroup(old, new *schedulingv1alpha1.PodGroup) error { if !reflect.DeepEqual(old, new) { patch, err := util.CreateMergePatch(old, new) if err != nil { diff --git a/pkg/controller/podgroup_test.go b/pkg/controller/podgroup_test.go index f2af4b5edc..7f03fd8241 100644 --- a/pkg/controller/podgroup_test.go +++ b/pkg/controller/podgroup_test.go @@ -3,20 +3,20 @@ package controller import ( "context" "fmt" - "k8s.io/apimachinery/pkg/util/wait" "testing" "time" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" "k8s.io/kubernetes/pkg/controller" st "k8s.io/kubernetes/pkg/scheduler/testing" - "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" pgfake "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/fake" - pgformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" + schedulinginformer "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" "sigs.k8s.io/scheduler-plugins/pkg/util" ) @@ -118,7 +118,7 @@ func Test_Run(t *testing.T) { pgClient := pgfake.NewSimpleClientset(pg) informerFactory := informers.NewSharedInformerFactory(kubeClient, controller.NoResyncPeriodFunc()) - pgInformerFactory := pgformers.NewSharedInformerFactory(pgClient, controller.NoResyncPeriodFunc()) + pgInformerFactory := schedulinginformer.NewSharedInformerFactory(pgClient, controller.NoResyncPeriodFunc()) podInformer := informerFactory.Core().V1().Pods() pgInformer := pgInformerFactory.Scheduling().V1alpha1().PodGroups() ctrl := NewPodGroupController(kubeClient, pgInformer, podInformer, pgClient) diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 46fa0236f2..eef8f344cd 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -24,7 +24,7 @@ import ( discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" - schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1" ) type Interface interface { diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 1d2f38eff1..3fbe18e59e 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -25,8 +25,8 @@ import ( fakediscovery "k8s.io/client-go/discovery/fake" "k8s.io/client-go/testing" clientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" - schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1" - fakeschedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1" + fakeschedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 4a16f96f02..8212e2cd4f 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -24,7 +24,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" - schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) var scheme = runtime.NewScheme() diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index f8286385fd..086774b2e1 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -24,7 +24,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" - schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) var Scheme = runtime.NewScheme() diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/doc.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/doc.go diff --git a/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/elasticquota.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/elasticquota.go new file mode 100644 index 0000000000..d6aba49914 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/elasticquota.go @@ -0,0 +1,178 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "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" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" + scheme "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/scheme" +) + +// ElasticQuotasGetter has a method to return a ElasticQuotaInterface. +// A group's client should implement this interface. +type ElasticQuotasGetter interface { + ElasticQuotas(namespace string) ElasticQuotaInterface +} + +// ElasticQuotaInterface has methods to work with ElasticQuota resources. +type ElasticQuotaInterface interface { + Create(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.CreateOptions) (*v1alpha1.ElasticQuota, error) + Update(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.UpdateOptions) (*v1alpha1.ElasticQuota, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ElasticQuota, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ElasticQuotaList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ElasticQuota, err error) + ElasticQuotaExpansion +} + +// elasticQuotas implements ElasticQuotaInterface +type elasticQuotas struct { + client rest.Interface + ns string +} + +// newElasticQuotas returns a ElasticQuotas +func newElasticQuotas(c *SchedulingV1alpha1Client, namespace string) *elasticQuotas { + return &elasticQuotas{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the elasticQuota, and returns the corresponding elasticQuota object, and an error if there is any. +func (c *elasticQuotas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ElasticQuota, err error) { + result = &v1alpha1.ElasticQuota{} + err = c.client.Get(). + Namespace(c.ns). + Resource("elasticquotas"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ElasticQuotas that match those selectors. +func (c *elasticQuotas) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ElasticQuotaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ElasticQuotaList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("elasticquotas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested elasticQuotas. +func (c *elasticQuotas) Watch(ctx context.Context, 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("elasticquotas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a elasticQuota and creates it. Returns the server's representation of the elasticQuota, and an error, if there is any. +func (c *elasticQuotas) Create(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.CreateOptions) (result *v1alpha1.ElasticQuota, err error) { + result = &v1alpha1.ElasticQuota{} + err = c.client.Post(). + Namespace(c.ns). + Resource("elasticquotas"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(elasticQuota). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a elasticQuota and updates it. Returns the server's representation of the elasticQuota, and an error, if there is any. +func (c *elasticQuotas) Update(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.UpdateOptions) (result *v1alpha1.ElasticQuota, err error) { + result = &v1alpha1.ElasticQuota{} + err = c.client.Put(). + Namespace(c.ns). + Resource("elasticquotas"). + Name(elasticQuota.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(elasticQuota). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the elasticQuota and deletes it. Returns an error if one occurs. +func (c *elasticQuotas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("elasticquotas"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *elasticQuotas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("elasticquotas"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched elasticQuota. +func (c *elasticQuotas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ElasticQuota, err error) { + result = &v1alpha1.ElasticQuota{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("elasticquotas"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/doc.go diff --git a/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_elasticquota.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_elasticquota.go new file mode 100644 index 0000000000..8f653b1719 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_elasticquota.go @@ -0,0 +1,130 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + 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" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" +) + +// FakeElasticQuotas implements ElasticQuotaInterface +type FakeElasticQuotas struct { + Fake *FakeSchedulingV1alpha1 + ns string +} + +var elasticquotasResource = schema.GroupVersionResource{Group: "scheduling.sigs.k8s.io", Version: "v1alpha1", Resource: "elasticquotas"} + +var elasticquotasKind = schema.GroupVersionKind{Group: "scheduling.sigs.k8s.io", Version: "v1alpha1", Kind: "ElasticQuota"} + +// Get takes name of the elasticQuota, and returns the corresponding elasticQuota object, and an error if there is any. +func (c *FakeElasticQuotas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ElasticQuota, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(elasticquotasResource, c.ns, name), &v1alpha1.ElasticQuota{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ElasticQuota), err +} + +// List takes label and field selectors, and returns the list of ElasticQuotas that match those selectors. +func (c *FakeElasticQuotas) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ElasticQuotaList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(elasticquotasResource, elasticquotasKind, c.ns, opts), &v1alpha1.ElasticQuotaList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ElasticQuotaList{ListMeta: obj.(*v1alpha1.ElasticQuotaList).ListMeta} + for _, item := range obj.(*v1alpha1.ElasticQuotaList).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 elasticQuotas. +func (c *FakeElasticQuotas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(elasticquotasResource, c.ns, opts)) + +} + +// Create takes the representation of a elasticQuota and creates it. Returns the server's representation of the elasticQuota, and an error, if there is any. +func (c *FakeElasticQuotas) Create(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.CreateOptions) (result *v1alpha1.ElasticQuota, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(elasticquotasResource, c.ns, elasticQuota), &v1alpha1.ElasticQuota{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ElasticQuota), err +} + +// Update takes the representation of a elasticQuota and updates it. Returns the server's representation of the elasticQuota, and an error, if there is any. +func (c *FakeElasticQuotas) Update(ctx context.Context, elasticQuota *v1alpha1.ElasticQuota, opts v1.UpdateOptions) (result *v1alpha1.ElasticQuota, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(elasticquotasResource, c.ns, elasticQuota), &v1alpha1.ElasticQuota{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ElasticQuota), err +} + +// Delete takes name of the elasticQuota and deletes it. Returns an error if one occurs. +func (c *FakeElasticQuotas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(elasticquotasResource, c.ns, name), &v1alpha1.ElasticQuota{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeElasticQuotas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(elasticquotasResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ElasticQuotaList{}) + return err +} + +// Patch applies the patch and returns the patched elasticQuota. +func (c *FakeElasticQuotas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ElasticQuota, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(elasticquotasResource, c.ns, name, pt, data, subresources...), &v1alpha1.ElasticQuota{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ElasticQuota), err +} diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_podgroup.go similarity index 98% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_podgroup.go index c59419d5e8..50efebddfb 100644 --- a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup.go +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_podgroup.go @@ -27,7 +27,7 @@ import ( types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) // FakePodGroups implements PodGroupInterface diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup_client.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_scheduling_client.go similarity index 86% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup_client.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_scheduling_client.go index 1bf14cf3ae..aa6384adad 100644 --- a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/fake/fake_podgroup_client.go +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_scheduling_client.go @@ -21,13 +21,17 @@ package fake import ( rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1" ) type FakeSchedulingV1alpha1 struct { *testing.Fake } +func (c *FakeSchedulingV1alpha1) ElasticQuotas(namespace string) v1alpha1.ElasticQuotaInterface { + return &FakeElasticQuotas{c, namespace} +} + func (c *FakeSchedulingV1alpha1) PodGroups(namespace string) v1alpha1.PodGroupInterface { return &FakePodGroups{c, namespace} } diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go similarity index 94% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go index 999084df86..925df95f98 100644 --- a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/generated_expansion.go @@ -18,4 +18,6 @@ limitations under the License. package v1alpha1 +type ElasticQuotaExpansion interface{} + type PodGroupExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go similarity index 98% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go index 13a0b05dd0..f318852580 100644 --- a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup.go +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/podgroup.go @@ -26,7 +26,7 @@ import ( types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" scheme "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/scheme" ) diff --git a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup_client.go b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go similarity index 91% rename from pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup_client.go rename to pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go index c507d39d7b..f7857d9d39 100644 --- a/pkg/generated/clientset/versioned/typed/podgroup/v1alpha1/podgroup_client.go +++ b/pkg/generated/clientset/versioned/typed/scheduling/v1alpha1/scheduling_client.go @@ -20,12 +20,13 @@ package v1alpha1 import ( rest "k8s.io/client-go/rest" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/scheme" ) type SchedulingV1alpha1Interface interface { RESTClient() rest.Interface + ElasticQuotasGetter PodGroupsGetter } @@ -34,6 +35,10 @@ type SchedulingV1alpha1Client struct { restClient rest.Interface } +func (c *SchedulingV1alpha1Client) ElasticQuotas(namespace string) ElasticQuotaInterface { + return newElasticQuotas(c, namespace) +} + func (c *SchedulingV1alpha1Client) PodGroups(namespace string) PodGroupInterface { return newPodGroups(c, namespace) } diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index b49277e352..3edb751882 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -29,7 +29,7 @@ import ( cache "k8s.io/client-go/tools/cache" versioned "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" internalinterfaces "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/internalinterfaces" - podgroup "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/podgroup" + scheduling "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/scheduling" ) // SharedInformerOption defines the functional option type for SharedInformerFactory. @@ -172,9 +172,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - Scheduling() podgroup.Interface + Scheduling() scheduling.Interface } -func (f *sharedInformerFactory) Scheduling() podgroup.Interface { - return podgroup.New(f, f.namespace, f.tweakListOptions) +func (f *sharedInformerFactory) Scheduling() scheduling.Interface { + return scheduling.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index ce6a33e334..20e101e9ed 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -23,7 +23,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -53,6 +53,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=scheduling.sigs.k8s.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("elasticquotas"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1alpha1().ElasticQuotas().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("podgroups"): return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1alpha1().PodGroups().Informer()}, nil diff --git a/pkg/generated/informers/externalversions/podgroup/interface.go b/pkg/generated/informers/externalversions/scheduling/interface.go similarity index 96% rename from pkg/generated/informers/externalversions/podgroup/interface.go rename to pkg/generated/informers/externalversions/scheduling/interface.go index 718c092fd5..dfb5cdf447 100644 --- a/pkg/generated/informers/externalversions/podgroup/interface.go +++ b/pkg/generated/informers/externalversions/scheduling/interface.go @@ -16,11 +16,11 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package podgroup +package scheduling import ( internalinterfaces "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/scheduling/v1alpha1" ) // Interface provides access to each of this group's versions. diff --git a/pkg/generated/informers/externalversions/scheduling/v1alpha1/elasticquota.go b/pkg/generated/informers/externalversions/scheduling/v1alpha1/elasticquota.go new file mode 100644 index 0000000000..07f47d2696 --- /dev/null +++ b/pkg/generated/informers/externalversions/scheduling/v1alpha1/elasticquota.go @@ -0,0 +1,90 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + 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" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" + versioned "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" + internalinterfaces "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/listers/scheduling/v1alpha1" +) + +// ElasticQuotaInformer provides access to a shared informer and lister for +// ElasticQuotas. +type ElasticQuotaInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ElasticQuotaLister +} + +type elasticQuotaInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewElasticQuotaInformer constructs a new informer for ElasticQuota 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 NewElasticQuotaInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredElasticQuotaInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredElasticQuotaInformer constructs a new informer for ElasticQuota 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 NewFilteredElasticQuotaInformer(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.SchedulingV1alpha1().ElasticQuotas(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SchedulingV1alpha1().ElasticQuotas(namespace).Watch(context.TODO(), options) + }, + }, + &schedulingv1alpha1.ElasticQuota{}, + resyncPeriod, + indexers, + ) +} + +func (f *elasticQuotaInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredElasticQuotaInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *elasticQuotaInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&schedulingv1alpha1.ElasticQuota{}, f.defaultInformer) +} + +func (f *elasticQuotaInformer) Lister() v1alpha1.ElasticQuotaLister { + return v1alpha1.NewElasticQuotaLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/podgroup/v1alpha1/interface.go b/pkg/generated/informers/externalversions/scheduling/v1alpha1/interface.go similarity index 83% rename from pkg/generated/informers/externalversions/podgroup/v1alpha1/interface.go rename to pkg/generated/informers/externalversions/scheduling/v1alpha1/interface.go index b825827e68..ff26654998 100644 --- a/pkg/generated/informers/externalversions/podgroup/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/scheduling/v1alpha1/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ElasticQuotas returns a ElasticQuotaInformer. + ElasticQuotas() ElasticQuotaInformer // PodGroups returns a PodGroupInformer. PodGroups() PodGroupInformer } @@ -39,6 +41,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ElasticQuotas returns a ElasticQuotaInformer. +func (v *version) ElasticQuotas() ElasticQuotaInformer { + return &elasticQuotaInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PodGroups returns a PodGroupInformer. func (v *version) PodGroups() PodGroupInformer { return &podGroupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/generated/informers/externalversions/podgroup/v1alpha1/podgroup.go b/pkg/generated/informers/externalversions/scheduling/v1alpha1/podgroup.go similarity index 92% rename from pkg/generated/informers/externalversions/podgroup/v1alpha1/podgroup.go rename to pkg/generated/informers/externalversions/scheduling/v1alpha1/podgroup.go index 1160171841..b401dd470d 100644 --- a/pkg/generated/informers/externalversions/podgroup/v1alpha1/podgroup.go +++ b/pkg/generated/informers/externalversions/scheduling/v1alpha1/podgroup.go @@ -26,10 +26,10 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" - podgroupv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + schedulingv1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" versioned "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" internalinterfaces "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/listers/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/generated/listers/scheduling/v1alpha1" ) // PodGroupInformer provides access to a shared informer and lister for @@ -71,7 +71,7 @@ func NewFilteredPodGroupInformer(client versioned.Interface, namespace string, r return client.SchedulingV1alpha1().PodGroups(namespace).Watch(context.TODO(), options) }, }, - &podgroupv1alpha1.PodGroup{}, + &schedulingv1alpha1.PodGroup{}, resyncPeriod, indexers, ) @@ -82,7 +82,7 @@ func (f *podGroupInformer) defaultInformer(client versioned.Interface, resyncPer } func (f *podGroupInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&podgroupv1alpha1.PodGroup{}, f.defaultInformer) + return f.factory.InformerFor(&schedulingv1alpha1.PodGroup{}, f.defaultInformer) } func (f *podGroupInformer) Lister() v1alpha1.PodGroupLister { diff --git a/pkg/generated/listers/scheduling/v1alpha1/elasticquota.go b/pkg/generated/listers/scheduling/v1alpha1/elasticquota.go new file mode 100644 index 0000000000..f88e478bc4 --- /dev/null +++ b/pkg/generated/listers/scheduling/v1alpha1/elasticquota.go @@ -0,0 +1,99 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" +) + +// ElasticQuotaLister helps list ElasticQuotas. +// All objects returned here must be treated as read-only. +type ElasticQuotaLister interface { + // List lists all ElasticQuotas in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ElasticQuota, err error) + // ElasticQuotas returns an object that can list and get ElasticQuotas. + ElasticQuotas(namespace string) ElasticQuotaNamespaceLister + ElasticQuotaListerExpansion +} + +// elasticQuotaLister implements the ElasticQuotaLister interface. +type elasticQuotaLister struct { + indexer cache.Indexer +} + +// NewElasticQuotaLister returns a new ElasticQuotaLister. +func NewElasticQuotaLister(indexer cache.Indexer) ElasticQuotaLister { + return &elasticQuotaLister{indexer: indexer} +} + +// List lists all ElasticQuotas in the indexer. +func (s *elasticQuotaLister) List(selector labels.Selector) (ret []*v1alpha1.ElasticQuota, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ElasticQuota)) + }) + return ret, err +} + +// ElasticQuotas returns an object that can list and get ElasticQuotas. +func (s *elasticQuotaLister) ElasticQuotas(namespace string) ElasticQuotaNamespaceLister { + return elasticQuotaNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ElasticQuotaNamespaceLister helps list and get ElasticQuotas. +// All objects returned here must be treated as read-only. +type ElasticQuotaNamespaceLister interface { + // List lists all ElasticQuotas in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ElasticQuota, err error) + // Get retrieves the ElasticQuota from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ElasticQuota, error) + ElasticQuotaNamespaceListerExpansion +} + +// elasticQuotaNamespaceLister implements the ElasticQuotaNamespaceLister +// interface. +type elasticQuotaNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ElasticQuotas in the indexer for a given namespace. +func (s elasticQuotaNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ElasticQuota, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ElasticQuota)) + }) + return ret, err +} + +// Get retrieves the ElasticQuota from the indexer for a given namespace and name. +func (s elasticQuotaNamespaceLister) Get(name string) (*v1alpha1.ElasticQuota, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("elasticquota"), name) + } + return obj.(*v1alpha1.ElasticQuota), nil +} diff --git a/pkg/generated/listers/podgroup/v1alpha1/expansion_generated.go b/pkg/generated/listers/scheduling/v1alpha1/expansion_generated.go similarity index 75% rename from pkg/generated/listers/podgroup/v1alpha1/expansion_generated.go rename to pkg/generated/listers/scheduling/v1alpha1/expansion_generated.go index 4bee06cb89..3e01f88f29 100644 --- a/pkg/generated/listers/podgroup/v1alpha1/expansion_generated.go +++ b/pkg/generated/listers/scheduling/v1alpha1/expansion_generated.go @@ -18,6 +18,14 @@ limitations under the License. package v1alpha1 +// ElasticQuotaListerExpansion allows custom methods to be added to +// ElasticQuotaLister. +type ElasticQuotaListerExpansion interface{} + +// ElasticQuotaNamespaceListerExpansion allows custom methods to be added to +// ElasticQuotaNamespaceLister. +type ElasticQuotaNamespaceListerExpansion interface{} + // PodGroupListerExpansion allows custom methods to be added to // PodGroupLister. type PodGroupListerExpansion interface{} diff --git a/pkg/generated/listers/podgroup/v1alpha1/podgroup.go b/pkg/generated/listers/scheduling/v1alpha1/podgroup.go similarity index 97% rename from pkg/generated/listers/podgroup/v1alpha1/podgroup.go rename to pkg/generated/listers/scheduling/v1alpha1/podgroup.go index 6b856e464f..8b66dd96d9 100644 --- a/pkg/generated/listers/podgroup/v1alpha1/podgroup.go +++ b/pkg/generated/listers/scheduling/v1alpha1/podgroup.go @@ -22,7 +22,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" - v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + v1alpha1 "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) // PodGroupLister helps list PodGroups. diff --git a/pkg/util/podgroup.go b/pkg/util/podgroup.go index 7c4a5f4c8a..b12b92f66e 100644 --- a/pkg/util/podgroup.go +++ b/pkg/util/podgroup.go @@ -24,7 +24,7 @@ import ( jsonpatch "github.com/evanphx/json-patch" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/scheduler-plugins/pkg/apis/podgroup/v1alpha1" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" ) // DefaultWaitTime is 60s if ScheduleTimeoutSeconds is not specified.