Skip to content

Commit

Permalink
Update go version to 1.23 (#127)
Browse files Browse the repository at this point in the history
* update go version to 1.23

* upgrade golangci-lint to 1.60.1, resolve make check errors
  • Loading branch information
rishabh-11 authored Nov 27, 2024
1 parent e54d69f commit 7d9127d
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 69 deletions.
6 changes: 3 additions & 3 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ dependency-watchdog:
dockerfile: 'Dockerfile'
steps:
check:
image: 'golang:1.22.2'
image: 'golang:1.23.3'
test-unit:
image: 'golang:1.22.2'
image: 'golang:1.23.3'
build:
image: 'golang:1.22.2'
image: 'golang:1.23.3'
output_dir: 'binary'
jobs:
head-update:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.2 AS builder
FROM golang:1.23.3 AS builder

WORKDIR /go/src/github.com/gardener/dependency-watchdog
COPY . .
Expand Down
1 change: 1 addition & 0 deletions cmd/.import-restrictions
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rules:
- selectorRegexp: github[.]com/gardener
allowedPrefixes:
- github.com/gardener/gardener/pkg/apis
- github.com/gardener/machine-controller-manager/pkg/apis
- selectorRegexp: github[.]com/gardener/dependency-watchdog
allowedPrefixes:
# should be self-contained and must not import any other dependency watchdog packages
Expand Down
2 changes: 1 addition & 1 deletion controllers/cluster/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func testProberSharedEnvTest(t *testing.T) {
}

for _, test := range tests {
t.Run(test.title, func(t *testing.T) {
t.Run(test.title, func(_ *testing.T) {
test.run(g, crClient, reconciler)
})
deleteAllClusters(g, crClient)
Expand Down
4 changes: 2 additions & 2 deletions controllers/endpoint/endpointpredicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ReadyEndpoints(logger logr.Logger) predicate.Predicate {
return false
},

DeleteFunc: func(event event.DeleteEvent) bool {
DeleteFunc: func(_ event.DeleteEvent) bool {
return false
},

Expand Down Expand Up @@ -77,7 +77,7 @@ func MatchingEndpoints(epMap map[string]wapi.DependantSelectors) predicate.Predi
return isMatchingEndpoints(event.ObjectNew, epMap)
},

DeleteFunc: func(event event.DeleteEvent) bool {
DeleteFunc: func(_ event.DeleteEvent) bool {
return false
},

Expand Down
4 changes: 2 additions & 2 deletions controllers/endpoint/endpointpredicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestReadyEndpoints(t *testing.T) {
}

for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
createEv := event.CreateEvent{
Object: tc.ep,
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestMatchingEndpointsPredicate(t *testing.T) {
}

for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
createEv := event.CreateEvent{
Object: tc.ep,
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/endpoint/endpoints_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func testWeederSharedEnvTest(t *testing.T) {
childCtx, chileCancelFn := context.WithCancel(ctx)
testNs := rand.String(4)
testutil.CreateTestNamespace(childCtx, g, reconciler.Client, testNs)
t.Run(test.description, func(t *testing.T) {
t.Run(test.description, func(_ *testing.T) {
test.run(childCtx, chileCancelFn, g, reconciler, testNs)
})
deleteAllPods(childCtx, g, reconciler.Client)
Expand All @@ -154,7 +154,7 @@ func testWeederDedicatedEnvTest(t *testing.T) {
testEnv, reconciler := setupWeederEnv(ctx, t, test.apiServerFlags)
testNs := rand.String(4)
testutil.CreateTestNamespace(ctx, g, reconciler.Client, testNs)
t.Run(test.description, func(t *testing.T) {
t.Run(test.description, func(_ *testing.T) {
test.run(ctx, cancelFn, g, reconciler, testNs)
})
testutil.TeardownEnv(g, testEnv, cancelFn)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gardener/dependency-watchdog

go 1.22.0
go 1.23.0

require (
github.com/gardener/gardener v1.99.1
Expand Down
8 changes: 4 additions & 4 deletions hack/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
GOTESTFMT := $(TOOLS_BIN_DIR)/gotestfmt

#default tool versions
GOLANGCI_LINT_VERSION ?= v1.55.2
GOLANGCI_LINT_VERSION ?= v1.60.1
GO_VULN_CHECK_VERSION ?= latest
GOIMPORTS_VERSION ?= latest
LOGCHECK_VERSION ?= cee120166b7b8a857dea90fc0217d86c2e41850f # this commit hash corresponds to v1.86.0 which is the gardener/gardener version in go.mod - we could use regular tags when https://github.com/gardener/gardener/issues/8811 is resolved
LOGCHECK_VERSION ?= d8145718cbe49d7ea453091f7836804455afe56d # this commit hash corresponds to v1.99.1 which is the gardener/gardener version in go.mod - we could use regular tags when https://github.com/gardener/gardener/issues/8811 is resolved
GO_ADD_LICENSE_VERSION ?= latest
# import boss failing with latest , so pinning to most up-to-date successfull version
# refer https://pkg.go.dev/k8s.io/code-generator@v0.26.3/cmd/import-boss?tab=versions for list of versions
GO_IMPORT_BOSS_VERSION ?= v0.28.4
# refer https://pkg.go.dev/k8s.io/code-generator@v0.29.6/cmd/import-boss?tab=versions for list of versions
GO_IMPORT_BOSS_VERSION ?= v0.28.4
GO_STRESS_VERSION ?= latest
SETUP_ENVTEST_VERSION ?= latest
GOTESTFMT_VERSION ?= v2.5.0
Expand Down
58 changes: 7 additions & 51 deletions internal/docs/e2e-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- [DWD prober](#dwd-prober)
- [Setup](#setup)
- [Shooted-Seed](#shooted-seed)
- [Secret changes](#secret-changes)
- [Prober Config](#prober-config)
- [End-To-End Tests](#end-to-end-tests)
- [Weeder e2e tests](#weeder-e2e-tests)
Expand All @@ -17,64 +16,21 @@
To run these tests against a DEV cluster the following setup is required.

#### Shooted-Seed

* Checkout the latest release of the [gardener](https://github.com/gardener/gardener) repository. Update the DWD image in the
`imagevector/images.yaml` file to the DWD image you want to test.
* Create a `shooted seed` setup by following running the script
at [Gardener-Extensions-Setup](https://github.tools.sap/kubernetes/onboarding/blob/master/setup/localsetup/hacks/local-setup-extensions.sh)
and deploy a local shoot in the shooted seed.(Use latest gardener version if possible)
* After the shoot is deployed, `annotate` the `managed resource` for DWD prober present in the `garden` namespace of the
seed worker plane with the following:
and deploy a local shoot in the shooted seed.
* If you want to update the DWD image after the setup is done, you can do so by changing the image in the `imagevector/images.yaml`
file in the cloned gardener repo and running `make gardener-extensions-up`.
* Another way to update the DWD image after the setup is done is to `annotate` the `managed resource` for DWD prober present in the `garden` namespace of the
seed worker plane with the following and then updating the deployment with the new image:

```bash
# This is required to ensure that `Dependency watchdog prober pods` are not scaled up during reconciliation of the shooted seed.
kubectl -n garden annotate managedresource dependency-watchdog-probe resources.gardener.cloud/ignore=true --overwrite
```

* Check the role/clusterrole for dependency-watchdog-prober in the `garden` namespace of the seed worker plane and add a
`patch` verb for deployment/scale resource if not present.
* Check the role/rolebinding in the shoot for the dependency-watchdog-probe related service account in the `kube-system`
namespace. Add rules for listing leases in the `kube-node-lease` namespace.
* Scale down the DWD prober deployment in the garden namespace (in the shooted-seed) and start a local DWD process by
providing the prober config and the kubeconfig of the shooted seed as command line flags -
```bash go run ./dwd.go prober --config-file=<path to prober config yaml> --kubeconfig=<path to shooted-seed kubeconfig yaml>```.
To change the log level one can additionally pass `--zap-log-level=<loglevel>` command line flag which will be picked
up zap logger at the time of initialization of DWD prober.
* Another way of running DWD is to change the image of the DWD deployment at `imagevector/images.yaml` in the cloned
gardener repo used for the setup. (This needs to be done after the script checks out the desired gardener version and
before `make gardener-extensions-up` is run)

#### Secret changes

DWD API server probe leverages an `apiserver-probe-endpoint`(name might vary) to connect to the shoot Kube API server.
API server probe DNS record points to an `in-cluster` endpoint which is only reachable from within the cluster. For
tests that are run locally by starting a DWD prober process, the api server probe endpoint will have to be changed. This
can be done in the following way:

> **NOTE:** <br/> Create a new apiserver probe endpoint which is then reachable from the locally running DWD prober
> process. To do that you will have to the following:
> * Create a new `DNSRecord` containing the new shoot Kube API server endpoint. This will create a provider specific
route (e.g. In case of AWS it will create a AWS-Route53 endpoint)
> * To ensure that a call to this endpoint is routed to the Kube API server of the shoot do the following:
> * Update Istio `Gateway` resource in the shoot namespace (E.g
`kubectl get gateway -n <shoot-ns> kube-apiserver -oyaml`). Add the new endpoint to `spec.servers.hosts`.
>
* Update Istio `VirtualService` resource in the shoot namespace (
`k get virtualservice -n <shoot-ns> kube-apiserver -oyaml`). Add the new endpoints to `spec.hosts`,
`spec.tls.match.sniHosts`

* Modify the existing secret `shoot-access-dependency-watchdog-apiserver-probe`(name might vary) present in the
`shoot namespace` of the `shooted seed` cluster to use the new endpoint.
> NOTE: If you intend to modify the existing secret, it will be restored back to its original state after every shoot
reconciliation. The duration is set to 1 hour. You need to then re-apply your changes.
* Create a new secret with the changed endpoint and ensure that the prober configuration that you supply to the locally
running DWD prober process points to the new secret.
> NOTE: If you intend to use a new secret, ensure that the name should not end with
`dependency-watchdog-internal-probe` or `dependency-watchdog-external-probe` to prevent its automatic removal during
reconciliation of the shoot.

For these tests, the API server probe uses the target url mentioned in the dns record `$SHOOTNAME-apiserver`(name might
vary).

#### Prober Config

You can customize different configuration values by defining your own config file. Prober config used for these tests is
Expand Down
2 changes: 1 addition & 1 deletion internal/util/k8shelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func createRestConfigFromKubeConfigBytes(kubeConfigBytes []byte, connectionTimeo
if err != nil {
return nil, err
}
config.Wrap(func(rt http.RoundTripper) http.RoundTripper {
config.Wrap(func(_ http.RoundTripper) http.RoundTripper {
return transport
})
return config, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestGetSliceOrDefault(t *testing.T) {
g := NewWithT(t)
t.Parallel()
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
t.Run(test.description, func(_ *testing.T) {
g.Expect(GetSliceOrDefault(test.inputSlice, test.expectedOutputSlice)).To(Equal(test.expectedOutputSlice))
})
}
Expand Down

0 comments on commit 7d9127d

Please sign in to comment.