Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CONTINT-4412] Upgrade k8s dependencies #221

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1-1.21",
"image": "mcr.microsoft.com/devcontainers/go:1-1.22",
"features": {
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
"ghcr.io/devcontainers-contrib/features/kubectx-kubens": {},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build
env:
GO_VERSION: 1.21
GO_VERSION: 1.22
on:
push:
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "CodeQL"
env:
GO_VERSION: 1.21
GO_VERSION: 1.22
on:
push:
branches: [main]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Release
env:
GO_VERSION: 1.21
GO_VERSION: 1.22
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]
env:
GO111MODULE: "on"
PROJECTNAME: "watermarkpodautoscaler"
GO_VERSION: 1.21
GO_VERSION: 1.22
jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
image: registry.ddbuild.io/images/mirror/golang:1.21
image: registry.ddbuild.io/images/mirror/golang:1.22
variables:
GO111MODULE: "on"
PROJECTNAME: "watermarkpodautoscaler"
Expand Down
27 changes: 13 additions & 14 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[linters-settings]

[linters-settings.govet]
check-shadowing = true
enable = [
"shadow"
]

[linters-settings.gocyclo]
min-complexity = 12.0
Expand All @@ -20,19 +22,22 @@
[linters-settings.misspell]
locale = "US"

[linters-settings.errcheck]
exclude-functions = [
"fmt.Fprint",
"fmt.Fprintf"
]

[linters]
enable-all = true
disable = [
"exhaustruct",
"nosnakecase",
"logrlint",
"loggercheck",
"nonamedreturns",
"maligned",
"revive",
"lll",
"gas",
"gosec",
"dupl",
"scopelint",
"gocyclo",
"gochecknoinits",
"gochecknoglobals",
Expand All @@ -41,16 +46,14 @@
"cyclop",
"gomnd",
"wrapcheck",
"exhaustivestruct",
"forcetypeassert",
"goerr113",
"err113",
"testpackage",
"wastedassign",
"thelper",
"paralleltest",
"nestif",
"exhaustive",
"interfacer",
"gci",
"wsl",
"godox",
Expand All @@ -63,20 +66,16 @@
"nilnil",
"ireturn",
"maintidx",
"ifshort",
"gocritic",
"errchkjson",
"gofumpt",
"golint",
"gomoddirectives",
"prealloc",
"structcheck",
"deadcode",
"varcheck",
"rowserrcheck",
"sqlclosecheck",
"depguard",
"perfsprint",
"mnd",
]

