From 7321b16649a2944028298d725fef81b3cbf572d1 Mon Sep 17 00:00:00 2001 From: David van der Spek Date: Mon, 2 Dec 2024 13:02:47 +0100 Subject: [PATCH] fix: bump vpa + update container builds Signed-off-by: David van der Spek --- multidimensional-pod-autoscaler/go.mod | 2 +- multidimensional-pod-autoscaler/go.sum | 4 +- .../pkg/admission-controller/main.go | 2 +- .../pkg/recommender/Dockerfile | 21 ++++-- .../pkg/recommender/Makefile | 41 ++++++------ .../pkg/recommender/main.go | 2 +- .../pkg/updater/Dockerfile | 20 ++++-- .../pkg/updater/Makefile | 36 +++++----- .../pkg/updater/main.go | 2 +- .../v1/zz_generated.deepcopy.go | 32 +++++++++ .../client/clientset/versioned/clientset.go | 66 ++++++++++++------- .../pkg/client/clientset/versioned/doc.go | 20 ------ .../clientset/versioned/scheme/register.go | 2 +- .../v1/autoscaling.k8s.io_client.go | 20 +++++- .../v1beta1/autoscaling.k8s.io_client.go | 20 +++++- .../v1beta2/autoscaling.k8s.io_client.go | 20 +++++- .../v1alpha1/poc.autoscaling.k8s.io_client.go | 20 +++++- .../v1/verticalpodautoscaler.go | 5 ++ .../v1/verticalpodautoscalercheckpoint.go | 5 ++ .../v1beta1/verticalpodautoscaler.go | 5 ++ .../verticalpodautoscalercheckpoint.go | 5 ++ .../input/metrics/metrics_source.go | 7 +- .../pkg/recommender/logic/recommender.go | 26 ++++---- .../pkg/recommender/model/cluster.go | 10 +-- .../pkg/recommender/model/vpa.go | 2 +- .../pkg/recommender/util/histogram.go | 4 +- .../pkg/utils/metrics/healthcheck.go | 13 +++- .../pkg/utils/status/status_object.go | 2 +- .../pkg/utils/vpa/api.go | 4 +- .../vendor/modules.txt | 2 +- 30 files changed, 284 insertions(+), 136 deletions(-) delete mode 100644 multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/doc.go diff --git a/multidimensional-pod-autoscaler/go.mod b/multidimensional-pod-autoscaler/go.mod index 235d41b6b819..53e63d586078 100644 --- a/multidimensional-pod-autoscaler/go.mod +++ b/multidimensional-pod-autoscaler/go.mod @@ -11,7 +11,7 @@ require ( golang.org/x/time v0.4.0 k8s.io/api v0.31.3 k8s.io/apimachinery v0.31.3 - k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2 + k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1 k8s.io/client-go v0.31.3 k8s.io/code-generator v0.31.3 k8s.io/component-base v0.31.3 diff --git a/multidimensional-pod-autoscaler/go.sum b/multidimensional-pod-autoscaler/go.sum index b6ea32ee6102..c5c8415ab4b1 100644 --- a/multidimensional-pod-autoscaler/go.sum +++ b/multidimensional-pod-autoscaler/go.sum @@ -301,8 +301,8 @@ k8s.io/apimachinery v0.31.3 h1:6l0WhcYgasZ/wk9ktLq5vLaoXJJr5ts6lkaQzgeYPq4= k8s.io/apimachinery v0.31.3/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/apiserver v0.31.3 h1:+1oHTtCB+OheqFEz375D0IlzHZ5VeQKX1KGXnx+TTuY= k8s.io/apiserver v0.31.3/go.mod h1:PrxVbebxrxQPFhJk4powDISIROkNMKHibTg9lTRQ0Qg= -k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2 h1:ENxmnVXLt8+iXhDA0PNFhXb1sgvbvnAc66sC34UGrTw= -k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2/go.mod h1:J2cNKnieE7r4bInjpQDBq93D50aD/CmspSi6xRUfKk4= +k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1 h1:t5t0Rsn4b7iQfiVlGdWSEnEx8pjrSM96Sn4Dvo1QH/Q= +k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1/go.mod h1:9ywHbt0kTrLyeNGgTNm7WEns34PmBMEr+9bDKTxW6wQ= k8s.io/client-go v0.31.3 h1:CAlZuM+PH2cm+86LOBemaJI/lQ5linJ6UFxKX/SoG+4= k8s.io/client-go v0.31.3/go.mod h1:2CgjPUTpv3fE5dNygAr2NcM8nhHzXvxB8KL5gYc3kJs= k8s.io/cloud-provider v0.31.3 h1:7C3CHQUUwnv/HWWVIaibZH06iPg663RYQ6C6Zy4FnO8= diff --git a/multidimensional-pod-autoscaler/pkg/admission-controller/main.go b/multidimensional-pod-autoscaler/pkg/admission-controller/main.go index fb2b6b2041ad..40b90a360c33 100644 --- a/multidimensional-pod-autoscaler/pkg/admission-controller/main.go +++ b/multidimensional-pod-autoscaler/pkg/admission-controller/main.go @@ -75,7 +75,7 @@ func main() { kube_flag.InitFlags() klog.V(1).Infof("Multi-dimensional Pod Autoscaler %s Admission Controller", common.MultidimPodAutoscalerVersion) - healthCheck := metrics.NewHealthCheck(time.Minute, false) + healthCheck := metrics.NewHealthCheck(time.Minute) metrics.Initialize(*address, healthCheck) metrics_admission.Register() diff --git a/multidimensional-pod-autoscaler/pkg/recommender/Dockerfile b/multidimensional-pod-autoscaler/pkg/recommender/Dockerfile index a31451c6c20e..3441cea0ea1d 100644 --- a/multidimensional-pod-autoscaler/pkg/recommender/Dockerfile +++ b/multidimensional-pod-autoscaler/pkg/recommender/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2024 The Kubernetes Authors. All rights reserved +# Copyright 2017 The Kubernetes Authors. All rights reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,11 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder + +ENV GOPATH=/gopath/ +ENV PATH=$GOPATH/bin:$PATH + +COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler +WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler + +ARG TARGETOS TARGETARCH + +RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/recommender -mod vendor -o recommender-$TARGETARCH + FROM gcr.io/distroless/static:latest -MAINTAINER Krzysztof Grygiel "kgrygiel@google.com" -ARG ARCH -COPY recommender-$ARCH /recommender +ARG TARGETARCH + +COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/recommender/recommender-$TARGETARCH /recommender ENTRYPOINT ["/recommender"] -CMD ["--v=4", "--stderrthreshold=info", "--prometheus-address=http://prometheus.monitoring.svc"] diff --git a/multidimensional-pod-autoscaler/pkg/recommender/Makefile b/multidimensional-pod-autoscaler/pkg/recommender/Makefile index ee5e74428462..ca3b61cf9d19 100644 --- a/multidimensional-pod-autoscaler/pkg/recommender/Makefile +++ b/multidimensional-pod-autoscaler/pkg/recommender/Makefile @@ -8,6 +8,8 @@ ENVVAR=CGO_ENABLED=0 $(TEST_ENVVAR) GOOS?=linux COMPONENT=recommender FULL_COMPONENT=mpa-${COMPONENT} +# localhost registries need --insecure for some docker commands. +INSECURE=$(subst localhost,--insecure,$(findstring localhost,$(REGISTRY))) ALL_ARCHITECTURES?=amd64 arm arm64 ppc64le s390x export DOCKER_CLI_EXPERIMENTAL=enabled @@ -19,13 +21,6 @@ build: clean build-binary: clean $(ENVVAR) GOOS=$(GOOS) go build -o ${COMPONENT} -.PHONY: build-binary-with-vendor -build-binary-with-vendor: $(addprefix build-binary-with-vendor-,$(ALL_ARCHITECTURES)) clean - -.PHONY: build-binary-with-vendor-* -build-binary-with-vendor-%: - $(ENVVAR) GOARCH=$* GOOS=$(GOOS) go build -mod vendor -o ${COMPONENT}-$* - test-unit: clean build $(TEST_ENVVAR) go test --test.short -race ./... $(FLAGS) @@ -33,7 +28,7 @@ test-unit: clean build docker-build: $(addprefix docker-build-,$(ALL_ARCHITECTURES)) .PHONY: docker-build-* -docker-build-%: +docker-build-%: ifndef REGISTRY ERR = $(error REGISTRY is undefined) $(ERR) @@ -42,13 +37,10 @@ ifndef TAG ERR = $(error TAG is undefined) $(ERR) endif - docker build --pull -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} --build-arg ARCH=$* . + docker buildx build --pull --load --platform linux/$* -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} -f ./Dockerfile ../../ .PHONY: docker-push -docker-push: $(addprefix sub-push-,$(ALL_ARCHITECTURES)) push-multi-arch; - -.PHONY: sub-push-* -sub-push-%: docker-build-% do-push-% ; +docker-push: $(addprefix do-push-,$(ALL_ARCHITECTURES)) push-multi-arch; .PHONY: do-push-* do-push-%: @@ -68,17 +60,24 @@ push-multi-arch: @for arch in $(ALL_ARCHITECTURES); do docker manifest annotate --arch $${arch} $(REGISTRY)/${FULL_COMPONENT}:$(TAG) $(REGISTRY)/${FULL_COMPONENT}-$${arch}:${TAG}; done docker manifest push --purge $(REGISTRY)/${FULL_COMPONENT}:$(TAG) -docker-builder: - docker build -t mpa-autoscaling-builder ../../builder +.PHONY: show-git-info +show-git-info: + echo '=============== local git status ===============' + git status + echo '=============== last commit ===============' + git log -1 + echo '=============== bulding from the above ===============' -.PHONY: build-in-docker -build-in-docker: $(addprefix build-in-docker-,$(ALL_ARCHITECTURES)) +.PHONY: create-buildx-builder +create-buildx-builder: + BUILDER=$(shell docker buildx create --driver=docker-container --use) -.PHONY: build-in-docker-* -build-in-docker-%: clean docker-builder - docker run -v `pwd`/../..:/gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler mpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler && make build-binary-with-vendor-$* -C pkg/recommender' +.PHONY: remove-buildx-builder +remove-buildx-builder: + docker buildx rm ${BUILDER} -release: build-in-docker docker-build docker-push +.PHONY: release +release: show-git-info create-buildx-builder docker-build remove-buildx-builder docker-push @echo "Full in-docker release ${FULL_COMPONENT}:${TAG} completed" clean: $(addprefix clean-,$(ALL_ARCHITECTURES)) diff --git a/multidimensional-pod-autoscaler/pkg/recommender/main.go b/multidimensional-pod-autoscaler/pkg/recommender/main.go index 27c6f868f1e9..501975e4b61b 100644 --- a/multidimensional-pod-autoscaler/pkg/recommender/main.go +++ b/multidimensional-pod-autoscaler/pkg/recommender/main.go @@ -119,7 +119,7 @@ func main() { vpa_model.InitializeAggregationsConfig(vpa_model.NewAggregationsConfig(*memoryAggregationInterval, *memoryAggregationIntervalCount, *memoryHistogramDecayHalfLife, *cpuHistogramDecayHalfLife, *oomBumpUpRatio, *oomMinBumpUp)) - healthCheck := metrics.NewHealthCheck(*metricsFetcherInterval*5, true) + healthCheck := metrics.NewHealthCheck(*metricsFetcherInterval * 5) metrics.Initialize(*address, healthCheck) metrics_recommender.Register() metrics_quality.Register() diff --git a/multidimensional-pod-autoscaler/pkg/updater/Dockerfile b/multidimensional-pod-autoscaler/pkg/updater/Dockerfile index 95cf4ec86237..d8703436bdc4 100644 --- a/multidimensional-pod-autoscaler/pkg/updater/Dockerfile +++ b/multidimensional-pod-autoscaler/pkg/updater/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2024 The Kubernetes Authors. All rights reserved +# Copyright 2016 The Kubernetes Authors. All rights reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,12 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder + +ENV GOPATH=/gopath/ +ENV PATH=$GOPATH/bin:$PATH + +COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler +WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler + +ARG TARGETOS TARGETARCH + +RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/updater -mod vendor -o updater-$TARGETARCH FROM gcr.io/distroless/static:latest -MAINTAINER Marcin Wielgus "mwielgus@google.com" -ARG ARCH -COPY updater-$ARCH /updater +ARG TARGETARCH + +COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/updater/updater-$TARGETARCH /updater ENTRYPOINT ["/updater"] -CMD ["--v=4", "--stderrthreshold=info"] diff --git a/multidimensional-pod-autoscaler/pkg/updater/Makefile b/multidimensional-pod-autoscaler/pkg/updater/Makefile index cfc5951029a4..648a6b6b881b 100644 --- a/multidimensional-pod-autoscaler/pkg/updater/Makefile +++ b/multidimensional-pod-autoscaler/pkg/updater/Makefile @@ -19,13 +19,6 @@ build: clean build-binary: clean $(ENVVAR) GOOS=$(GOOS) go build -o ${COMPONENT} -.PHONY: build-binary-with-vendor -build-binary-with-vendor: $(addprefix build-binary-with-vendor-,$(ALL_ARCHITECTURES)) clean - -.PHONY: build-binary-with-vendor-* -build-binary-with-vendor-%: - $(ENVVAR) GOARCH=$* GOOS=$(GOOS) go build -mod vendor -o ${COMPONENT}-$* - test-unit: clean build $(TEST_ENVVAR) go test --test.short -race ./... $(FLAGS) @@ -42,13 +35,10 @@ ifndef TAG ERR = $(error TAG is undefined) $(ERR) endif - docker build --pull -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} --build-arg ARCH=$* . + docker buildx build --pull --load --platform linux/$* -t ${REGISTRY}/${FULL_COMPONENT}-$*:${TAG} -f ./Dockerfile ../../ .PHONY: docker-push -docker-push: $(addprefix sub-push-,$(ALL_ARCHITECTURES)) push-multi-arch; - -.PHONY: sub-push-* -sub-push-%: docker-build-% do-push-% ; +docker-push: $(addprefix do-push-,$(ALL_ARCHITECTURES)) push-multi-arch; .PHONY: do-push-* do-push-%: @@ -68,18 +58,24 @@ push-multi-arch: @for arch in $(ALL_ARCHITECTURES); do docker manifest annotate --arch $${arch} $(REGISTRY)/${FULL_COMPONENT}:$(TAG) $(REGISTRY)/${FULL_COMPONENT}-$${arch}:${TAG}; done docker manifest push --purge $(REGISTRY)/${FULL_COMPONENT}:$(TAG) -docker-builder: - docker build -t vpa-autoscaling-builder ../../builder +.PHONY: show-git-info +show-git-info: + echo '=============== local git status ===============' + git status + echo '=============== last commit ===============' + git log -1 + echo '=============== bulding from the above ===============' -.PHONY: build-in-docker -build-in-docker: $(addprefix build-in-docker-,$(ALL_ARCHITECTURES)) +.PHONY: create-buildx-builder +create-buildx-builder: + BUILDER=$(shell docker buildx create --driver=docker-container --use) -.PHONY: build-in-docker-* -build-in-docker-%: clean docker-builder - docker run -v `pwd`/../..:/gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler vpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler && make build-binary-with-vendor-$* -C pkg/updater' +.PHONY: remove-buildx-builder +remove-buildx-builder: + docker buildx rm ${BUILDER} .PHONY: release -release: build-in-docker docker-build docker-push +release: show-git-info create-buildx-builder docker-build remove-buildx-builder docker-push @echo "Full in-docker release ${FULL_COMPONENT}:${TAG} completed" clean: $(addprefix clean-,$(ALL_ARCHITECTURES)) diff --git a/multidimensional-pod-autoscaler/pkg/updater/main.go b/multidimensional-pod-autoscaler/pkg/updater/main.go index 62616ed58dd3..afb8a68ad0b0 100644 --- a/multidimensional-pod-autoscaler/pkg/updater/main.go +++ b/multidimensional-pod-autoscaler/pkg/updater/main.go @@ -74,7 +74,7 @@ func main() { kube_flag.InitFlags() klog.V(1).Infof("Multidimensional Pod Autoscaler %s Updater", common.MultidimPodAutoscalerVersion) - healthCheck := metrics.NewHealthCheck(*updaterInterval*5, true) + healthCheck := metrics.NewHealthCheck(*updaterInterval * 5) metrics.Initialize(*address, healthCheck) metrics_updater.Register() diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go index 9cea0376dd91..732ebc2377ba 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/zz_generated.deepcopy.go @@ -76,6 +76,27 @@ func (in *ContainerResourcePolicy) DeepCopy() *ContainerResourcePolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EvictionRequirement) DeepCopyInto(out *EvictionRequirement) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]corev1.ResourceName, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EvictionRequirement. +func (in *EvictionRequirement) DeepCopy() *EvictionRequirement { + if in == nil { + return nil + } + out := new(EvictionRequirement) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HistogramCheckpoint) DeepCopyInto(out *HistogramCheckpoint) { *out = *in @@ -136,6 +157,17 @@ func (in *PodUpdatePolicy) DeepCopyInto(out *PodUpdatePolicy) { *out = new(int32) **out = **in } + if in.EvictionRequirements != nil { + in, out := &in.EvictionRequirements, &out.EvictionRequirements + *out = make([]*EvictionRequirement, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(EvictionRequirement) + (*in).DeepCopyInto(*out) + } + } + } return } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/clientset.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/clientset.go index 6ab4aa58f623..92551829156a 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/clientset.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ package versioned import ( "fmt" + "net/http" autoscalingv1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1" autoscalingv1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1" @@ -33,18 +34,17 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface AutoscalingV1() autoscalingv1.AutoscalingV1Interface - AutoscalingV1beta2() autoscalingv1beta2.AutoscalingV1beta2Interface AutoscalingV1beta1() autoscalingv1beta1.AutoscalingV1beta1Interface + AutoscalingV1beta2() autoscalingv1beta2.AutoscalingV1beta2Interface PocV1alpha1() pocv1alpha1.PocV1alpha1Interface } -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. +// Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient autoscalingV1 *autoscalingv1.AutoscalingV1Client - autoscalingV1beta2 *autoscalingv1beta2.AutoscalingV1beta2Client autoscalingV1beta1 *autoscalingv1beta1.AutoscalingV1beta1Client + autoscalingV1beta2 *autoscalingv1beta2.AutoscalingV1beta2Client pocV1alpha1 *pocv1alpha1.PocV1alpha1Client } @@ -53,16 +53,16 @@ func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface { return c.autoscalingV1 } -// AutoscalingV1beta2 retrieves the AutoscalingV1beta2Client -func (c *Clientset) AutoscalingV1beta2() autoscalingv1beta2.AutoscalingV1beta2Interface { - return c.autoscalingV1beta2 -} - // AutoscalingV1beta1 retrieves the AutoscalingV1beta1Client func (c *Clientset) AutoscalingV1beta1() autoscalingv1beta1.AutoscalingV1beta1Interface { return c.autoscalingV1beta1 } +// AutoscalingV1beta2 retrieves the AutoscalingV1beta2Client +func (c *Clientset) AutoscalingV1beta2() autoscalingv1beta2.AutoscalingV1beta2Interface { + return c.autoscalingV1beta2 +} + // PocV1alpha1 retrieves the PocV1alpha1Client func (c *Clientset) PocV1alpha1() pocv1alpha1.PocV1alpha1Interface { return c.pocV1alpha1 @@ -79,34 +79,57 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { // NewForConfig creates a new Clientset for the given config. // If config's RateLimiter is not set and QPS and Burst are acceptable, // NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.Burst <= 0 { return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } + var cs Clientset var err error - cs.autoscalingV1, err = autoscalingv1.NewForConfig(&configShallowCopy) + cs.autoscalingV1, err = autoscalingv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.autoscalingV1beta2, err = autoscalingv1beta2.NewForConfig(&configShallowCopy) + cs.autoscalingV1beta1, err = autoscalingv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.autoscalingV1beta1, err = autoscalingv1beta1.NewForConfig(&configShallowCopy) + cs.autoscalingV1beta2, err = autoscalingv1beta2.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.pocV1alpha1, err = pocv1alpha1.NewForConfig(&configShallowCopy) + cs.pocV1alpha1, err = pocv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -116,22 +139,19 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // NewForConfigOrDie creates a new Clientset for the given config and // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.autoscalingV1 = autoscalingv1.NewForConfigOrDie(c) - cs.autoscalingV1beta2 = autoscalingv1beta2.NewForConfigOrDie(c) - cs.autoscalingV1beta1 = autoscalingv1beta1.NewForConfigOrDie(c) - cs.pocV1alpha1 = pocv1alpha1.NewForConfigOrDie(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - return &cs + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs } // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset cs.autoscalingV1 = autoscalingv1.New(c) - cs.autoscalingV1beta2 = autoscalingv1beta2.New(c) cs.autoscalingV1beta1 = autoscalingv1beta1.New(c) + cs.autoscalingV1beta2 = autoscalingv1beta2.New(c) cs.pocV1alpha1 = pocv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/doc.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/doc.go deleted file mode 100644 index 41721ca52d44..000000000000 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package versioned diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme/register.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme/register.go index a312da294a8f..020b8f9ace1e 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme/register.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme/register.go @@ -35,8 +35,8 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ autoscalingv1.AddToScheme, - autoscalingv1beta2.AddToScheme, autoscalingv1beta1.AddToScheme, + autoscalingv1beta2.AddToScheme, pocv1alpha1.AddToScheme, } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/autoscaling.k8s.io_client.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/autoscaling.k8s.io_client.go index 9daaa3a232a9..451a5ffedfeb 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/autoscaling.k8s.io_client.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1/autoscaling.k8s.io_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1 import ( + "net/http" + v1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *AutoscalingV1Client) VerticalPodAutoscalerCheckpoints(namespace string) } // NewForConfig creates a new AutoscalingV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AutoscalingV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/autoscaling.k8s.io_client.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/autoscaling.k8s.io_client.go index 202cd4ab5cd4..d44a31e35d8c 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/autoscaling.k8s.io_client.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta1/autoscaling.k8s.io_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1beta1 import ( + "net/http" + v1beta1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta1" "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *AutoscalingV1beta1Client) VerticalPodAutoscalerCheckpoints(namespace st } // NewForConfig creates a new AutoscalingV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AutoscalingV1beta1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/autoscaling.k8s.io_client.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/autoscaling.k8s.io_client.go index 953e1ccb33ce..2da32d98452e 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/autoscaling.k8s.io_client.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1beta2/autoscaling.k8s.io_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1beta2 import ( + "net/http" + v1beta2 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1beta2" "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *AutoscalingV1beta2Client) VerticalPodAutoscalerCheckpoints(namespace st } // NewForConfig creates a new AutoscalingV1beta2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*AutoscalingV1beta2Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AutoscalingV1beta2Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AutoscalingV1beta2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/poc.autoscaling.k8s.io_client.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/poc.autoscaling.k8s.io_client.go index edca5872e17e..4bfabc671d64 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/poc.autoscaling.k8s.io_client.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/poc.autoscaling.k8s.io/v1alpha1/poc.autoscaling.k8s.io_client.go @@ -19,6 +19,8 @@ limitations under the License. package v1alpha1 import ( + "net/http" + v1alpha1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/poc.autoscaling.k8s.io/v1alpha1" "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" @@ -44,12 +46,28 @@ func (c *PocV1alpha1Client) VerticalPodAutoscalerCheckpoints(namespace string) V } // NewForConfig creates a new PocV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). func NewForConfig(c *rest.Config) (*PocV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err } - client, err := rest.RESTClientFor(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new PocV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*PocV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscaler.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscaler.go index fcfd735378a5..890e8bfe80f4 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscaler.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscaler.go @@ -26,8 +26,10 @@ import ( ) // VerticalPodAutoscalerLister helps list VerticalPodAutoscalers. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerLister interface { // List lists all VerticalPodAutoscalers in the indexer. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1.VerticalPodAutoscaler, err error) // VerticalPodAutoscalers returns an object that can list and get VerticalPodAutoscalers. VerticalPodAutoscalers(namespace string) VerticalPodAutoscalerNamespaceLister @@ -58,10 +60,13 @@ func (s *verticalPodAutoscalerLister) VerticalPodAutoscalers(namespace string) V } // VerticalPodAutoscalerNamespaceLister helps list and get VerticalPodAutoscalers. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerNamespaceLister interface { // List lists all VerticalPodAutoscalers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1.VerticalPodAutoscaler, err error) // Get retrieves the VerticalPodAutoscaler from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. Get(name string) (*v1.VerticalPodAutoscaler, error) VerticalPodAutoscalerNamespaceListerExpansion } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscalercheckpoint.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscalercheckpoint.go index 947a4760b9bf..1d840db3e26d 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/verticalpodautoscalercheckpoint.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1/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 []*v1.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 []*v1.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) (*v1.VerticalPodAutoscalerCheckpoint, error) VerticalPodAutoscalerCheckpointNamespaceListerExpansion } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscaler.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscaler.go index 1e7346ddfbf3..8d210396e1df 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscaler.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscaler.go @@ -26,8 +26,10 @@ import ( ) // VerticalPodAutoscalerLister helps list VerticalPodAutoscalers. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerLister interface { // List lists all VerticalPodAutoscalers in the indexer. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta1.VerticalPodAutoscaler, err error) // VerticalPodAutoscalers returns an object that can list and get VerticalPodAutoscalers. VerticalPodAutoscalers(namespace string) VerticalPodAutoscalerNamespaceLister @@ -58,10 +60,13 @@ func (s *verticalPodAutoscalerLister) VerticalPodAutoscalers(namespace string) V } // VerticalPodAutoscalerNamespaceLister helps list and get VerticalPodAutoscalers. +// All objects returned here must be treated as read-only. type VerticalPodAutoscalerNamespaceLister interface { // List lists all VerticalPodAutoscalers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta1.VerticalPodAutoscaler, err error) // Get retrieves the VerticalPodAutoscaler from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. Get(name string) (*v1beta1.VerticalPodAutoscaler, error) VerticalPodAutoscalerNamespaceListerExpansion } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscalercheckpoint.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscalercheckpoint.go index 7eba6bc926dd..87f3bc93e509 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/verticalpodautoscalercheckpoint.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1beta1/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 []*v1beta1.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 []*v1beta1.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) (*v1beta1.VerticalPodAutoscalerCheckpoint, error) VerticalPodAutoscalerCheckpointNamespaceListerExpansion } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics/metrics_source.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics/metrics_source.go index 04978268baf5..6f612a1c6f4a 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics/metrics_source.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics/metrics_source.go @@ -18,6 +18,8 @@ package metrics import ( "context" + "time" + k8sapiv1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -28,7 +30,6 @@ import ( "k8s.io/metrics/pkg/apis/metrics/v1beta1" resourceclient "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" "k8s.io/metrics/pkg/client/external_metrics" - "time" ) // PodMetricsLister wraps both metrics-client and External Metrics @@ -113,10 +114,10 @@ func (s *externalMetricsClient) List(ctx context.Context, namespace string, opts return nil, err } if m == nil || len(m.Items) == 0 { - klog.V(4).Infof("External Metrics Query for VPA %+v: resource %+v, metric %+v, No items,", vpa.ID, resourceName, metricName) + klog.V(4).Infof("External Metrics Query for VPA %s: resource %+v, metric %+v, No items,", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), resourceName, metricName) continue } - klog.V(4).Infof("External Metrics Query for VPA %+v: resource %+v, metric %+v, %d items, item[0]: %+v", vpa.ID, resourceName, metricName, len(m.Items), m.Items[0]) + klog.V(4).Infof("External Metrics Query for VPA %s: resource %+v, metric %+v, %d items, item[0]: %+v", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), resourceName, metricName, len(m.Items), m.Items[0]) podMets.Timestamp = m.Items[0].Timestamp if m.Items[0].WindowSeconds != nil { podMets.Window = v1.Duration{Duration: time.Duration(*m.Items[0].WindowSeconds) * time.Second} diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go index 9a7ad8e51be7..4afa93d69e7f 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go @@ -25,10 +25,15 @@ import ( ) var ( - safetyMarginFraction = flag.Float64("recommendation-margin-fraction", 0.15, `Fraction of usage added as the safety margin to the recommended request`) - podMinCPUMillicores = flag.Float64("pod-recommendation-min-cpu-millicores", 25, `Minimum CPU recommendation for a pod`) - podMinMemoryMb = flag.Float64("pod-recommendation-min-memory-mb", 250, `Minimum memory recommendation for a pod`) - targetCPUPercentile = flag.Float64("target-cpu-percentile", 0.9, "CPU usage percentile that will be used as a base for CPU target recommendation. Doesn't affect CPU lower bound, CPU upper bound nor memory recommendations.") + safetyMarginFraction = flag.Float64("recommendation-margin-fraction", 0.15, `Fraction of usage added as the safety margin to the recommended request`) + podMinCPUMillicores = flag.Float64("pod-recommendation-min-cpu-millicores", 25, `Minimum CPU recommendation for a pod`) + podMinMemoryMb = flag.Float64("pod-recommendation-min-memory-mb", 250, `Minimum memory recommendation for a pod`) + targetCPUPercentile = flag.Float64("target-cpu-percentile", 0.9, "CPU usage percentile that will be used as a base for CPU target recommendation. Doesn't affect CPU lower bound, CPU upper bound nor memory recommendations.") + lowerBoundCPUPercentile = flag.Float64("recommendation-lower-bound-cpu-percentile", 0.5, `CPU usage percentile that will be used for the lower bound on CPU recommendation.`) + upperBoundCPUPercentile = flag.Float64("recommendation-upper-bound-cpu-percentile", 0.95, `CPU usage percentile that will be used for the upper bound on CPU recommendation.`) + targetMemoryPercentile = flag.Float64("target-memory-percentile", 0.9, "Memory usage percentile that will be used as a base for memory target recommendation. Doesn't affect memory lower bound nor memory upper bound.") + lowerBoundMemoryPercentile = flag.Float64("recommendation-lower-bound-memory-percentile", 0.5, `Memory usage percentile that will be used for the lower bound on memory recommendation.`) + upperBoundMemoryPercentile = flag.Float64("recommendation-upper-bound-memory-percentile", 0.95, `Memory usage percentile that will be used for the upper bound on memory recommendation.`) ) // PodResourceRecommender computes resource recommendation for a Vpa object. @@ -102,16 +107,9 @@ func FilterControlledResources(estimation model.Resources, controlledResources [ // CreatePodResourceRecommender returns the primary recommender. func CreatePodResourceRecommender() PodResourceRecommender { - lowerBoundCPUPercentile := 0.5 - upperBoundCPUPercentile := 0.95 - - targetMemoryPeaksPercentile := 0.9 - lowerBoundMemoryPeaksPercentile := 0.5 - upperBoundMemoryPeaksPercentile := 0.95 - - targetEstimator := NewPercentileEstimator(*targetCPUPercentile, targetMemoryPeaksPercentile) - lowerBoundEstimator := NewPercentileEstimator(lowerBoundCPUPercentile, lowerBoundMemoryPeaksPercentile) - upperBoundEstimator := NewPercentileEstimator(upperBoundCPUPercentile, upperBoundMemoryPeaksPercentile) + targetEstimator := NewPercentileEstimator(*targetCPUPercentile, *targetMemoryPercentile) + lowerBoundEstimator := NewPercentileEstimator(*lowerBoundCPUPercentile, *lowerBoundMemoryPercentile) + upperBoundEstimator := NewPercentileEstimator(*upperBoundCPUPercentile, *upperBoundMemoryPercentile) targetEstimator = WithMargin(*safetyMarginFraction, targetEstimator) lowerBoundEstimator = WithMargin(*safetyMarginFraction, lowerBoundEstimator) diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/cluster.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/cluster.go index 2e6f1bd2017a..b9912b946ed5 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/cluster.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/cluster.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog/v2" vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" - "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/target/controller_fetcher" + controllerfetcher "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/target/controller_fetcher" vpa_utils "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/vpa" ) @@ -329,7 +329,7 @@ func (cluster *ClusterState) MakeAggregateStateKey(pod *PodState, containerName func (cluster *ClusterState) aggregateStateKeyForContainerID(containerID ContainerID) AggregateStateKey { pod, podExists := cluster.Pods[containerID.PodID] if !podExists { - panic(fmt.Sprintf("Pod not present in the ClusterState: %v", containerID.PodID)) + panic(fmt.Sprintf("Pod not present in the ClusterState: %s/%s", containerID.PodID.Namespace, containerID.PodID.PodName)) } return cluster.MakeAggregateStateKey(pod, containerID.ContainerName) } @@ -385,7 +385,7 @@ func (cluster *ClusterState) garbageCollectAggregateCollectionStates(now time.Ti } // RateLimitedGarbageCollectAggregateCollectionStates removes obsolete AggregateCollectionStates from the ClusterState. -// It performs clean up only if more than `gcInterval` passed since the last time it performed a clean up. +// It performs clean up only if more than `gcInterval` passed since the last time it performed a cleanup. // AggregateCollectionState is obsolete in following situations: // 1) It has no samples and there are no more contributive pods - a pod is contributive in any of following situations: // @@ -433,7 +433,7 @@ func (cluster *ClusterState) RecordRecommendation(vpa *Vpa, now time.Time) error } else { if lastLogged.Add(RecommendationMissingMaxDuration).Before(now) { cluster.EmptyVPAs[vpa.ID] = now - return fmt.Errorf("VPA %v/%v is missing recommendation for more than %v", vpa.ID.Namespace, vpa.ID.VpaName, RecommendationMissingMaxDuration) + return fmt.Errorf("VPA %s/%s is missing recommendation for more than %v", vpa.ID.Namespace, vpa.ID.VpaName, RecommendationMissingMaxDuration) } } return nil @@ -491,7 +491,7 @@ type aggregateStateKey struct { labelSetMap *labelSetMap } -// Labels returns the namespace for the aggregateStateKey. +// Namespace returns the namespace for the aggregateStateKey. func (k aggregateStateKey) Namespace() string { return k.namespace } diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/vpa.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/vpa.go index 4a97c4c5ba2b..b4f32e07f8c1 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/vpa.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model/vpa.go @@ -282,7 +282,7 @@ func (vpa *Vpa) AsStatus() *vpa_types.VerticalPodAutoscalerStatus { return status } -// HasMatchedPods returns true if there are are currently active pods in the +// HasMatchedPods returns true if there are currently active pods in the // cluster matching this VPA, based on conditions. UpdateConditions should be // called first. func (vpa *Vpa) HasMatchedPods() bool { diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/util/histogram.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/util/histogram.go index 016a3d659bb1..cd0d360d0f4b 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/util/histogram.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/util/histogram.go @@ -248,10 +248,10 @@ func (h *histogram) SaveToChekpoint() (*vpa_types.HistogramCheckpoint, error) { func (h *histogram) LoadFromCheckpoint(checkpoint *vpa_types.HistogramCheckpoint) error { if checkpoint == nil { - return fmt.Errorf("Cannot load from empty checkpoint") + return fmt.Errorf("cannot load from empty checkpoint") } if checkpoint.TotalWeight < 0.0 { - return fmt.Errorf("Cannot load checkpoint with negative weight %v", checkpoint.TotalWeight) + return fmt.Errorf("cannot load checkpoint with negative weight %v", checkpoint.TotalWeight) } sum := int64(0) for bucket, weight := range checkpoint.BucketWeights { diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/healthcheck.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/healthcheck.go index 78417dc13789..44003603a63c 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/healthcheck.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/healthcheck.go @@ -35,15 +35,24 @@ type HealthCheck struct { } // NewHealthCheck builds new HealthCheck object with given timeout. -func NewHealthCheck(activityTimeout time.Duration, checkTimeout bool) *HealthCheck { +func NewHealthCheck(activityTimeout time.Duration) *HealthCheck { return &HealthCheck{ activityTimeout: activityTimeout, - checkTimeout: checkTimeout, + checkTimeout: false, lastActivity: time.Now(), mutex: &sync.Mutex{}, } } +// StartMonitoring activates checks for the component inactivity. +func (hc *HealthCheck) StartMonitoring() { + hc.mutex.Lock() + defer hc.mutex.Unlock() + + hc.checkTimeout = true + hc.lastActivity = time.Now() +} + // checkLastActivity returns true if the last activity was too long ago, with duration from it. func (hc *HealthCheck) checkLastActivity() (bool, time.Duration) { hc.mutex.Lock() diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object.go index 8277db362006..232da4964b50 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/status/status_object.go @@ -37,7 +37,7 @@ const ( AdmissionControllerStatusName = "vpa-admission-controller" // AdmissionControllerStatusNamespace is the namespace of // the Admission Controller status object. - AdmissionControllerStatusNamespace = "kube-system" + AdmissionControllerStatusNamespace = metav1.NamespaceSystem // AdmissionControllerStatusTimeout is a time after which // if not updated the Admission Controller status is no longer valid. AdmissionControllerStatusTimeout = 1 * time.Minute diff --git a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/vpa/api.go b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/vpa/api.go index 529d76961727..42fa0bb54d27 100644 --- a/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/vpa/api.go +++ b/multidimensional-pod-autoscaler/vendor/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/vpa/api.go @@ -150,7 +150,7 @@ func GetControllingVPAForPod(pod *core.Pod, vpas []*VpaWithSelector, ctrlFetcher } parentController, err := ctrlFetcher.FindTopMostWellKnownOrScalable(k) if err != nil { - klog.Errorf("fail to get pod controller: pod=%s err=%s", pod.Name, err.Error()) + klog.Errorf("fail to get pod controller: pod=%s err=%s", klog.KObj(pod), err.Error()) return nil } if parentController == nil { @@ -231,7 +231,7 @@ func CreateOrUpdateVpaCheckpoint(vpaCheckpointClient vpa_api.VerticalPodAutoscal _, err = vpaCheckpointClient.Create(context.TODO(), vpaCheckpoint, meta.CreateOptions{}) } if err != nil { - return fmt.Errorf("Cannot save checkpoint for vpa %v container %v. Reason: %+v", vpaCheckpoint.ObjectMeta.Name, vpaCheckpoint.Spec.ContainerName, err) + return fmt.Errorf("Cannot save checkpoint for vpa %s/%s container %s. Reason: %+v", vpaCheckpoint.Namespace, vpaCheckpoint.Name, vpaCheckpoint.Spec.ContainerName, err) } return nil } diff --git a/multidimensional-pod-autoscaler/vendor/modules.txt b/multidimensional-pod-autoscaler/vendor/modules.txt index 08d4674308ae..2a1227a877ae 100644 --- a/multidimensional-pod-autoscaler/vendor/modules.txt +++ b/multidimensional-pod-autoscaler/vendor/modules.txt @@ -804,7 +804,7 @@ k8s.io/apiserver/plugin/pkg/audit/webhook k8s.io/apiserver/plugin/pkg/authenticator/token/webhook k8s.io/apiserver/plugin/pkg/authorizer/webhook k8s.io/apiserver/plugin/pkg/authorizer/webhook/metrics -# k8s.io/autoscaler/vertical-pod-autoscaler v1.1.2 +# k8s.io/autoscaler/vertical-pod-autoscaler v1.2.1 ## explicit; go 1.21 k8s.io/autoscaler/vertical-pod-autoscaler/pkg/admission-controller/resource k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1