diff --git a/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml b/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml index 05c813469854..25c027f455cf 100644 --- a/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml +++ b/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml @@ -268,6 +268,23 @@ spec: description: 'Specification of the behavior of the autoscaler. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.' properties: + recommenders: + description: Recommender responsible for generating recommendation + for this object. List should be empty (then the default recommender + will generate the recommendation) or contain exactly one recommender. + items: + description: VerticalPodAutoscalerRecommenderSelector points to + a specific Vertical Pod Autoscaler recommender. In the future it + might pass parameters to the recommender. + properties: + name: + description: Name of the recommender responsible for generating + recommendation for this object. + type: string + required: + - name + type: object + type: array resourcePolicy: description: Controls how the autoscaler computes recommended resources. The resource policy may be used to set constraints on the recommendations @@ -493,6 +510,7 @@ spec: type: object served: true storage: true + subresources: {} - name: v1beta2 schema: openAPIV3Schema: diff --git a/vertical-pod-autoscaler/e2e/v1/actuation.go b/vertical-pod-autoscaler/e2e/v1/actuation.go index 4a51596f28bb..3eba450008ee 100644 --- a/vertical-pod-autoscaler/e2e/v1/actuation.go +++ b/vertical-pod-autoscaler/e2e/v1/actuation.go @@ -321,7 +321,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() { hamsterResourceList := apiv1.ResourceList{apiv1.ResourceCPU: ParseQuantityOrDie("100m")} sidecarResourceList := apiv1.ResourceList{apiv1.ResourceCPU: ParseQuantityOrDie("5000m")} - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Spec.UpdatePolicy.UpdateMode = &mode vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ diff --git a/vertical-pod-autoscaler/e2e/v1/admission_controller.go b/vertical-pod-autoscaler/e2e/v1/admission_controller.go index b007fb24dfb0..2e5923d36fed 100644 --- a/vertical-pod-autoscaler/e2e/v1/admission_controller.go +++ b/vertical-pod-autoscaler/e2e/v1/admission_controller.go @@ -40,7 +40,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -67,7 +67,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -111,7 +111,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithGuaranteedResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -142,7 +142,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { ParseQuantityOrDie("150m") /*cpu limit*/, ParseQuantityOrDie("200Mi") /*memory limit*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -173,7 +173,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { ParseQuantityOrDie("500m") /*cpu limit*/, ParseQuantityOrDie("500Mi") /*memory limit*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -216,7 +216,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResourcesAndLimits(f, startCpuRequest, startMemRequest, startCpuLimit, startMemLimit) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -269,7 +269,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { ParseQuantityOrDie("150m") /*cpu limit*/, ParseQuantityOrDie("400Mi") /*memory limit*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -311,7 +311,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d.Spec.Template.Spec.Containers = append(d.Spec.Template.Spec.Containers, d.Spec.Template.Spec.Containers[0]) d.Spec.Template.Spec.Containers[1].Name = "hamster2" ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{ { @@ -361,7 +361,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d.Spec.Template.Spec.Containers = append(d.Spec.Template.Spec.Containers, d.Spec.Template.Spec.Containers[0]) d.Spec.Template.Spec.Containers[1].Name = "hamster2" ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{ { @@ -409,7 +409,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -446,7 +446,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Status.Recommendation = &vpa_types.RecommendedPodResources{ ContainerRecommendations: []vpa_types.RecommendedContainerResources{{ ContainerName: "hamster", @@ -483,7 +483,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeploymentWithResources(f, ParseQuantityOrDie("100m") /*cpu*/, ParseQuantityOrDie("100Mi") /*memory*/) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) InstallVPA(f, vpaCRD) ginkgo.By("Setting up a hamster deployment") @@ -500,7 +500,7 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() { d := NewHamsterDeployment(f) ginkgo.By("Setting up a VPA CRD") - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) InstallVPA(f, vpaCRD) ginkgo.By("Setting up a hamster deployment") diff --git a/vertical-pod-autoscaler/e2e/v1/common.go b/vertical-pod-autoscaler/e2e/v1/common.go index be64831cf25c..aad1285d9d85 100644 --- a/vertical-pod-autoscaler/e2e/v1/common.go +++ b/vertical-pod-autoscaler/e2e/v1/common.go @@ -299,7 +299,7 @@ func SetupVPA(f *framework.Framework, cpu string, mode vpa_types.UpdateMode, tar // SetupVPAForNHamsters creates and installs a simple pod with n hamster containers for e2e test purposes. func SetupVPAForNHamsters(f *framework.Framework, n int, cpu string, mode vpa_types.UpdateMode, targetRef *autoscaling.CrossVersionObjectReference) { - vpaCRD := NewVPA(f, "hamster-vpa", targetRef) + vpaCRD := NewVPA(f, "hamster-vpa", targetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaCRD.Spec.UpdatePolicy.UpdateMode = &mode cpuQuantity := ParseQuantityOrDie(cpu) @@ -324,7 +324,7 @@ func SetupVPAForNHamsters(f *framework.Framework, n int, cpu string, mode vpa_ty } // NewVPA creates a VPA object for e2e test purposes. -func NewVPA(f *framework.Framework, name string, targetRef *autoscaling.CrossVersionObjectReference) *vpa_types.VerticalPodAutoscaler { +func NewVPA(f *framework.Framework, name string, targetRef *autoscaling.CrossVersionObjectReference, recommenders []*vpa_types.VerticalPodAutoscalerRecommenderSelector) *vpa_types.VerticalPodAutoscaler { updateMode := vpa_types.UpdateModeAuto vpa := vpa_types.VerticalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ @@ -341,6 +341,12 @@ func NewVPA(f *framework.Framework, name string, targetRef *autoscaling.CrossVer }, }, } + + if len(recommenders) == 0 { + return &vpa + } + + vpa.Spec.Recommenders = recommenders return &vpa } diff --git a/vertical-pod-autoscaler/e2e/v1/full_vpa.go b/vertical-pod-autoscaler/e2e/v1/full_vpa.go index 62cc68938e4f..7a7d7981b361 100644 --- a/vertical-pod-autoscaler/e2e/v1/full_vpa.go +++ b/vertical-pod-autoscaler/e2e/v1/full_vpa.go @@ -82,7 +82,7 @@ var _ = FullVpaE2eDescribe("Pods under VPA", func() { APIVersion: "apps/v1", Kind: "Deployment", Name: "hamster", - }) + }, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaClientSet = vpa_clientset.NewForConfigOrDie(config) vpaClient := vpaClientSet.AutoscalingV1() @@ -123,6 +123,129 @@ var _ = FullVpaE2eDescribe("Pods under VPA", func() { }) }) +var _ = FullVpaE2eDescribe("Pods under VPA with default recommender explicitly configured", func() { + var ( + rc *ResourceConsumer + vpaClientSet *vpa_clientset.Clientset + vpaCRD *vpa_types.VerticalPodAutoscaler + ) + replicas := 3 + + ginkgo.AfterEach(func() { + rc.CleanUp() + }) + + // This schedules AfterEach block that needs to run after the AfterEach above and + // BeforeEach that needs to run before the BeforeEach below - thus the order of these matters. + f := framework.NewDefaultFramework("vertical-pod-autoscaling") + + ginkgo.BeforeEach(func() { + ns := f.Namespace.Name + ginkgo.By("Setting up a hamster deployment") + rc = NewDynamicResourceConsumer("hamster", ns, KindDeployment, + replicas, + 1, /*initCPUTotal*/ + 10, /*initMemoryTotal*/ + 1, /*initCustomMetric*/ + initialCPU, /*cpuRequest*/ + initialMemory, /*memRequest*/ + f.ClientSet, + f.ScalesGetter) + + ginkgo.By("Setting up a VPA CRD with Recommender explicitly configured") + config, err := framework.LoadConfig() + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + vpaCRD = NewVPA(f, "hamster-vpa", &autoscaling.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "hamster", + }, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{{Name: "default"}}) + + vpaClientSet = vpa_clientset.NewForConfigOrDie(config) + vpaClient := vpaClientSet.AutoscalingV1() + _, err = vpaClient.VerticalPodAutoscalers(ns).Create(context.TODO(), vpaCRD, metav1.CreateOptions{}) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + }) + + ginkgo.It("have cpu requests growing with usage", func() { + // initial CPU usage is low so a minimal recommendation is expected + err := waitForResourceRequestInRangeInPods( + f, pollTimeout, metav1.ListOptions{LabelSelector: "name=hamster"}, apiv1.ResourceCPU, + ParseQuantityOrDie(minimalCPULowerBound), ParseQuantityOrDie(minimalCPUUpperBound)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + // consume more CPU to get a higher recommendation + rc.ConsumeCPU(600 * replicas) + err = waitForResourceRequestInRangeInPods( + f, pollTimeout, metav1.ListOptions{LabelSelector: "name=hamster"}, apiv1.ResourceCPU, + ParseQuantityOrDie("500m"), ParseQuantityOrDie("1000m")) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + }) +}) + +var _ = FullVpaE2eDescribe("Pods under VPA with non-recognized recommender explicitly configured", func() { + var ( + rc *ResourceConsumer + vpaClientSet *vpa_clientset.Clientset + vpaCRD *vpa_types.VerticalPodAutoscaler + ) + replicas := 3 + + ginkgo.AfterEach(func() { + rc.CleanUp() + }) + + // This schedules AfterEach block that needs to run after the AfterEach above and + // BeforeEach that needs to run before the BeforeEach below - thus the order of these matters. + f := framework.NewDefaultFramework("vertical-pod-autoscaling") + + ginkgo.BeforeEach(func() { + ns := f.Namespace.Name + ginkgo.By("Setting up a hamster deployment") + rc = NewDynamicResourceConsumer("hamster", ns, KindDeployment, + replicas, + 1, /*initCPUTotal*/ + 10, /*initMemoryTotal*/ + 1, /*initCustomMetric*/ + initialCPU, /*cpuRequest*/ + initialMemory, /*memRequest*/ + f.ClientSet, + f.ScalesGetter) + + ginkgo.By("Setting up a VPA CRD with Recommender explicitly configured") + config, err := framework.LoadConfig() + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + vpaCRD = NewVPA(f, "hamster-vpa", &autoscaling.CrossVersionObjectReference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Name: "hamster", + }, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{{Name: "non-recognized"}}) + + vpaClientSet = vpa_clientset.NewForConfigOrDie(config) + vpaClient := vpaClientSet.AutoscalingV1() + _, err = vpaClient.VerticalPodAutoscalers(ns).Create(context.TODO(), vpaCRD, metav1.CreateOptions{}) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + }) + + ginkgo.It("deployment not updated by non-recognized recommender", func() { + err := waitForResourceRequestInRangeInPods( + f, pollTimeout, metav1.ListOptions{LabelSelector: "name=hamster"}, apiv1.ResourceCPU, + ParseQuantityOrDie(minimalCPULowerBound), ParseQuantityOrDie(minimalCPUUpperBound)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + // consume more CPU to get a higher recommendation + rc.ConsumeCPU(600 * replicas) + err = waitForResourceRequestInRangeInPods( + f, pollTimeout, metav1.ListOptions{LabelSelector: "name=hamster"}, apiv1.ResourceCPU, + ParseQuantityOrDie("500m"), ParseQuantityOrDie("1000m")) + gomega.Expect(err).To(gomega.HaveOccurred()) + }) +}) + var _ = FullVpaE2eDescribe("OOMing pods under VPA", func() { var ( vpaClientSet *vpa_clientset.Clientset @@ -149,7 +272,7 @@ var _ = FullVpaE2eDescribe("OOMing pods under VPA", func() { APIVersion: "v1", Kind: "Deployment", Name: "hamster", - }) + }, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) vpaClientSet = vpa_clientset.NewForConfigOrDie(config) vpaClient := vpaClientSet.AutoscalingV1() diff --git a/vertical-pod-autoscaler/e2e/v1/recommender.go b/vertical-pod-autoscaler/e2e/v1/recommender.go index 5fd4aef50d5c..e345791ccbf5 100644 --- a/vertical-pod-autoscaler/e2e/v1/recommender.go +++ b/vertical-pod-autoscaler/e2e/v1/recommender.go @@ -159,7 +159,7 @@ var _ = RecommenderE2eDescribe("VPA CRD object", func() { APIVersion: "batch/v1", Kind: "CronJob", Name: "hamster-cronjob", - }) + }, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) InstallVPA(f, vpaCRD) @@ -187,7 +187,7 @@ var _ = RecommenderE2eDescribe("VPA CRD object", func() { ) ginkgo.By("Setting up a VPA CRD") - vpaCRD = NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD = NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) InstallVPA(f, vpaCRD) vpaClientSet = getVpaClientSet(f) @@ -304,7 +304,7 @@ func getMilliCpu(resources apiv1.ResourceList) int64 { // createVpaCRDWithMinMaxAllowed creates vpa object with min and max resources allowed. func createVpaCRDWithMinMaxAllowed(f *framework.Framework, minAllowed, maxAllowed apiv1.ResourceList) *vpa_types.VerticalPodAutoscaler { - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) containerResourcePolicies := []vpa_types.ContainerResourcePolicy{ { ContainerName: GetHamsterContainerNameByIndex(0), @@ -361,7 +361,7 @@ var _ = RecommenderE2eDescribe("VPA CRD object", func() { // createVpaCRDWithContainerScalingModes creates vpa object with containers policies // having assigned given scaling modes respectively. func createVpaCRDWithContainerScalingModes(f *framework.Framework, modes ...vpa_types.ContainerScalingMode) *vpa_types.VerticalPodAutoscaler { - vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef) + vpaCRD := NewVPA(f, "hamster-vpa", hamsterTargetRef, []*vpa_types.VerticalPodAutoscalerRecommenderSelector{}) containerResourcePolicies := make([]vpa_types.ContainerResourcePolicy, len(modes), len(modes)) for i := range modes { containerResourcePolicies[i] = vpa_types.ContainerResourcePolicy{ diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go index bd8267b664b0..819209115a37 100644 --- a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go @@ -62,6 +62,13 @@ type VerticalPodAutoscaler struct { Status VerticalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } +// VerticalPodAutoscalerRecommenderSelector points to a specific Vertical Pod Autoscaler recommender +// in the future it might pass parameters to the recommender. +type VerticalPodAutoscalerRecommenderSelector struct { + // Name of the recommender responsible for generating recommendation for this object. + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` +} + // VerticalPodAutoscalerSpec is the specification of the behavior of the autoscaler. type VerticalPodAutoscalerSpec struct { @@ -90,6 +97,12 @@ type VerticalPodAutoscalerSpec struct { // resources for all containers in the pod, without additional constraints. // +optional ResourcePolicy *PodResourcePolicy `json:"resourcePolicy,omitempty" protobuf:"bytes,3,opt,name=resourcePolicy"` + + // Recommender responsible for generating recommendation for this object. + // List should be empty (then the default recommender will generate the + // recommendation) or contain exactly one recommender. + // +optional + Recommenders []*VerticalPodAutoscalerRecommenderSelector `json:"recommenders,omitempty" protobuf:"bytes,4,opt,name=recommenders"` } // PodUpdatePolicy describes the rules on how changes are applied to the pods. diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go index dfd2eadd99f7..a279401e655b 100644 --- a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go @@ -404,6 +404,11 @@ func (in *VerticalPodAutoscalerSpec) DeepCopyInto(out *VerticalPodAutoscalerSpec *out = new(PodResourcePolicy) (*in).DeepCopyInto(*out) } + if in.Recommenders != nil { + in, out := &in.Recommenders, &out.Recommenders + *out = make([]*VerticalPodAutoscalerRecommenderSelector, len(*in)) + copy(*out, *in) + } return } diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/clientset_generated.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 000000000000..8f10e40b4e97 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,103 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + clientset "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned" + autoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1" + fakeautoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake" + autoscalingv1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1" + fakeautoscalingv1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake" + autoscalingv1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2" + fakeautoscalingv1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake" + pocv1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1" + fakepocv1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var _ clientset.Interface = &Clientset{} + +// AutoscalingV1 retrieves the AutoscalingV1Client +func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface { + return &fakeautoscalingv1.FakeAutoscalingV1{Fake: &c.Fake} +} + +// AutoscalingV1beta2 retrieves the AutoscalingV1beta2Client +func (c *Clientset) AutoscalingV1beta2() autoscalingv1beta2.AutoscalingV1beta2Interface { + return &fakeautoscalingv1beta2.FakeAutoscalingV1beta2{Fake: &c.Fake} +} + +// AutoscalingV1beta1 retrieves the AutoscalingV1beta1Client +func (c *Clientset) AutoscalingV1beta1() autoscalingv1beta1.AutoscalingV1beta1Interface { + return &fakeautoscalingv1beta1.FakeAutoscalingV1beta1{Fake: &c.Fake} +} + +// PocV1alpha1 retrieves the PocV1alpha1Client +func (c *Clientset) PocV1alpha1() pocv1alpha1.PocV1alpha1Interface { + return &fakepocv1alpha1.FakePocV1alpha1{Fake: &c.Fake} +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/doc.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 000000000000..9b99e7167091 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/register.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 000000000000..6118b0b996ee --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,62 @@ +/* +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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + autoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" + autoscalingv1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1" + autoscalingv1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" + pocv1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + autoscalingv1.AddToScheme, + autoscalingv1beta2.AddToScheme, + autoscalingv1beta1.AddToScheme, + pocv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/doc.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/doc.go new file mode 100644 index 000000000000..16f44399065e --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_autoscaling.k8s.io_client.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_autoscaling.k8s.io_client.go new file mode 100644 index 000000000000..0ac93be9ed1d --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_autoscaling.k8s.io_client.go @@ -0,0 +1,44 @@ +/* +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 ( + v1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1) VerticalPodAutoscalers(namespace string) v1.VerticalPodAutoscalerInterface { + return &FakeVerticalPodAutoscalers{c, namespace} +} + +func (c *FakeAutoscalingV1) VerticalPodAutoscalerCheckpoints(namespace string) v1.VerticalPodAutoscalerCheckpointInterface { + return &FakeVerticalPodAutoscalerCheckpoints{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscaler.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscaler.go new file mode 100644 index 000000000000..6aab61ba44d4 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscaler.go @@ -0,0 +1,142 @@ +/* +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" + autoscalingk8siov1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalers implements VerticalPodAutoscalerInterface +type FakeVerticalPodAutoscalers struct { + Fake *FakeAutoscalingV1 + ns string +} + +var verticalpodautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1", Resource: "verticalpodautoscalers"} + +var verticalpodautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1", Kind: "VerticalPodAutoscaler"} + +// Get takes name of the verticalPodAutoscaler, and returns the corresponding verticalPodAutoscaler object, and an error if there is any. +func (c *FakeVerticalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *autoscalingk8siov1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalersResource, c.ns, name), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalers that match those selectors. +func (c *FakeVerticalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *autoscalingk8siov1.VerticalPodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalersResource, verticalpodautoscalersKind, c.ns, opts), &autoscalingk8siov1.VerticalPodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &autoscalingk8siov1.VerticalPodAutoscalerList{ListMeta: obj.(*autoscalingk8siov1.VerticalPodAutoscalerList).ListMeta} + for _, item := range obj.(*autoscalingk8siov1.VerticalPodAutoscalerList).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 verticalPodAutoscalers. +func (c *FakeVerticalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscaler and creates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Create(ctx context.Context, verticalPodAutoscaler *autoscalingk8siov1.VerticalPodAutoscaler, opts v1.CreateOptions) (result *autoscalingk8siov1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscaler), err +} + +// Update takes the representation of a verticalPodAutoscaler and updates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Update(ctx context.Context, verticalPodAutoscaler *autoscalingk8siov1.VerticalPodAutoscaler, opts v1.UpdateOptions) (result *autoscalingk8siov1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscaler), 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 *FakeVerticalPodAutoscalers) UpdateStatus(ctx context.Context, verticalPodAutoscaler *autoscalingk8siov1.VerticalPodAutoscaler, opts v1.UpdateOptions) (*autoscalingk8siov1.VerticalPodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(verticalpodautoscalersResource, "status", c.ns, verticalPodAutoscaler), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscaler), err +} + +// Delete takes name of the verticalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalersResource, c.ns, name), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &autoscalingk8siov1.VerticalPodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscaler. +func (c *FakeVerticalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *autoscalingk8siov1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalersResource, c.ns, name, pt, data, subresources...), &autoscalingk8siov1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscaler), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscalercheckpoint.go new file mode 100644 index 000000000000..856e26b12ffb --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/fake/fake_verticalpodautoscalercheckpoint.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" + autoscalingk8siov1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalerCheckpoints implements VerticalPodAutoscalerCheckpointInterface +type FakeVerticalPodAutoscalerCheckpoints struct { + Fake *FakeAutoscalingV1 + ns string +} + +var verticalpodautoscalercheckpointsResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1", Resource: "verticalpodautoscalercheckpoints"} + +var verticalpodautoscalercheckpointsKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1", Kind: "VerticalPodAutoscalerCheckpoint"} + +// Get takes name of the verticalPodAutoscalerCheckpoint, and returns the corresponding verticalPodAutoscalerCheckpoint object, and an error if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Get(ctx context.Context, name string, options v1.GetOptions) (result *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalercheckpointsResource, c.ns, name), &autoscalingk8siov1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpoint), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalerCheckpoints that match those selectors. +func (c *FakeVerticalPodAutoscalerCheckpoints) List(ctx context.Context, opts v1.ListOptions) (result *autoscalingk8siov1.VerticalPodAutoscalerCheckpointList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalercheckpointsResource, verticalpodautoscalercheckpointsKind, c.ns, opts), &autoscalingk8siov1.VerticalPodAutoscalerCheckpointList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &autoscalingk8siov1.VerticalPodAutoscalerCheckpointList{ListMeta: obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpointList).ListMeta} + for _, item := range obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpointList).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 verticalPodAutoscalerCheckpoints. +func (c *FakeVerticalPodAutoscalerCheckpoints) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalercheckpointsResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscalerCheckpoint and creates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Create(ctx context.Context, verticalPodAutoscalerCheckpoint *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, opts v1.CreateOptions) (result *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &autoscalingk8siov1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpoint), err +} + +// Update takes the representation of a verticalPodAutoscalerCheckpoint and updates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Update(ctx context.Context, verticalPodAutoscalerCheckpoint *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, opts v1.UpdateOptions) (result *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &autoscalingk8siov1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpoint), err +} + +// Delete takes name of the verticalPodAutoscalerCheckpoint and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalerCheckpoints) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalercheckpointsResource, c.ns, name), &autoscalingk8siov1.VerticalPodAutoscalerCheckpoint{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalerCheckpoints) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalercheckpointsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &autoscalingk8siov1.VerticalPodAutoscalerCheckpointList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscalerCheckpoint. +func (c *FakeVerticalPodAutoscalerCheckpoints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *autoscalingk8siov1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalercheckpointsResource, c.ns, name, pt, data, subresources...), &autoscalingk8siov1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*autoscalingk8siov1.VerticalPodAutoscalerCheckpoint), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/doc.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/doc.go new file mode 100644 index 000000000000..16f44399065e --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_autoscaling.k8s.io_client.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_autoscaling.k8s.io_client.go new file mode 100644 index 000000000000..5df35155eeef --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_autoscaling.k8s.io_client.go @@ -0,0 +1,44 @@ +/* +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 ( + v1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1beta1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1beta1) VerticalPodAutoscalers(namespace string) v1beta1.VerticalPodAutoscalerInterface { + return &FakeVerticalPodAutoscalers{c, namespace} +} + +func (c *FakeAutoscalingV1beta1) VerticalPodAutoscalerCheckpoints(namespace string) v1beta1.VerticalPodAutoscalerCheckpointInterface { + return &FakeVerticalPodAutoscalerCheckpoints{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscaler.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscaler.go new file mode 100644 index 000000000000..67a68ca49944 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscaler.go @@ -0,0 +1,142 @@ +/* +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" + v1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalers implements VerticalPodAutoscalerInterface +type FakeVerticalPodAutoscalers struct { + Fake *FakeAutoscalingV1beta1 + ns string +} + +var verticalpodautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1beta1", Resource: "verticalpodautoscalers"} + +var verticalpodautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1beta1", Kind: "VerticalPodAutoscaler"} + +// Get takes name of the verticalPodAutoscaler, and returns the corresponding verticalPodAutoscaler object, and an error if there is any. +func (c *FakeVerticalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalersResource, c.ns, name), &v1beta1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalers that match those selectors. +func (c *FakeVerticalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VerticalPodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalersResource, verticalpodautoscalersKind, c.ns, opts), &v1beta1.VerticalPodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.VerticalPodAutoscalerList{ListMeta: obj.(*v1beta1.VerticalPodAutoscalerList).ListMeta} + for _, item := range obj.(*v1beta1.VerticalPodAutoscalerList).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 verticalPodAutoscalers. +func (c *FakeVerticalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscaler and creates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Create(ctx context.Context, verticalPodAutoscaler *v1beta1.VerticalPodAutoscaler, opts v1.CreateOptions) (result *v1beta1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1beta1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscaler), err +} + +// Update takes the representation of a verticalPodAutoscaler and updates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Update(ctx context.Context, verticalPodAutoscaler *v1beta1.VerticalPodAutoscaler, opts v1.UpdateOptions) (result *v1beta1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1beta1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscaler), 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 *FakeVerticalPodAutoscalers) UpdateStatus(ctx context.Context, verticalPodAutoscaler *v1beta1.VerticalPodAutoscaler, opts v1.UpdateOptions) (*v1beta1.VerticalPodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(verticalpodautoscalersResource, "status", c.ns, verticalPodAutoscaler), &v1beta1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscaler), err +} + +// Delete takes name of the verticalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalersResource, c.ns, name), &v1beta1.VerticalPodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.VerticalPodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscaler. +func (c *FakeVerticalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v1beta1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscaler), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscalercheckpoint.go new file mode 100644 index 000000000000..8f0d69e197cf --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/fake/fake_verticalpodautoscalercheckpoint.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" + v1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalerCheckpoints implements VerticalPodAutoscalerCheckpointInterface +type FakeVerticalPodAutoscalerCheckpoints struct { + Fake *FakeAutoscalingV1beta1 + ns string +} + +var verticalpodautoscalercheckpointsResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1beta1", Resource: "verticalpodautoscalercheckpoints"} + +var verticalpodautoscalercheckpointsKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1beta1", Kind: "VerticalPodAutoscalerCheckpoint"} + +// Get takes name of the verticalPodAutoscalerCheckpoint, and returns the corresponding verticalPodAutoscalerCheckpoint object, and an error if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1beta1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscalerCheckpoint), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalerCheckpoints that match those selectors. +func (c *FakeVerticalPodAutoscalerCheckpoints) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VerticalPodAutoscalerCheckpointList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalercheckpointsResource, verticalpodautoscalercheckpointsKind, c.ns, opts), &v1beta1.VerticalPodAutoscalerCheckpointList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.VerticalPodAutoscalerCheckpointList{ListMeta: obj.(*v1beta1.VerticalPodAutoscalerCheckpointList).ListMeta} + for _, item := range obj.(*v1beta1.VerticalPodAutoscalerCheckpointList).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 verticalPodAutoscalerCheckpoints. +func (c *FakeVerticalPodAutoscalerCheckpoints) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalercheckpointsResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscalerCheckpoint and creates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Create(ctx context.Context, verticalPodAutoscalerCheckpoint *v1beta1.VerticalPodAutoscalerCheckpoint, opts v1.CreateOptions) (result *v1beta1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1beta1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscalerCheckpoint), err +} + +// Update takes the representation of a verticalPodAutoscalerCheckpoint and updates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Update(ctx context.Context, verticalPodAutoscalerCheckpoint *v1beta1.VerticalPodAutoscalerCheckpoint, opts v1.UpdateOptions) (result *v1beta1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1beta1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscalerCheckpoint), err +} + +// Delete takes name of the verticalPodAutoscalerCheckpoint and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalerCheckpoints) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1beta1.VerticalPodAutoscalerCheckpoint{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalerCheckpoints) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalercheckpointsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.VerticalPodAutoscalerCheckpointList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscalerCheckpoint. +func (c *FakeVerticalPodAutoscalerCheckpoints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalercheckpointsResource, c.ns, name, pt, data, subresources...), &v1beta1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.VerticalPodAutoscalerCheckpoint), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/doc.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/doc.go new file mode 100644 index 000000000000..16f44399065e --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_autoscaling.k8s.io_client.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_autoscaling.k8s.io_client.go new file mode 100644 index 000000000000..d4cc45a41927 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_autoscaling.k8s.io_client.go @@ -0,0 +1,44 @@ +/* +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 ( + v1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1beta2 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1beta2) VerticalPodAutoscalers(namespace string) v1beta2.VerticalPodAutoscalerInterface { + return &FakeVerticalPodAutoscalers{c, namespace} +} + +func (c *FakeAutoscalingV1beta2) VerticalPodAutoscalerCheckpoints(namespace string) v1beta2.VerticalPodAutoscalerCheckpointInterface { + return &FakeVerticalPodAutoscalerCheckpoints{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1beta2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscaler.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscaler.go new file mode 100644 index 000000000000..a9651910df86 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscaler.go @@ -0,0 +1,142 @@ +/* +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" + v1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalers implements VerticalPodAutoscalerInterface +type FakeVerticalPodAutoscalers struct { + Fake *FakeAutoscalingV1beta2 + ns string +} + +var verticalpodautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1beta2", Resource: "verticalpodautoscalers"} + +var verticalpodautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1beta2", Kind: "VerticalPodAutoscaler"} + +// Get takes name of the verticalPodAutoscaler, and returns the corresponding verticalPodAutoscaler object, and an error if there is any. +func (c *FakeVerticalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalersResource, c.ns, name), &v1beta2.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalers that match those selectors. +func (c *FakeVerticalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VerticalPodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalersResource, verticalpodautoscalersKind, c.ns, opts), &v1beta2.VerticalPodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.VerticalPodAutoscalerList{ListMeta: obj.(*v1beta2.VerticalPodAutoscalerList).ListMeta} + for _, item := range obj.(*v1beta2.VerticalPodAutoscalerList).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 verticalPodAutoscalers. +func (c *FakeVerticalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscaler and creates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Create(ctx context.Context, verticalPodAutoscaler *v1beta2.VerticalPodAutoscaler, opts v1.CreateOptions) (result *v1beta2.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1beta2.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscaler), err +} + +// Update takes the representation of a verticalPodAutoscaler and updates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Update(ctx context.Context, verticalPodAutoscaler *v1beta2.VerticalPodAutoscaler, opts v1.UpdateOptions) (result *v1beta2.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1beta2.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscaler), 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 *FakeVerticalPodAutoscalers) UpdateStatus(ctx context.Context, verticalPodAutoscaler *v1beta2.VerticalPodAutoscaler, opts v1.UpdateOptions) (*v1beta2.VerticalPodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(verticalpodautoscalersResource, "status", c.ns, verticalPodAutoscaler), &v1beta2.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscaler), err +} + +// Delete takes name of the verticalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalersResource, c.ns, name), &v1beta2.VerticalPodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.VerticalPodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscaler. +func (c *FakeVerticalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v1beta2.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscaler), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscalercheckpoint.go new file mode 100644 index 000000000000..18d4c613989a --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/fake/fake_verticalpodautoscalercheckpoint.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" + v1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalerCheckpoints implements VerticalPodAutoscalerCheckpointInterface +type FakeVerticalPodAutoscalerCheckpoints struct { + Fake *FakeAutoscalingV1beta2 + ns string +} + +var verticalpodautoscalercheckpointsResource = schema.GroupVersionResource{Group: "autoscaling.k8s.io", Version: "v1beta2", Resource: "verticalpodautoscalercheckpoints"} + +var verticalpodautoscalercheckpointsKind = schema.GroupVersionKind{Group: "autoscaling.k8s.io", Version: "v1beta2", Kind: "VerticalPodAutoscalerCheckpoint"} + +// Get takes name of the verticalPodAutoscalerCheckpoint, and returns the corresponding verticalPodAutoscalerCheckpoint object, and an error if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1beta2.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscalerCheckpoint), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalerCheckpoints that match those selectors. +func (c *FakeVerticalPodAutoscalerCheckpoints) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VerticalPodAutoscalerCheckpointList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalercheckpointsResource, verticalpodautoscalercheckpointsKind, c.ns, opts), &v1beta2.VerticalPodAutoscalerCheckpointList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.VerticalPodAutoscalerCheckpointList{ListMeta: obj.(*v1beta2.VerticalPodAutoscalerCheckpointList).ListMeta} + for _, item := range obj.(*v1beta2.VerticalPodAutoscalerCheckpointList).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 verticalPodAutoscalerCheckpoints. +func (c *FakeVerticalPodAutoscalerCheckpoints) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalercheckpointsResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscalerCheckpoint and creates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Create(ctx context.Context, verticalPodAutoscalerCheckpoint *v1beta2.VerticalPodAutoscalerCheckpoint, opts v1.CreateOptions) (result *v1beta2.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1beta2.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscalerCheckpoint), err +} + +// Update takes the representation of a verticalPodAutoscalerCheckpoint and updates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Update(ctx context.Context, verticalPodAutoscalerCheckpoint *v1beta2.VerticalPodAutoscalerCheckpoint, opts v1.UpdateOptions) (result *v1beta2.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1beta2.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscalerCheckpoint), err +} + +// Delete takes name of the verticalPodAutoscalerCheckpoint and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalerCheckpoints) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1beta2.VerticalPodAutoscalerCheckpoint{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalerCheckpoints) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalercheckpointsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.VerticalPodAutoscalerCheckpointList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscalerCheckpoint. +func (c *FakeVerticalPodAutoscalerCheckpoints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalercheckpointsResource, c.ns, name, pt, data, subresources...), &v1beta2.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta2.VerticalPodAutoscalerCheckpoint), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/doc.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/doc.go new file mode 100644 index 000000000000..16f44399065e --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_poc.autoscaling.k8s.io_client.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_poc.autoscaling.k8s.io_client.go new file mode 100644 index 000000000000..d2b4b81d38d4 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_poc.autoscaling.k8s.io_client.go @@ -0,0 +1,44 @@ +/* +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 ( + v1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakePocV1alpha1 struct { + *testing.Fake +} + +func (c *FakePocV1alpha1) VerticalPodAutoscalers(namespace string) v1alpha1.VerticalPodAutoscalerInterface { + return &FakeVerticalPodAutoscalers{c, namespace} +} + +func (c *FakePocV1alpha1) VerticalPodAutoscalerCheckpoints(namespace string) v1alpha1.VerticalPodAutoscalerCheckpointInterface { + return &FakeVerticalPodAutoscalerCheckpoints{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakePocV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscaler.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscaler.go new file mode 100644 index 000000000000..c78a25183c07 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscaler.go @@ -0,0 +1,142 @@ +/* +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" + v1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalers implements VerticalPodAutoscalerInterface +type FakeVerticalPodAutoscalers struct { + Fake *FakePocV1alpha1 + ns string +} + +var verticalpodautoscalersResource = schema.GroupVersionResource{Group: "poc.autoscaling.k8s.io", Version: "v1alpha1", Resource: "verticalpodautoscalers"} + +var verticalpodautoscalersKind = schema.GroupVersionKind{Group: "poc.autoscaling.k8s.io", Version: "v1alpha1", Kind: "VerticalPodAutoscaler"} + +// Get takes name of the verticalPodAutoscaler, and returns the corresponding verticalPodAutoscaler object, and an error if there is any. +func (c *FakeVerticalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalersResource, c.ns, name), &v1alpha1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalers that match those selectors. +func (c *FakeVerticalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VerticalPodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalersResource, verticalpodautoscalersKind, c.ns, opts), &v1alpha1.VerticalPodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.VerticalPodAutoscalerList{ListMeta: obj.(*v1alpha1.VerticalPodAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha1.VerticalPodAutoscalerList).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 verticalPodAutoscalers. +func (c *FakeVerticalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscaler and creates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Create(ctx context.Context, verticalPodAutoscaler *v1alpha1.VerticalPodAutoscaler, opts v1.CreateOptions) (result *v1alpha1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1alpha1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscaler), err +} + +// Update takes the representation of a verticalPodAutoscaler and updates it. Returns the server's representation of the verticalPodAutoscaler, and an error, if there is any. +func (c *FakeVerticalPodAutoscalers) Update(ctx context.Context, verticalPodAutoscaler *v1alpha1.VerticalPodAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalersResource, c.ns, verticalPodAutoscaler), &v1alpha1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscaler), 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 *FakeVerticalPodAutoscalers) UpdateStatus(ctx context.Context, verticalPodAutoscaler *v1alpha1.VerticalPodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.VerticalPodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(verticalpodautoscalersResource, "status", c.ns, verticalPodAutoscaler), &v1alpha1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscaler), err +} + +// Delete takes name of the verticalPodAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalersResource, c.ns, name), &v1alpha1.VerticalPodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.VerticalPodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscaler. +func (c *FakeVerticalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VerticalPodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v1alpha1.VerticalPodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscaler), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscalercheckpoint.go new file mode 100644 index 000000000000..328cb7301ebc --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/fake/fake_verticalpodautoscalercheckpoint.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" + v1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1" + testing "k8s.io/client-go/testing" +) + +// FakeVerticalPodAutoscalerCheckpoints implements VerticalPodAutoscalerCheckpointInterface +type FakeVerticalPodAutoscalerCheckpoints struct { + Fake *FakePocV1alpha1 + ns string +} + +var verticalpodautoscalercheckpointsResource = schema.GroupVersionResource{Group: "poc.autoscaling.k8s.io", Version: "v1alpha1", Resource: "verticalpodautoscalercheckpoints"} + +var verticalpodautoscalercheckpointsKind = schema.GroupVersionKind{Group: "poc.autoscaling.k8s.io", Version: "v1alpha1", Kind: "VerticalPodAutoscalerCheckpoint"} + +// Get takes name of the verticalPodAutoscalerCheckpoint, and returns the corresponding verticalPodAutoscalerCheckpoint object, and an error if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1alpha1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscalerCheckpoint), err +} + +// List takes label and field selectors, and returns the list of VerticalPodAutoscalerCheckpoints that match those selectors. +func (c *FakeVerticalPodAutoscalerCheckpoints) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VerticalPodAutoscalerCheckpointList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(verticalpodautoscalercheckpointsResource, verticalpodautoscalercheckpointsKind, c.ns, opts), &v1alpha1.VerticalPodAutoscalerCheckpointList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.VerticalPodAutoscalerCheckpointList{ListMeta: obj.(*v1alpha1.VerticalPodAutoscalerCheckpointList).ListMeta} + for _, item := range obj.(*v1alpha1.VerticalPodAutoscalerCheckpointList).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 verticalPodAutoscalerCheckpoints. +func (c *FakeVerticalPodAutoscalerCheckpoints) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(verticalpodautoscalercheckpointsResource, c.ns, opts)) + +} + +// Create takes the representation of a verticalPodAutoscalerCheckpoint and creates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Create(ctx context.Context, verticalPodAutoscalerCheckpoint *v1alpha1.VerticalPodAutoscalerCheckpoint, opts v1.CreateOptions) (result *v1alpha1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1alpha1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscalerCheckpoint), err +} + +// Update takes the representation of a verticalPodAutoscalerCheckpoint and updates it. Returns the server's representation of the verticalPodAutoscalerCheckpoint, and an error, if there is any. +func (c *FakeVerticalPodAutoscalerCheckpoints) Update(ctx context.Context, verticalPodAutoscalerCheckpoint *v1alpha1.VerticalPodAutoscalerCheckpoint, opts v1.UpdateOptions) (result *v1alpha1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(verticalpodautoscalercheckpointsResource, c.ns, verticalPodAutoscalerCheckpoint), &v1alpha1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscalerCheckpoint), err +} + +// Delete takes name of the verticalPodAutoscalerCheckpoint and deletes it. Returns an error if one occurs. +func (c *FakeVerticalPodAutoscalerCheckpoints) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(verticalpodautoscalercheckpointsResource, c.ns, name), &v1alpha1.VerticalPodAutoscalerCheckpoint{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVerticalPodAutoscalerCheckpoints) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(verticalpodautoscalercheckpointsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.VerticalPodAutoscalerCheckpointList{}) + return err +} + +// Patch applies the patch and returns the patched verticalPodAutoscalerCheckpoint. +func (c *FakeVerticalPodAutoscalerCheckpoints) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VerticalPodAutoscalerCheckpoint, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(verticalpodautoscalercheckpointsResource, c.ns, name, pt, data, subresources...), &v1alpha1.VerticalPodAutoscalerCheckpoint{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VerticalPodAutoscalerCheckpoint), err +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/annotations/vpa_observed_containers_test.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/annotations/vpa_observed_containers_test.go new file mode 100644 index 000000000000..13ada60aa9e4 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/annotations/vpa_observed_containers_test.go @@ -0,0 +1,87 @@ +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package annotations + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" + "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/test" +) + +func TestGetVpaObservedContainersValue(t *testing.T) { + tests := []struct { + name string + pod *v1.Pod + want string + }{ + { + name: "creating vpa observed containers annotation", + pod: test.Pod(). + AddContainer(test.Container().WithName("test1").Get()). + AddContainer(test.Container().WithName("test2").Get()). + AddContainer(test.Container().WithName("test3").Get()). + Get(), + want: "test1, test2, test3", + }, + } + for _, tc := range tests { + t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) { + got := GetVpaObservedContainersValue(tc.pod) + assert.Equal(t, got, tc.want) + }) + } +} + +func TestParseVpaObservedContainersValue(t *testing.T) { + tests := []struct { + name string + annotation string + want []string + wantErr bool + }{ + { + name: "parsing correct vpa observed containers annotation", + annotation: "test1, test2, test3", + want: []string{"test1", "test2", "test3"}, + wantErr: false, + }, + { + name: "parsing vpa observed containers annotation with incorrect container name", + annotation: "test1, test2, test3_;';s", + want: []string(nil), + wantErr: true, + }, + { + name: "parsing empty vpa observed containers annotation", + annotation: "", + want: []string{}, + wantErr: false, + }, + } + for _, tc := range tests { + t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) { + got, gotErr := ParseVpaObservedContainersValue(tc.annotation) + if (gotErr != nil) != tc.wantErr { + t.Errorf("gotErr %v, wantErr %v", (gotErr != nil), tc.wantErr) + } + assert.Equal(t, got, tc.want) + }) + } +} diff --git a/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object_test.go b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object_test.go new file mode 100644 index 000000000000..2c5ee4c4fdf3 --- /dev/null +++ b/vertical-pod-autoscaler/e2e/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object_test.go @@ -0,0 +1,275 @@ +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package status + +import ( + "fmt" + "syscall" + "testing" + "time" + + "github.com/stretchr/testify/assert" + apicoordinationv1 "k8s.io/api/coordination/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/kubernetes/fake" + testcore "k8s.io/client-go/testing" +) + +func TestUpdateStatus(t *testing.T) { + const ( + leaseName = "lease" + leaseNamespace = "default" + ) + tests := []struct { + name string + updateReactor func(action testcore.Action) (bool, runtime.Object, error) + wantErr bool + }{ + { + name: "updating status object", + updateReactor: func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetResource().Resource == "leases" { + return true, &apicoordinationv1.Lease{}, nil + } + + return true, nil, fmt.Errorf("unsupported action") + }, + wantErr: false, + }, + { + name: "updating status object - creating status", + updateReactor: func() func(action testcore.Action) (bool, runtime.Object, error) { + i := 0 + return func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetResource().Resource == "leases" { + i++ + switch i { + case 1: + return true, nil, apierrors.NewNotFound(schema.GroupResource{}, leaseName) + default: + return true, &apicoordinationv1.Lease{}, nil + } + } + + return true, nil, fmt.Errorf("unsupported action") + } + }(), + wantErr: false, + }, + { + // Status doesn't exist but will be created by an other component in the meantime. + name: "updating status object - creating status, already exists", + updateReactor: func() func(action testcore.Action) (bool, runtime.Object, error) { + i := 0 + return func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetResource().Resource == "leases" { + i++ + switch i { + case 1: + return true, nil, apierrors.NewNotFound(schema.GroupResource{}, leaseName) + default: + return true, nil, apierrors.NewAlreadyExists(schema.GroupResource{}, leaseName) + } + } + + return true, nil, fmt.Errorf("unsupported action") + } + }(), + wantErr: false, + }, + { + // Status is updated by an other component in the meantime. + name: "updating status object - updating conflict", + updateReactor: func() func(action testcore.Action) (bool, runtime.Object, error) { + i := 0 + return func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetResource().Resource == "leases" { + i++ + switch i { + case 1: + return true, &apicoordinationv1.Lease{}, nil + default: + return true, nil, apierrors.NewConflict(schema.GroupResource{}, leaseName, nil) + } + } + + return true, nil, fmt.Errorf("unsupported action") + } + }(), + wantErr: false, + }, + { + name: "updating status object - endless error", + updateReactor: func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetResource().Resource == "leases" { + return true, nil, apierrors.NewNotFound(schema.GroupResource{}, leaseName) + } + return true, nil, fmt.Errorf("unsupported action") + }, + wantErr: true, + }, + } + for _, tc := range tests { + t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) { + fc := fake.NewSimpleClientset() + fc.PrependReactor("get", "leases", tc.updateReactor) + fc.PrependReactor("create", "leases", tc.updateReactor) + fc.PrependReactor("update", "leases", tc.updateReactor) + client := NewClient(fc, leaseName, leaseNamespace, 10*time.Second, leaseName) + err := client.UpdateStatus() + assert.True(t, (err != nil) == tc.wantErr, fmt.Sprintf("gotErr: %v, wantErr: %v", (err != nil), tc.wantErr)) + }) + } +} + +func TestGetStatus(t *testing.T) { + const ( + leaseName = "lease" + leaseNamespace = "default" + ) + tests := []struct { + name string + getReactor func(action testcore.Action) (bool, runtime.Object, error) + wantErr bool + }{ + { + name: "getting status object", + getReactor: func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetVerb() == "get" && action.GetResource().Resource == "leases" { + return true, &apicoordinationv1.Lease{}, nil + } + + return true, nil, fmt.Errorf("unsupported action") + }, + wantErr: false, + }, + { + name: "getting status object - retryable error", + getReactor: func() func(action testcore.Action) (bool, runtime.Object, error) { + i := 0 + return func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetVerb() == "get" && action.GetResource().Resource == "leases" { + i++ + switch i { + case 1, 2: + return true, nil, syscall.ECONNRESET + default: + return true, &apicoordinationv1.Lease{}, nil + } + } + + return true, nil, fmt.Errorf("unsupported action") + } + }(), + wantErr: false, + }, + { + name: "getting status object - non-retryable error", + getReactor: func() func(action testcore.Action) (bool, runtime.Object, error) { + i := 0 + return func(action testcore.Action) (bool, runtime.Object, error) { + if action.GetVerb() == "get" && action.GetResource().Resource == "leases" { + i++ + switch i { + case 1: + return true, nil, fmt.Errorf("non-retryable error") + default: + return true, &apicoordinationv1.Lease{}, nil + } + } + + return true, nil, fmt.Errorf("unsupported action") + } + }(), + wantErr: true, + }, + } + for _, tc := range tests { + t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) { + fc := fake.NewSimpleClientset() + fc.PrependReactor("get", "leases", tc.getReactor) + client := NewClient(fc, leaseName, leaseNamespace, 10*time.Second, leaseName) + _, err := client.getStatus() + assert.True(t, (err != nil) == tc.wantErr) + }) + } +} + +func TestIsStatusValid(t *testing.T) { + now := time.Now() + tests := []struct { + name string + lease *apicoordinationv1.Lease + leaseTimeout time.Duration + expectedValid bool + }{ + { + name: "Valid CreationTimestamp", + lease: &apicoordinationv1.Lease{ + ObjectMeta: metav1.ObjectMeta{ + CreationTimestamp: metav1.Time{Time: now}, + }, + }, + leaseTimeout: 10 * time.Second, + expectedValid: true, + }, + { + name: "Outdated CreationTimestamp with no RenewTime", + lease: &apicoordinationv1.Lease{ + ObjectMeta: metav1.ObjectMeta{ + CreationTimestamp: metav1.Time{Time: now.Add(-time.Minute)}, + }, + }, + leaseTimeout: 10 * time.Second, + expectedValid: false, + }, + { + name: "Valid RenewTime", + lease: &apicoordinationv1.Lease{ + ObjectMeta: metav1.ObjectMeta{ + CreationTimestamp: metav1.Time{Time: now.Add(-time.Minute)}, + }, + Spec: apicoordinationv1.LeaseSpec{ + RenewTime: &metav1.MicroTime{Time: now}, + }, + }, + leaseTimeout: 10 * time.Second, + expectedValid: true, + }, + { + name: "Outdated CreationTimestamp and RenewTime", + lease: &apicoordinationv1.Lease{ + ObjectMeta: metav1.ObjectMeta{ + CreationTimestamp: metav1.Time{Time: now.Add(-time.Minute)}, + }, + Spec: apicoordinationv1.LeaseSpec{ + RenewTime: &metav1.MicroTime{Time: now.Add(-time.Minute)}, + }, + }, + leaseTimeout: 10 * time.Second, + expectedValid: false, + }, + } + for _, tc := range tests { + t.Run(fmt.Sprintf("test case: %s", tc.name), func(t *testing.T) { + assert.Equal(t, isStatusValid(tc.lease, tc.leaseTimeout, now), tc.expectedValid) + }) + } +} diff --git a/vertical-pod-autoscaler/examples/hamster.yaml b/vertical-pod-autoscaler/examples/hamster.yaml index f4190258a25c..a4928605aea5 100644 --- a/vertical-pod-autoscaler/examples/hamster.yaml +++ b/vertical-pod-autoscaler/examples/hamster.yaml @@ -10,6 +10,11 @@ kind: VerticalPodAutoscaler metadata: name: hamster-vpa spec: + # recommenders field can be unset when using the default recommender. + # When using an alternative recommender, the alternative recommender's name + # can be specified as the following in a list. + # recommenders: + # - name: 'alternative' targetRef: apiVersion: "apps/v1" kind: Deployment diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler.go index 5ce614b0e042..8b33a086ab93 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler.go @@ -147,5 +147,9 @@ func validateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error { return fmt.Errorf("TargetRef is required. If you're using v1beta1 version of the API, please migrate to v1") } + if len(vpa.Spec.Recommenders) > 1 { + return fmt.Errorf("The current version of VPA object shouldn't specify more than one recommenders.") + } + return nil } diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler_test.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler_test.go index 80ecb7207499..722f74690700 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler_test.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler_test.go @@ -101,6 +101,21 @@ func TestValidateVPA(t *testing.T) { }, expectError: fmt.Errorf("unexpected Mode value bad"), }, + { + name: "more than one recommender", + vpa: vpa_types.VerticalPodAutoscaler{ + Spec: vpa_types.VerticalPodAutoscalerSpec{ + UpdatePolicy: &vpa_types.PodUpdatePolicy{ + UpdateMode: &validUpdateMode, + }, + Recommenders: []*vpa_types.VerticalPodAutoscalerRecommenderSelector{ + {Name: "test1"}, + {Name: "test2"}, + }, + }, + }, + expectError: fmt.Errorf("The current version of VPA object shouldn't specify more than one recommenders."), + }, { name: "bad limits", vpa: vpa_types.VerticalPodAutoscaler{ diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go index bd8267b664b0..819209115a37 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go @@ -62,6 +62,13 @@ type VerticalPodAutoscaler struct { Status VerticalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` } +// VerticalPodAutoscalerRecommenderSelector points to a specific Vertical Pod Autoscaler recommender +// in the future it might pass parameters to the recommender. +type VerticalPodAutoscalerRecommenderSelector struct { + // Name of the recommender responsible for generating recommendation for this object. + Name string `json:"name" protobuf:"bytes,1,opt,name=name"` +} + // VerticalPodAutoscalerSpec is the specification of the behavior of the autoscaler. type VerticalPodAutoscalerSpec struct { @@ -90,6 +97,12 @@ type VerticalPodAutoscalerSpec struct { // resources for all containers in the pod, without additional constraints. // +optional ResourcePolicy *PodResourcePolicy `json:"resourcePolicy,omitempty" protobuf:"bytes,3,opt,name=resourcePolicy"` + + // Recommender responsible for generating recommendation for this object. + // List should be empty (then the default recommender will generate the + // recommendation) or contain exactly one recommender. + // +optional + Recommenders []*VerticalPodAutoscalerRecommenderSelector `json:"recommenders,omitempty" protobuf:"bytes,4,opt,name=recommenders"` } // PodUpdatePolicy describes the rules on how changes are applied to the pods. diff --git a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go index dfd2eadd99f7..a279401e655b 100644 --- a/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go +++ b/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go @@ -404,6 +404,11 @@ func (in *VerticalPodAutoscalerSpec) DeepCopyInto(out *VerticalPodAutoscalerSpec *out = new(PodResourcePolicy) (*in).DeepCopyInto(*out) } + if in.Recommenders != nil { + in, out := &in.Recommenders, &out.Recommenders + *out = make([]*VerticalPodAutoscalerRecommenderSelector, len(*in)) + copy(*out, *in) + } return } diff --git a/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta2/verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta2/verticalpodautoscalercheckpoint.go index e97650ea880a..6bfad042d310 100644 --- a/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta2/verticalpodautoscalercheckpoint.go +++ b/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta2/verticalpodautoscalercheckpoint.go @@ -26,8 +26,10 @@ import ( ) // VerticalPodAutoscalerCheckpointLister helps list VerticalPodAutoscalerCheckpoints. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerCheckpointLister interface { // List lists all VerticalPodAutoscalerCheckpoints in the indexer. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta2.VerticalPodAutoscalerCheckpoint, err error) // VerticalPodAutoscalerCheckpoints returns an object that can list and get VerticalPodAutoscalerCheckpoints. VerticalPodAutoscalerCheckpoints(namespace string) VerticalPodAutoscalerCheckpointNamespaceLister @@ -58,10 +60,13 @@ func (s *verticalPodAutoscalerCheckpointLister) VerticalPodAutoscalerCheckpoints } // VerticalPodAutoscalerCheckpointNamespaceLister helps list and get VerticalPodAutoscalerCheckpoints. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerCheckpointNamespaceLister interface { // List lists all VerticalPodAutoscalerCheckpoints in the indexer for a given namespace. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta2.VerticalPodAutoscalerCheckpoint, err error) // Get retrieves the VerticalPodAutoscalerCheckpoint from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. Get(name string) (*v1beta2.VerticalPodAutoscalerCheckpoint, error) VerticalPodAutoscalerCheckpointNamespaceListerExpansion } diff --git a/vertical-pod-autoscaler/pkg/client/listers/poc.autoscaling.k8s.io/v1alpha1/verticalpodautoscalercheckpoint.go b/vertical-pod-autoscaler/pkg/client/listers/poc.autoscaling.k8s.io/v1alpha1/verticalpodautoscalercheckpoint.go index 5881680af760..9bb4164e83d7 100644 --- a/vertical-pod-autoscaler/pkg/client/listers/poc.autoscaling.k8s.io/v1alpha1/verticalpodautoscalercheckpoint.go +++ b/vertical-pod-autoscaler/pkg/client/listers/poc.autoscaling.k8s.io/v1alpha1/verticalpodautoscalercheckpoint.go @@ -58,6 +58,7 @@ func (s *verticalPodAutoscalerCheckpointLister) VerticalPodAutoscalerCheckpoints } // VerticalPodAutoscalerCheckpointNamespaceLister helps list and get VerticalPodAutoscalerCheckpoints. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerCheckpointNamespaceLister interface { // List lists all VerticalPodAutoscalerCheckpoints in the indexer for a given namespace. List(selector labels.Selector) (ret []*v1alpha1.VerticalPodAutoscalerCheckpoint, err error) diff --git a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go index a5355ea701f0..6c21ba6cf401 100644 --- a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go +++ b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go @@ -58,6 +58,7 @@ const ( scaleCacheEntryFreshnessTime time.Duration = 10 * time.Minute scaleCacheEntryJitterFactor float64 = 1. defaultResyncPeriod time.Duration = 10 * time.Minute + defaultRecommenderName = "default" ) // ClusterStateFeeder can update state of ClusterState object. @@ -330,14 +331,46 @@ func (feeder *clusterStateFeeder) GarbageCollectCheckpoints() { } } +func implicitDefaultRecommender(selectors []*vpa_types.VerticalPodAutoscalerRecommenderSelector) bool { + return len(selectors) == 0 +} + +func selectsRecommender(selectors []*vpa_types.VerticalPodAutoscalerRecommenderSelector, name *string) bool { + for _, s := range selectors { + if s.Name == *name { + return true + } + } + return false +} + +// Filter VPA objects whose specified recommender names are not default +func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodAutoscaler) []*vpa_types.VerticalPodAutoscaler { + klog.V(3).Infof("Start selecting the vpaCRDs.") + var vpaCRDs []*vpa_types.VerticalPodAutoscaler + for _, vpaCRD := range allVpaCRDs { + currentRecommenderName := defaultRecommenderName + if !implicitDefaultRecommender(vpaCRD.Spec.Recommenders) && !selectsRecommender(vpaCRD.Spec.Recommenders, ¤tRecommenderName) { + klog.V(6).Infof("Ignoring vpaCRD %s in namespace %s as current recommender's name %v doesn't appear among its recommenders", vpaCRD.Name, vpaCRD.Namespace, currentRecommenderName) + continue + } + vpaCRDs = append(vpaCRDs, vpaCRD) + } + return vpaCRDs +} + // Fetch VPA objects and load them into the cluster state. func (feeder *clusterStateFeeder) LoadVPAs() { // List VPA API objects. - vpaCRDs, err := feeder.vpaLister.List(labels.Everything()) + allVpaCRDs, err := feeder.vpaLister.List(labels.Everything()) if err != nil { klog.Errorf("Cannot list VPAs. Reason: %+v", err) return } + + // Filter out VPAs that specified recommenders with names not equal to "default" + vpaCRDs := filterVPAs(feeder, allVpaCRDs) + klog.V(3).Infof("Fetched %d VPAs.", len(vpaCRDs)) // Add or update existing VPAs in the model. vpaKeys := make(map[model.VpaID]bool) diff --git a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder_test.go b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder_test.go index 0a1b63d120b8..360cc2e7b0f3 100644 --- a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder_test.go +++ b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder_test.go @@ -208,7 +208,6 @@ func TestLoadPods(t *testing.T) { vpaLister.On("List").Return([]*vpa_types.VerticalPodAutoscaler{vpa}, nil) targetSelectorFetcher := target_mock.NewMockVpaTargetSelectorFetcher(ctrl) - clusterState := model.NewClusterState(testGcPeriod) clusterStateFeeder := clusterStateFeeder{ @@ -399,6 +398,7 @@ func TestClusterStateFeeder_InitFromHistoryProvider(t *testing.T) { pod1: &pod1History, }, } + clusterState := model.NewClusterState(testGcPeriod) feeder := clusterStateFeeder{ clusterState: clusterState, diff --git a/vertical-pod-autoscaler/pkg/recommender/main.go b/vertical-pod-autoscaler/pkg/recommender/main.go index 9e1ec863cbb2..d01824f3b34b 100644 --- a/vertical-pod-autoscaler/pkg/recommender/main.go +++ b/vertical-pod-autoscaler/pkg/recommender/main.go @@ -32,6 +32,9 @@ import ( "k8s.io/klog" ) +// DefaultRecommenderName denotes the current recommender name as the "default" one. +const DefaultRecommenderName = "default" + var ( metricsFetcherInterval = flag.Duration("recommender-interval", 1*time.Minute, `How often metrics should be fetched`) checkpointsGCInterval = flag.Duration("checkpoints-gc-interval", 10*time.Minute, `How often orphaned checkpoints should be garbage collected`) @@ -68,7 +71,7 @@ var ( func main() { klog.InitFlags(nil) kube_flag.InitFlags() - klog.V(1).Infof("Vertical Pod Autoscaler %s Recommender", common.VerticalPodAutoscalerVersion) + klog.V(1).Infof("Vertical Pod Autoscaler %s Recommender: %v", common.VerticalPodAutoscalerVersion, DefaultRecommenderName) config := common.CreateKubeConfigOrDie(*kubeconfig, float32(*kubeApiQps), int(*kubeApiBurst))