[issues]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.21 as builder
FROM golang:1.22 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
43 changes: 13 additions & 30 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
@@ -1,69 +1,52 @@
Component,Origin,License
core,cloud.google.com/go/compute/metadata,Apache-2.0
core,github.com/Azure/go-autorest/autorest,Apache-2.0
core,github.com/Azure/go-autorest/autorest/adal,Apache-2.0
core,github.com/Azure/go-autorest/autorest/date,Apache-2.0
core,github.com/Azure/go-autorest/logger,Apache-2.0
core,github.com/Azure/go-autorest/tracing,Apache-2.0
core,github.com/DataDog/appsec-internal-go,Apache-2.0
core,github.com/DataDog/datadog-agent/pkg/remoteconfig/state,Apache-2.0
core,github.com/DataDog/datadog-api-client-go/v2,Apache-2.0
core,github.com/DataDog/datadog-go/v5/statsd,MIT
core,github.com/DataDog/datadog-operator,Apache-2.0
core,github.com/DataDog/extendeddaemonset/api/v1alpha1,Apache-2.0
core,github.com/DataDog/go-libddwaf/v2,Apache-2.0
core,github.com/DataDog/go-tuf,BSD-3-Clause
core,github.com/DataDog/datadog-operator/api/datadoghq,Apache-2.0
core,github.com/DataDog/gostackparse,Apache-2.0
core,github.com/DataDog/watermarkpodautoscaler,Apache-2.0
core,github.com/DataDog/watermarkpodautoscaler/third_party/kubernetes/pkg/controller/podautoscaler/metrics,Apache-2.0
core,github.com/Masterminds/semver/v3,MIT
core,github.com/PuerkitoBio/purell,BSD-3-Clause
core,github.com/PuerkitoBio/urlesc,BSD-3-Clause
core,github.com/DataDog/zstd,BSD-3-Clause
core,github.com/beorn7/perks/quantile,MIT
core,github.com/cespare/xxhash/v2,MIT
core,github.com/davecgh/go-spew/spew,ISC
core,github.com/ebitengine/purego,Apache-2.0
core,github.com/emicklei/go-restful,MIT
core,github.com/evanphx/json-patch,BSD-3-Clause
core,github.com/emicklei/go-restful/v3,MIT
core,github.com/evanphx/json-patch/v5,BSD-3-Clause
core,github.com/fsnotify/fsnotify,BSD-3-Clause
core,github.com/fxamacker/cbor/v2,MIT
core,github.com/go-logr/logr,Apache-2.0
core,github.com/go-logr/zapr,Apache-2.0
core,github.com/go-openapi/jsonpointer,Apache-2.0
core,github.com/go-openapi/jsonreference,Apache-2.0
core,github.com/go-openapi/swag,Apache-2.0
core,github.com/gogo/protobuf,BSD-3-Clause
core,github.com/golang-jwt/jwt/v4,MIT
core,github.com/golang/groupcache/lru,Apache-2.0
core,github.com/golang/protobuf,BSD-3-Clause
core,github.com/google/gnostic-models,Apache-2.0
core,github.com/google/go-cmp/cmp,BSD-3-Clause
core,github.com/google/gofuzz,Apache-2.0
core,github.com/google/pprof/profile,Apache-2.0
core,github.com/google/uuid,BSD-3-Clause
core,github.com/googleapis/gnostic,Apache-2.0
core,github.com/hashicorp/errwrap,MPL-2.0
core,github.com/hashicorp/go-multierror,MPL-2.0
core,github.com/imdario/mergo,BSD-3-Clause
core,github.com/josharian/intern,MIT
core,github.com/json-iterator/go,MIT
core,github.com/mailru/easyjson,MIT
core,github.com/matttproud/golang_protobuf_extensions/pbutil,Apache-2.0
core,github.com/modern-go/concurrent,Apache-2.0
core,github.com/modern-go/reflect2,Apache-2.0
core,github.com/munnerz/goautoneg,BSD-3-Clause
core,github.com/pkg/errors,BSD-2-Clause
core,github.com/prometheus/client_golang/prometheus,Apache-2.0
core,github.com/prometheus/client_model/go,Apache-2.0
core,github.com/prometheus/common,Apache-2.0
core,github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg,BSD-3-Clause
core,github.com/prometheus/procfs,Apache-2.0
core,github.com/richardartoul/molecule,MIT
core,github.com/richardartoul/molecule/src/codec,Apache-2.0
core,github.com/richardartoul/molecule/src/protowire,BSD-3-Clause
core,github.com/secure-systems-lab/go-securesystemslib/cjson,MIT
core,github.com/spaolacci/murmur3,BSD-3-Clause
core,github.com/spf13/pflag,BSD-3-Clause
core,go.uber.org/atomic,MIT
core,github.com/x448/float16,MIT
core,go.uber.org/multierr,MIT
core,go.uber.org/zap,MIT
core,golang.org/x/crypto/pkcs12,BSD-3-Clause
core,golang.org/x/exp/maps,BSD-3-Clause
core,golang.org/x/net,BSD-3-Clause
core,golang.org/x/oauth2,BSD-3-Clause
core,golang.org/x/sys/unix,BSD-3-Clause
Expand All @@ -82,17 +65,17 @@ core,k8s.io/apimachinery/pkg,Apache-2.0
core,k8s.io/apimachinery/third_party/forked/golang,BSD-3-Clause
core,k8s.io/apiserver/pkg/authentication,Apache-2.0
core,k8s.io/client-go,Apache-2.0
core,k8s.io/client-go/third_party/forked/golang/template,BSD-3-Clause
core,k8s.io/component-base/config,Apache-2.0
core,k8s.io/controller-manager/pkg/clientbuilder,Apache-2.0
core,k8s.io/heapster/metrics/api/v1/types,Apache-2.0
core,k8s.io/klog/v2,Apache-2.0
core,k8s.io/kube-openapi/pkg,Apache-2.0
core,k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json,BSD-3-Clause
core,k8s.io/kube-openapi/pkg/validation/spec,Apache-2.0
core,k8s.io/metrics/pkg,Apache-2.0
core,k8s.io/utils,Apache-2.0
core,k8s.io/utils/internal/third_party/forked/golang/net,BSD-3-Clause
core,sigs.k8s.io/controller-runtime,Apache-2.0
core,sigs.k8s.io/json,Apache-2.0
core,sigs.k8s.io/structured-merge-diff/v4,Apache-2.0
core,sigs.k8s.io/yaml,MIT
core,sigs.k8s.io/yaml,Apache-2.0
core,sigs.k8s.io/yaml/goyaml.v2,Apache-2.0
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUILDINFOPKG=github.com/DataDog/watermarkpodautoscaler/pkg/version
GIT_TAG?=$(shell git tag -l --contains HEAD | tail -1)
TAG_HASH=$(shell git tag | tail -1)_$(shell git rev-parse --short HEAD)
TAG_HASH=$(shell git tag | tail -1)-$(shell git rev-parse --short HEAD)
GIT_VERSION?=$(if $(GIT_TAG),$(GIT_TAG),$(TAG_HASH))
VERSION?=$(GIT_VERSION:v%=%)
IMG_VERSION?=$(if $(VERSION),$(VERSION),latest)
Expand All @@ -20,7 +20,7 @@ GOARCH?=amd64
IMG_NAME=gcr.io/datadoghq/watermarkpodautoscaler
RELEASE_IMAGE_TAG := $(if $(CI_COMMIT_TAG),--tag $(RELEASE_IMAGE),)

CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd"

# Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION)
Expand Down Expand Up @@ -95,8 +95,8 @@ undeploy: $(KUSTOMIZE) ## Undeploy controller from the K8s cluster specified in
manifests: generate-manifests patch-crds

generate-manifests: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1 rbac:roleName=manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1beta1 rbac:roleName=manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1beta1
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1beta1

# Run go fmt against code
fmt:
Expand Down Expand Up @@ -126,7 +126,7 @@ docker-buildx-ci:
##@ Tools
CONTROLLER_GEN = bin/$(PLATFORM)/controller-gen
$(CONTROLLER_GEN): Makefile ## Download controller-gen locally if necessary.
$(call go-get-tool,$@,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
$(call go-get-tool,$@,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.3)

KUSTOMIZE = bin/$(PLATFORM)/kustomize
$(KUSTOMIZE): Makefile ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -183,7 +183,7 @@ install-tools: bin/$(PLATFORM)/golangci-lint bin/$(PLATFORM)/operator-sdk bin/$(

.PHONY: generate-openapi
generate-openapi: bin/$(PLATFORM)/openapi-gen
bin/$(PLATFORM)/openapi-gen --logtostderr=true -o "" -i ./apis/datadoghq/v1alpha1 -O zz_generated.openapi -p ./apis/datadoghq/v1alpha1 -h ./hack/boilerplate.go.txt -r "-"
bin/$(PLATFORM)/openapi-gen --logtostderr --output-dir apis/datadoghq/v1alpha1 --output-file zz_generated.openapi.go --output-pkg apis/datadoghq/v1alpha1 --go-header-file ./hack/boilerplate.go.txt

.PHONY: patch-crds
patch-crds: bin/$(PLATFORM)/yq
Expand Down Expand Up @@ -214,7 +214,7 @@ bin/$(PLATFORM)/jq: Makefile
hack/install-jq.sh "bin/$(PLATFORM)" 1.7.1

bin/$(PLATFORM)/golangci-lint: Makefile
hack/install-golangci-lint.sh -b "bin/$(PLATFORM)" v1.56.0
hack/install-golangci-lint.sh -b "bin/$(PLATFORM)" v1.61.0

bin/$(PLATFORM)/operator-sdk: Makefile
hack/install-operator-sdk.sh v1.23.0
Expand Down
24 changes: 8 additions & 16 deletions apis/datadoghq/v1alpha1/watermarkpodautoscaler_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ func IsDefaultWatermarkPodAutoscaler(wpa *WatermarkPodAutoscaler) bool {
// return nil if valid, else an error
func CheckWPAValidity(wpa *WatermarkPodAutoscaler) error {
if wpa.Spec.ScaleTargetRef.Kind == "" || wpa.Spec.ScaleTargetRef.Name == "" {
msg := fmt.Sprintf("the Spec.ScaleTargetRef should be populated, currently Kind:%s and/or Name:%s are not set properly", wpa.Spec.ScaleTargetRef.Kind, wpa.Spec.ScaleTargetRef.Name)
return fmt.Errorf(msg)
return fmt.Errorf("the Spec.ScaleTargetRef should be populated, currently Kind:%s and/or Name:%s are not set properly", wpa.Spec.ScaleTargetRef.Kind, wpa.Spec.ScaleTargetRef.Name)
}
if wpa.Spec.MinReplicas == nil || wpa.Spec.MaxReplicas < *wpa.Spec.MinReplicas {
msg := "watermark pod autoscaler requires the minimum number of replicas to be configured and inferior to the maximum"
return fmt.Errorf(msg)
return fmt.Errorf("watermark pod autoscaler requires the minimum number of replicas to be configured and inferior to the maximum")
}
if wpa.Spec.Tolerance.MilliValue() > 1000 || wpa.Spec.Tolerance.MilliValue() < 0 {
return fmt.Errorf("tolerance should be set as a quantity between 0 and 1, currently set to : %v, which is %.0f%%", wpa.Spec.Tolerance.String(), float64(wpa.Spec.Tolerance.MilliValue())/10)
Expand Down Expand Up @@ -120,35 +118,29 @@ func checkWPAMetricsValidity(wpa *WatermarkPodAutoscaler) (err error) {
return fmt.Errorf("metric.External is nil while metric.Type is '%s'", metric.Type)
}
if metric.External.LowWatermark == nil && metric.External.HighWatermark == nil {
msg := fmt.Sprintf("Watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
return fmt.Errorf(msg)
return fmt.Errorf("watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
}
if metric.External.MetricSelector == nil {
msg := fmt.Sprintf("Missing Labels for the External metric %s", metric.External.MetricName)
return fmt.Errorf(msg)
return fmt.Errorf("missing Labels for the External metric %s", metric.External.MetricName)
}
if metric.External.LowWatermark != nil && metric.External.HighWatermark != nil {
if metric.External.HighWatermark.MilliValue() < metric.External.LowWatermark.MilliValue() {
msg := fmt.Sprintf("Low WaterMark of External metric %s{%s} has to be strictly inferior to the High Watermark", metric.External.MetricName, metric.External.MetricSelector.MatchLabels)
return fmt.Errorf(msg)
return fmt.Errorf("low WaterMark of External metric %s{%s} has to be strictly inferior to the High Watermark", metric.External.MetricName, metric.External.MetricSelector.MatchLabels)
}
}
case ResourceMetricSourceType:
if metric.Resource == nil {
return fmt.Errorf("metric.Resource is nil while metric.Type is '%s'", metric.Type)
}
if metric.Resource.LowWatermark == nil && metric.Resource.HighWatermark == nil {
msg := fmt.Sprintf("Watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
return fmt.Errorf(msg)
return fmt.Errorf("watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
}
if metric.Resource.MetricSelector == nil {
msg := fmt.Sprintf("Missing Labels for the Resource metric %s", metric.Resource.Name)
return fmt.Errorf(msg)
return fmt.Errorf("missing Labels for the Resource metric %s", metric.Resource.Name)
}
if metric.Resource.LowWatermark != nil && metric.Resource.HighWatermark != nil {
if metric.Resource.HighWatermark.MilliValue() < metric.Resource.LowWatermark.MilliValue() {
msg := fmt.Sprintf("Low WaterMark of Resource metric %s{%s} has to be strictly inferior to the High Watermark", metric.Resource.Name, metric.Resource.MetricSelector.MatchLabels)
return fmt.Errorf(msg)
return fmt.Errorf("low WaterMark of Resource metric %s{%s} has to be strictly inferior to the High Watermark", metric.Resource.Name, metric.Resource.MetricSelector.MatchLabels)
}
}
default:
Expand Down
1 change: 0 additions & 1 deletion apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading