From b8981c31bdecba032490f51a2fa74055ed679733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=91=E7=A5=8E?= Date: Mon, 29 Jan 2024 20:37:50 +0800 Subject: [PATCH] apis: add Recommendation crd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 佑祎 --- OWNERS_ALIASES | 14 +- apis/analysis/v1alpha1/condition.go | 32 +++ apis/analysis/v1alpha1/groupversion_info.go | 43 ++++ .../analysis/v1alpha1/recommendation_types.go | 109 +++++++++ .../v1alpha1/zz_generated.deepcopy.go | 214 +++++++++++++++++ ...alysis.koordinator.sh_recommendations.yaml | 223 ++++++++++++++++++ config/crd/kustomization.yaml | 3 + .../analysis_v1alpha1_metricprediction.yaml | 57 +++++ hack/update-codegen.sh | 3 +- pkg/client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../analysis/v1alpha1/analysis_client.go | 107 +++++++++ .../versioned/typed/analysis/v1alpha1/doc.go | 20 ++ .../typed/analysis/v1alpha1/fake/doc.go | 20 ++ .../v1alpha1/fake/fake_analysis_client.go | 40 ++++ .../v1alpha1/fake/fake_recommendation.go | 142 +++++++++++ .../analysis/v1alpha1/generated_expansion.go | 21 ++ .../typed/analysis/v1alpha1/recommendation.go | 195 +++++++++++++++ .../externalversions/analysis/interface.go | 46 ++++ .../analysis/v1alpha1/interface.go | 45 ++++ .../analysis/v1alpha1/recommendation.go | 90 +++++++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 11 +- .../analysis/v1alpha1/expansion_generated.go | 27 +++ .../analysis/v1alpha1/recommendation.go | 99 ++++++++ pkg/{yarn => prediction}/OWNERS | 4 +- pkg/yarn/controller/OWNERS | 6 - pkg/yarn/copilot/OWNERS | 6 - 30 files changed, 1576 insertions(+), 31 deletions(-) create mode 100644 apis/analysis/v1alpha1/condition.go create mode 100644 apis/analysis/v1alpha1/groupversion_info.go create mode 100644 apis/analysis/v1alpha1/recommendation_types.go create mode 100644 apis/analysis/v1alpha1/zz_generated.deepcopy.go create mode 100644 config/crd/bases/analysis.koordinator.sh_recommendations.yaml create mode 100644 config/samples/analysis_v1alpha1_metricprediction.yaml create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/analysis_client.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_analysis_client.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_recommendation.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/analysis/v1alpha1/recommendation.go create mode 100644 pkg/client/informers/externalversions/analysis/interface.go create mode 100644 pkg/client/informers/externalversions/analysis/v1alpha1/interface.go create mode 100644 pkg/client/informers/externalversions/analysis/v1alpha1/recommendation.go create mode 100644 pkg/client/listers/analysis/v1alpha1/expansion_generated.go create mode 100644 pkg/client/listers/analysis/v1alpha1/recommendation.go rename pkg/{yarn => prediction}/OWNERS (59%) delete mode 100644 pkg/yarn/controller/OWNERS delete mode 100644 pkg/yarn/copilot/OWNERS diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index b550682ef..386942ae3 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -34,19 +34,7 @@ aliases: - FillZpp - eahydra - yarn-approvers: + prediction-approvers: - zwzhang0107 - saintube - yarn-controller-approvers: - - zwzhang0107 - - saintube - - FillZpp - - songzh215 - - yarn-copilot-approvers: - - zwzhang0107 - - saintube - - FillZpp - - songzh215 - diff --git a/apis/analysis/v1alpha1/condition.go b/apis/analysis/v1alpha1/condition.go new file mode 100644 index 000000000..39e35d6e3 --- /dev/null +++ b/apis/analysis/v1alpha1/condition.go @@ -0,0 +1,32 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +const ( + // LowConfidenceCondition indicates the low confidence for the current forecasting result. + LowConfidenceCondition string = "LowConfidence" + // NoObjectsMatchedCondition indicates that the current description didn't match any objects. + NoObjectsMatchedCondition string = "NoObjectsMatched" + // FetchingHistoryCondition indicates that forecaster is in the process of loading additional + // history samples. + FetchingHistoryCondition string = "FetchingHistory" + // ConfigDeprecatedCondition indicates that this configuration is deprecated and will stop being + // supported soon. + ConfigDeprecatedCondition string = "ConfigDeprecated" + // ConfigUnsupportedCondition indicates that this configuration is unsupported and will not be provided for it. + ConfigUnsupportedCondition string = "ConfigUnsupported" +) diff --git a/apis/analysis/v1alpha1/groupversion_info.go b/apis/analysis/v1alpha1/groupversion_info.go new file mode 100644 index 000000000..bf16d7dae --- /dev/null +++ b/apis/analysis/v1alpha1/groupversion_info.go @@ -0,0 +1,43 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the analysis v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=analysis.koordinator.sh +package v1alpha1 + +import ( + "github.com/koordinator-sh/koordinator/apis/scheme" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "analysis.koordinator.sh", Version: "v1alpha1"} + + SchemeGroupVersion = GroupVersion + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Resource is required by pkg/client/listers/... +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/apis/analysis/v1alpha1/recommendation_types.go b/apis/analysis/v1alpha1/recommendation_types.go new file mode 100644 index 000000000..c37e87cc6 --- /dev/null +++ b/apis/analysis/v1alpha1/recommendation_types.go @@ -0,0 +1,109 @@ +/* + Copyright 2024 The Koordinator Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// RecommendationTargetType defines the type of analysis target +type RecommendationTargetType string + +const ( + // RecommendationTargetWorkload defines the k8s workload type + RecommendationTargetWorkload RecommendationTargetType = "workload" + // RecommendationPodSelector defines the pod selector type + RecommendationPodSelector RecommendationTargetType = "podSelector" +) + +// RecommendationTarget defines the target of analysis, which can be a k8s workload or a series of pods +type RecommendationTarget struct { + // Type indicates the type of target + Type RecommendationTargetType `json:"type"` + // Workload indicates the target is a k8s workload, which is effective when Type is "workload" + Workload *CrossVersionObjectReference `json:"workload,omitempty"` + // PodSelector defines the reference of a series of pods, which is effective when Type is "podSelector" + PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"` +} + +// CrossVersionObjectReference contains enough information to let you identify the referred resource. +type CrossVersionObjectReference struct { + // Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + Kind string `json:"kind"` + // Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names + Name string `json:"name"` + // API version of the referent + APIVersion string `json:"apiVersion,omitempty"` +} + +// RecommendationSpec is the specification of the client object. +type RecommendationSpec struct { + // Target is the object to be analyzed, which can be a workload or a series of pods + Target RecommendationTarget `json:"target"` +} + +// RecommendedPodStatus defines the observed state of pod +type RecommendedPodStatus struct { + // ContainerStatuses records the most recently computed amount of resources recommended + ContainerStatuses []RecommendedContainerStatus `json:"containerStatuses,omitempty"` +} + +// RecommendedContainerStatus defines the observed state of container +type RecommendedContainerStatus struct { + // Name of the container. + ContainerName string `json:"containerName,omitempty"` + // Recommended resources of container + Resources corev1.ResourceList `json:"resources,omitempty"` +} + +// RecommendationStatus defines the observed state of Recommendation +type RecommendationStatus struct { + // PodStatus records the most recently computed amount of resources recommended + PodStatus RecommendedPodStatus `json:"podStatus,omitempty"` + // UpdateTime is the update time of the distribution + UpdateTime *metav1.Time `json:"updateTime,omitempty"` + // Conditions is the list of conditions representing the status of the distribution + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:shortName=recom + +// Recommendation is the Schema for the recommendations API +type Recommendation struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec RecommendationSpec `json:"spec,omitempty"` + Status RecommendationStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// RecommendationList contains a list of Recommendation +type RecommendationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Recommendation `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Recommendation{}, &RecommendationList{}) +} diff --git a/apis/analysis/v1alpha1/zz_generated.deepcopy.go b/apis/analysis/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..0f76067e3 --- /dev/null +++ b/apis/analysis/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,214 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The Koordinator 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 controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CrossVersionObjectReference) DeepCopyInto(out *CrossVersionObjectReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossVersionObjectReference. +func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference { + if in == nil { + return nil + } + out := new(CrossVersionObjectReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Recommendation) DeepCopyInto(out *Recommendation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Recommendation. +func (in *Recommendation) DeepCopy() *Recommendation { + if in == nil { + return nil + } + out := new(Recommendation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Recommendation) 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 *RecommendationList) DeepCopyInto(out *RecommendationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Recommendation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendationList. +func (in *RecommendationList) DeepCopy() *RecommendationList { + if in == nil { + return nil + } + out := new(RecommendationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RecommendationList) 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 *RecommendationSpec) DeepCopyInto(out *RecommendationSpec) { + *out = *in + in.Target.DeepCopyInto(&out.Target) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendationSpec. +func (in *RecommendationSpec) DeepCopy() *RecommendationSpec { + if in == nil { + return nil + } + out := new(RecommendationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RecommendationStatus) DeepCopyInto(out *RecommendationStatus) { + *out = *in + in.PodStatus.DeepCopyInto(&out.PodStatus) + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = (*in).DeepCopy() + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendationStatus. +func (in *RecommendationStatus) DeepCopy() *RecommendationStatus { + if in == nil { + return nil + } + out := new(RecommendationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RecommendationTarget) DeepCopyInto(out *RecommendationTarget) { + *out = *in + if in.Workload != nil { + in, out := &in.Workload, &out.Workload + *out = new(CrossVersionObjectReference) + **out = **in + } + if in.PodSelector != nil { + in, out := &in.PodSelector, &out.PodSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendationTarget. +func (in *RecommendationTarget) DeepCopy() *RecommendationTarget { + if in == nil { + return nil + } + out := new(RecommendationTarget) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RecommendedContainerStatus) DeepCopyInto(out *RecommendedContainerStatus) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendedContainerStatus. +func (in *RecommendedContainerStatus) DeepCopy() *RecommendedContainerStatus { + if in == nil { + return nil + } + out := new(RecommendedContainerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RecommendedPodStatus) DeepCopyInto(out *RecommendedPodStatus) { + *out = *in + if in.ContainerStatuses != nil { + in, out := &in.ContainerStatuses, &out.ContainerStatuses + *out = make([]RecommendedContainerStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecommendedPodStatus. +func (in *RecommendedPodStatus) DeepCopy() *RecommendedPodStatus { + if in == nil { + return nil + } + out := new(RecommendedPodStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/bases/analysis.koordinator.sh_recommendations.yaml b/config/crd/bases/analysis.koordinator.sh_recommendations.yaml new file mode 100644 index 000000000..36f5752f7 --- /dev/null +++ b/config/crd/bases/analysis.koordinator.sh_recommendations.yaml @@ -0,0 +1,223 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: recommendations.analysis.koordinator.sh +spec: + group: analysis.koordinator.sh + names: + kind: Recommendation + listKind: RecommendationList + plural: recommendations + shortNames: + - recom + singular: recommendation + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Recommendation is the Schema for the recommendations API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: RecommendationSpec is the specification of the client object. + properties: + target: + description: Target is the object to be analyzed, which can be a workload + or a series of pods + properties: + podSelector: + description: PodSelector defines the reference of a series of + pods, which is effective when Type is "podSelector" + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A + single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field is "key", + the operator is "In", and the values array contains only + "value". The requirements are ANDed. + type: object + type: object + type: + description: Type indicates the type of target + type: string + workload: + description: Workload indicates the target is a k8s workload, + which is effective when Type is "workload" + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"' + type: string + name: + description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + required: + - type + type: object + required: + - target + type: object + status: + description: RecommendationStatus defines the observed state of Recommendation + properties: + conditions: + description: Conditions is the list of conditions representing the + status of the distribution + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", + \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge + // +listType=map // +listMapKey=type Conditions []metav1.Condition + `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" + protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + podStatus: + description: PodStatus records the most recently computed amount of + resources recommended + properties: + containerStatuses: + description: ContainerStatuses records the most recently computed + amount of resources recommended + items: + description: RecommendedContainerStatus defines the observed + state of container + properties: + containerName: + description: Name of the container. + type: string + resources: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Recommended resources of container + type: object + type: object + type: array + type: object + updateTime: + description: UpdateTime is the update time of the distribution + format: date-time + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 9aaafedbc..e0775903d 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -12,17 +12,20 @@ resources: - bases/scheduling.sigs.k8s.io_podgroups.yaml - bases/topology.node.k8s.io_noderesourcetopologies.yaml - bases/quota.koordinator.sh_elasticquotaprofiles.yaml +- bases/analysis.koordinator.sh_metricpredictions.yaml #+kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_nodemetrics.yaml +#- patches/webhook_in_metricpredictions.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_nodemetrics.yaml +#- patches/cainjection_in_metricpredictions.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/samples/analysis_v1alpha1_metricprediction.yaml b/config/samples/analysis_v1alpha1_metricprediction.yaml new file mode 100644 index 000000000..10d98c000 --- /dev/null +++ b/config/samples/analysis_v1alpha1_metricprediction.yaml @@ -0,0 +1,57 @@ +apiVersion: analysis.koordinator.sh/v1alpha1 +kind: MetricPrediction +metadata: + name: metricprediction-sample + namespace: default +spec: + target: + type: workload + workload: + apiVersion: apps/v1 + kind: Deployment + name: nginx + hierarchy: + level: container + metric: + source: metricServer + metricServer: + resources: [cpu, memory] + profilers: + - name: recommendation-sample + model: distribution + distribution: + # args +status: + results: + - profilerName: recommendation-sample + model: distribution + distributionResult: + items: + - id: + level: container + name: nginx-container + resources: + - name: cpu + avg: 6850m + quantiles: + # ... + p95: 7950m + p99: 8900m + stdDev: 759m + firstSampleTime: 2024-01-29T07:15:56Z + lastSampleTime: 2024-01-30T07:15:56Z + totalSamplesCount: 10000 + updateTime: 2024-01-30T07:16:56Z + conditions: [] + - name: memory + avg: 1000Mi + quantiles: + # ... + p95: 1100Mi + p99: 1200Mi + stdDev: 100Mi + firstSampleTime: 2024-01-29T07:15:56Z + lastSampleTime: 2024-01-30T07:15:56Z + totalSamplesCount: 10000 + updateTime: 2024-01-30T07:16:56Z + conditions: [] \ No newline at end of file diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index d3ad71b25..2b93e473e 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -47,7 +47,7 @@ echo ">> Temporary output directory ${TEMP_DIR}" # instead of the $GOPATH directly. For normal projects this can be dropped. $SCRIPT_ROOT/hack/generate-groups.sh "client,informer,lister" \ github.com/koordinator-sh/koordinator/pkg/client github.com/koordinator-sh/koordinator/apis \ - "config:v1alpha1 slo:v1alpha1 scheduling:v1alpha1 quota:v1alpha1" \ + "analysis:v1alpha1 config:v1alpha1 slo:v1alpha1 scheduling:v1alpha1 quota:v1alpha1" \ --output-base "${TEMP_DIR}" \ --go-header-file hack/boilerplate/boilerplate.go.txt @@ -76,6 +76,7 @@ function custom_sed(){ perl -i -pe $@ } +custom_sed 's#\"analysis\"#\"config.koordinator.sh\"#g' ./pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_*.go custom_sed 's#\"config\"#\"config.koordinator.sh\"#g' ./pkg/client/clientset/versioned/typed/config/v1alpha1/fake/fake_*.go custom_sed 's#\"slo\"#\"slo.koordinator.sh\"#g' ./pkg/client/clientset/versioned/typed/slo/v1alpha1/fake/fake_*.go custom_sed 's#\"scheduling\"#\"scheduling.koordinator.sh\"#g' ./pkg/client/clientset/versioned/typed/scheduling/v1alpha1/fake/fake_*.go diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 0d6705fa7..c53d57782 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( "fmt" "net/http" + analysisv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/analysis/v1alpha1" configv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/config/v1alpha1" quotav1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/quota/v1alpha1" schedulingv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/scheduling/v1alpha1" @@ -33,6 +34,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface + AnalysisV1alpha1() analysisv1alpha1.AnalysisV1alpha1Interface ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface QuotaV1alpha1() quotav1alpha1.QuotaV1alpha1Interface SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface @@ -43,12 +45,18 @@ type Interface interface { // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient + analysisV1alpha1 *analysisv1alpha1.AnalysisV1alpha1Client configV1alpha1 *configv1alpha1.ConfigV1alpha1Client quotaV1alpha1 *quotav1alpha1.QuotaV1alpha1Client schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client sloV1alpha1 *slov1alpha1.SloV1alpha1Client } +// AnalysisV1alpha1 retrieves the AnalysisV1alpha1Client +func (c *Clientset) AnalysisV1alpha1() analysisv1alpha1.AnalysisV1alpha1Interface { + return c.analysisV1alpha1 +} + // ConfigV1alpha1 retrieves the ConfigV1alpha1Client func (c *Clientset) ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface { return c.configV1alpha1 @@ -113,6 +121,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error + cs.analysisV1alpha1, err = analysisv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.configV1alpha1, err = configv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -150,6 +162,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset + cs.analysisV1alpha1 = analysisv1alpha1.New(c) cs.configV1alpha1 = configv1alpha1.New(c) cs.quotaV1alpha1 = quotav1alpha1.New(c) cs.schedulingV1alpha1 = schedulingv1alpha1.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 1e12ba4ff..d30048766 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -20,6 +20,8 @@ package fake import ( clientset "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" + analysisv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/analysis/v1alpha1" + fakeanalysisv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake" configv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/config/v1alpha1" fakeconfigv1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/config/v1alpha1/fake" quotav1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/quota/v1alpha1" @@ -85,6 +87,11 @@ var ( _ testing.FakeClient = &Clientset{} ) +// AnalysisV1alpha1 retrieves the AnalysisV1alpha1Client +func (c *Clientset) AnalysisV1alpha1() analysisv1alpha1.AnalysisV1alpha1Interface { + return &fakeanalysisv1alpha1.FakeAnalysisV1alpha1{Fake: &c.Fake} +} + // ConfigV1alpha1 retrieves the ConfigV1alpha1Client func (c *Clientset) ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface { return &fakeconfigv1alpha1.FakeConfigV1alpha1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 856389a42..7e9537883 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -19,6 +19,7 @@ limitations under the License. package fake import ( + analysisv1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" configv1alpha1 "github.com/koordinator-sh/koordinator/apis/config/v1alpha1" quotav1alpha1 "github.com/koordinator-sh/koordinator/apis/quota/v1alpha1" schedulingv1alpha1 "github.com/koordinator-sh/koordinator/apis/scheduling/v1alpha1" @@ -34,6 +35,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + analysisv1alpha1.AddToScheme, configv1alpha1.AddToScheme, quotav1alpha1.AddToScheme, schedulingv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index d9ff69ce3..3600010d6 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -19,6 +19,7 @@ limitations under the License. package scheme import ( + analysisv1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" configv1alpha1 "github.com/koordinator-sh/koordinator/apis/config/v1alpha1" quotav1alpha1 "github.com/koordinator-sh/koordinator/apis/quota/v1alpha1" schedulingv1alpha1 "github.com/koordinator-sh/koordinator/apis/scheduling/v1alpha1" @@ -34,6 +35,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + analysisv1alpha1.AddToScheme, configv1alpha1.AddToScheme, quotav1alpha1.AddToScheme, schedulingv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/analysis_client.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/analysis_client.go new file mode 100644 index 000000000..7959ff8ab --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/analysis_client.go @@ -0,0 +1,107 @@ +/* +Copyright 2022 The Koordinator 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 ( + "net/http" + + v1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AnalysisV1alpha1Interface interface { + RESTClient() rest.Interface + RecommendationsGetter +} + +// AnalysisV1alpha1Client is used to interact with features provided by the analysis group. +type AnalysisV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AnalysisV1alpha1Client) Recommendations(namespace string) RecommendationInterface { + return newRecommendations(c, namespace) +} + +// NewForConfig creates a new AnalysisV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*AnalysisV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AnalysisV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AnalysisV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &AnalysisV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AnalysisV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AnalysisV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AnalysisV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AnalysisV1alpha1Client { + return &AnalysisV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + 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 *AnalysisV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/doc.go new file mode 100644 index 000000000..28802f366 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/doc.go new file mode 100644 index 000000000..a537e15bf --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2022 The Koordinator 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/analysis/v1alpha1/fake/fake_analysis_client.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_analysis_client.go new file mode 100644 index 000000000..441103d3d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_analysis_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2022 The Koordinator 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 ( + v1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/typed/analysis/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAnalysisV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAnalysisV1alpha1) Recommendations(namespace string) v1alpha1.RecommendationInterface { + return &FakeRecommendations{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAnalysisV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_recommendation.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_recommendation.go new file mode 100644 index 000000000..dfc543373 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/fake/fake_recommendation.go @@ -0,0 +1,142 @@ +/* +Copyright 2022 The Koordinator 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" + + v1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + 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" +) + +// FakeRecommendations implements RecommendationInterface +type FakeRecommendations struct { + Fake *FakeAnalysisV1alpha1 + ns string +} + +var recommendationsResource = schema.GroupVersionResource{Group: "config.koordinator.sh", Version: "v1alpha1", Resource: "recommendations"} + +var recommendationsKind = schema.GroupVersionKind{Group: "config.koordinator.sh", Version: "v1alpha1", Kind: "Recommendation"} + +// Get takes name of the recommendation, and returns the corresponding recommendation object, and an error if there is any. +func (c *FakeRecommendations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Recommendation, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(recommendationsResource, c.ns, name), &v1alpha1.Recommendation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Recommendation), err +} + +// List takes label and field selectors, and returns the list of Recommendations that match those selectors. +func (c *FakeRecommendations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RecommendationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(recommendationsResource, recommendationsKind, c.ns, opts), &v1alpha1.RecommendationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RecommendationList{ListMeta: obj.(*v1alpha1.RecommendationList).ListMeta} + for _, item := range obj.(*v1alpha1.RecommendationList).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 recommendations. +func (c *FakeRecommendations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(recommendationsResource, c.ns, opts)) + +} + +// Create takes the representation of a recommendation and creates it. Returns the server's representation of the recommendation, and an error, if there is any. +func (c *FakeRecommendations) Create(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.CreateOptions) (result *v1alpha1.Recommendation, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(recommendationsResource, c.ns, recommendation), &v1alpha1.Recommendation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Recommendation), err +} + +// Update takes the representation of a recommendation and updates it. Returns the server's representation of the recommendation, and an error, if there is any. +func (c *FakeRecommendations) Update(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (result *v1alpha1.Recommendation, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(recommendationsResource, c.ns, recommendation), &v1alpha1.Recommendation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Recommendation), 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 *FakeRecommendations) UpdateStatus(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (*v1alpha1.Recommendation, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(recommendationsResource, "status", c.ns, recommendation), &v1alpha1.Recommendation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Recommendation), err +} + +// Delete takes name of the recommendation and deletes it. Returns an error if one occurs. +func (c *FakeRecommendations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(recommendationsResource, c.ns, name, opts), &v1alpha1.Recommendation{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRecommendations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(recommendationsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.RecommendationList{}) + return err +} + +// Patch applies the patch and returns the patched recommendation. +func (c *FakeRecommendations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Recommendation, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(recommendationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Recommendation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Recommendation), err +} diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..46457b2b9 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type RecommendationExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/analysis/v1alpha1/recommendation.go b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/recommendation.go new file mode 100644 index 000000000..4f6969b4a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/analysis/v1alpha1/recommendation.go @@ -0,0 +1,195 @@ +/* +Copyright 2022 The Koordinator 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" + + v1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + scheme "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// RecommendationsGetter has a method to return a RecommendationInterface. +// A group's client should implement this interface. +type RecommendationsGetter interface { + Recommendations(namespace string) RecommendationInterface +} + +// RecommendationInterface has methods to work with Recommendation resources. +type RecommendationInterface interface { + Create(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.CreateOptions) (*v1alpha1.Recommendation, error) + Update(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (*v1alpha1.Recommendation, error) + UpdateStatus(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (*v1alpha1.Recommendation, 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.Recommendation, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RecommendationList, 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.Recommendation, err error) + RecommendationExpansion +} + +// recommendations implements RecommendationInterface +type recommendations struct { + client rest.Interface + ns string +} + +// newRecommendations returns a Recommendations +func newRecommendations(c *AnalysisV1alpha1Client, namespace string) *recommendations { + return &recommendations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the recommendation, and returns the corresponding recommendation object, and an error if there is any. +func (c *recommendations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Recommendation, err error) { + result = &v1alpha1.Recommendation{} + err = c.client.Get(). + Namespace(c.ns). + Resource("recommendations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Recommendations that match those selectors. +func (c *recommendations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RecommendationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RecommendationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("recommendations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested recommendations. +func (c *recommendations) 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("recommendations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a recommendation and creates it. Returns the server's representation of the recommendation, and an error, if there is any. +func (c *recommendations) Create(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.CreateOptions) (result *v1alpha1.Recommendation, err error) { + result = &v1alpha1.Recommendation{} + err = c.client.Post(). + Namespace(c.ns). + Resource("recommendations"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(recommendation). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a recommendation and updates it. Returns the server's representation of the recommendation, and an error, if there is any. +func (c *recommendations) Update(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (result *v1alpha1.Recommendation, err error) { + result = &v1alpha1.Recommendation{} + err = c.client.Put(). + Namespace(c.ns). + Resource("recommendations"). + Name(recommendation.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(recommendation). + Do(ctx). + 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 *recommendations) UpdateStatus(ctx context.Context, recommendation *v1alpha1.Recommendation, opts v1.UpdateOptions) (result *v1alpha1.Recommendation, err error) { + result = &v1alpha1.Recommendation{} + err = c.client.Put(). + Namespace(c.ns). + Resource("recommendations"). + Name(recommendation.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(recommendation). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the recommendation and deletes it. Returns an error if one occurs. +func (c *recommendations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("recommendations"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *recommendations) 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("recommendations"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched recommendation. +func (c *recommendations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Recommendation, err error) { + result = &v1alpha1.Recommendation{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("recommendations"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/analysis/interface.go b/pkg/client/informers/externalversions/analysis/interface.go new file mode 100644 index 000000000..7976ee3cf --- /dev/null +++ b/pkg/client/informers/externalversions/analysis/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2022 The Koordinator 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 analysis + +import ( + v1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/analysis/v1alpha1" + internalinterfaces "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group 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 &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/analysis/v1alpha1/interface.go b/pkg/client/informers/externalversions/analysis/v1alpha1/interface.go new file mode 100644 index 000000000..7162d7da7 --- /dev/null +++ b/pkg/client/informers/externalversions/analysis/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2022 The Koordinator 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 ( + internalinterfaces "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Recommendations returns a RecommendationInformer. + Recommendations() RecommendationInformer +} + +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} +} + +// Recommendations returns a RecommendationInformer. +func (v *version) Recommendations() RecommendationInformer { + return &recommendationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/analysis/v1alpha1/recommendation.go b/pkg/client/informers/externalversions/analysis/v1alpha1/recommendation.go new file mode 100644 index 000000000..7e94e4fd3 --- /dev/null +++ b/pkg/client/informers/externalversions/analysis/v1alpha1/recommendation.go @@ -0,0 +1,90 @@ +/* +Copyright 2022 The Koordinator 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" + + analysisv1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + versioned "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" + internalinterfaces "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/koordinator-sh/koordinator/pkg/client/listers/analysis/v1alpha1" + 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" +) + +// RecommendationInformer provides access to a shared informer and lister for +// Recommendations. +type RecommendationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.RecommendationLister +} + +type recommendationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRecommendationInformer constructs a new informer for Recommendation 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 NewRecommendationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRecommendationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRecommendationInformer constructs a new informer for Recommendation 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 NewFilteredRecommendationInformer(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.AnalysisV1alpha1().Recommendations(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AnalysisV1alpha1().Recommendations(namespace).Watch(context.TODO(), options) + }, + }, + &analysisv1alpha1.Recommendation{}, + resyncPeriod, + indexers, + ) +} + +func (f *recommendationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRecommendationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *recommendationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&analysisv1alpha1.Recommendation{}, f.defaultInformer) +} + +func (f *recommendationInformer) Lister() v1alpha1.RecommendationLister { + return v1alpha1.NewRecommendationLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index b814041a5..db79275e9 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -24,6 +24,7 @@ import ( time "time" versioned "github.com/koordinator-sh/koordinator/pkg/client/clientset/versioned" + analysis "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/analysis" config "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/config" internalinterfaces "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/internalinterfaces" quota "github.com/koordinator-sh/koordinator/pkg/client/informers/externalversions/quota" @@ -175,12 +176,17 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + Analysis() analysis.Interface Config() config.Interface Quota() quota.Interface Scheduling() scheduling.Interface Slo() slo.Interface } +func (f *sharedInformerFactory) Analysis() analysis.Interface { + return analysis.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Config() config.Interface { return config.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 0f8c22878..c03950c1c 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -21,7 +21,8 @@ package externalversions import ( "fmt" - v1alpha1 "github.com/koordinator-sh/koordinator/apis/config/v1alpha1" + v1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + configv1alpha1 "github.com/koordinator-sh/koordinator/apis/config/v1alpha1" quotav1alpha1 "github.com/koordinator-sh/koordinator/apis/quota/v1alpha1" schedulingv1alpha1 "github.com/koordinator-sh/koordinator/apis/scheduling/v1alpha1" slov1alpha1 "github.com/koordinator-sh/koordinator/apis/slo/v1alpha1" @@ -55,8 +56,12 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=config, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("clustercolocationprofiles"): + // Group=analysis, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("recommendations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Analysis().V1alpha1().Recommendations().Informer()}, nil + + // Group=config, Version=v1alpha1 + case configv1alpha1.SchemeGroupVersion.WithResource("clustercolocationprofiles"): return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha1().ClusterColocationProfiles().Informer()}, nil // Group=quota, Version=v1alpha1 diff --git a/pkg/client/listers/analysis/v1alpha1/expansion_generated.go b/pkg/client/listers/analysis/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..7d2acaa45 --- /dev/null +++ b/pkg/client/listers/analysis/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2022 The Koordinator 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 + +// RecommendationListerExpansion allows custom methods to be added to +// RecommendationLister. +type RecommendationListerExpansion interface{} + +// RecommendationNamespaceListerExpansion allows custom methods to be added to +// RecommendationNamespaceLister. +type RecommendationNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/analysis/v1alpha1/recommendation.go b/pkg/client/listers/analysis/v1alpha1/recommendation.go new file mode 100644 index 000000000..d521b6d88 --- /dev/null +++ b/pkg/client/listers/analysis/v1alpha1/recommendation.go @@ -0,0 +1,99 @@ +/* +Copyright 2022 The Koordinator 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 ( + v1alpha1 "github.com/koordinator-sh/koordinator/apis/analysis/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// RecommendationLister helps list Recommendations. +// All objects returned here must be treated as read-only. +type RecommendationLister interface { + // List lists all Recommendations in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Recommendation, err error) + // Recommendations returns an object that can list and get Recommendations. + Recommendations(namespace string) RecommendationNamespaceLister + RecommendationListerExpansion +} + +// recommendationLister implements the RecommendationLister interface. +type recommendationLister struct { + indexer cache.Indexer +} + +// NewRecommendationLister returns a new RecommendationLister. +func NewRecommendationLister(indexer cache.Indexer) RecommendationLister { + return &recommendationLister{indexer: indexer} +} + +// List lists all Recommendations in the indexer. +func (s *recommendationLister) List(selector labels.Selector) (ret []*v1alpha1.Recommendation, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Recommendation)) + }) + return ret, err +} + +// Recommendations returns an object that can list and get Recommendations. +func (s *recommendationLister) Recommendations(namespace string) RecommendationNamespaceLister { + return recommendationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RecommendationNamespaceLister helps list and get Recommendations. +// All objects returned here must be treated as read-only. +type RecommendationNamespaceLister interface { + // List lists all Recommendations in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Recommendation, err error) + // Get retrieves the Recommendation from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Recommendation, error) + RecommendationNamespaceListerExpansion +} + +// recommendationNamespaceLister implements the RecommendationNamespaceLister +// interface. +type recommendationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Recommendations in the indexer for a given namespace. +func (s recommendationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Recommendation, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Recommendation)) + }) + return ret, err +} + +// Get retrieves the Recommendation from the indexer for a given namespace and name. +func (s recommendationNamespaceLister) Get(name string) (*v1alpha1.Recommendation, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("recommendation"), name) + } + return obj.(*v1alpha1.Recommendation), nil +} diff --git a/pkg/yarn/OWNERS b/pkg/prediction/OWNERS similarity index 59% rename from pkg/yarn/OWNERS rename to pkg/prediction/OWNERS index b4057792a..38756bdc4 100644 --- a/pkg/yarn/OWNERS +++ b/pkg/prediction/OWNERS @@ -1,6 +1,6 @@ # See the OWNERS docs at https://go.k8s.io/owners approvers: - - yarn-approvers + - prediction-approvers reviewers: - - yarn-approvers + - prediction-approvers diff --git a/pkg/yarn/controller/OWNERS b/pkg/yarn/controller/OWNERS deleted file mode 100644 index d12c358e2..000000000 --- a/pkg/yarn/controller/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: - - yarn-controller-approvers -reviewers: - - yarn-controller-approvers diff --git a/pkg/yarn/copilot/OWNERS b/pkg/yarn/copilot/OWNERS deleted file mode 100644 index 520331aa3..000000000 --- a/pkg/yarn/copilot/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: - - yarn-copilot-approvers -reviewers: - - yarn-copilot-approvers