Skip to content

Commit

Permalink
Fix compiler and test failures with latest version of sigs.k8s.io/con…
Browse files Browse the repository at this point in the history
…troller-runtime (#7979)

# Description

A [recent
change](kubernetes-sigs/controller-runtime#2903)
to the
[`controller-runtime`](https://github.com/kubernetes-sigs/controller-runtime/)
package caused Radius compilation errors and test failures, as
referenced in #7882. Breaking changes in `controller-runtime` include
the removal of a configuration option, and a new validation that
prevents duplicate controller names. This PR makes changes to update the
packages referenced, fix the compilation errors, and address the test
failures.

Changes include:
- Updates to `go.mod` and `go.sum`.
- Fixed compiler errors by moving the warning suppression configuration
from the `controller-runtime/pkg/client` options to
`client-go/rest/Config`, as required by the changes in
`controller-runtime`.
- Fixed broken tests by adding the `SkipNameValidation` configuration
parameter to unit tests for creating new controllers.
- Some refactoring of commonly shared test functions and constants in
`cli/controller/reconciler` into `shared-test.go`.

> NOTE: The compilation fix in this PR did not change the behavior of
the `rad` cli--only the tests were changed. The assumption is that `rad`
does not ever create controllers with duplicate names, so suppressing
the duplicate controller name validation is not necessary, even though
it is necessary in the automated tests.

## Type of change

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).

Fixes: #7882 

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- [ ] An overview of proposed schema changes is included in a linked
GitHub issue.
- [ ] A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
- [ ] If applicable, design document has been reviewed and approved by
Radius maintainers/approvers.
- [ ] A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
- [ ] A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
- [ ] A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.

---------

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
  • Loading branch information
brooke-hamilton authored Oct 7, 2024
1 parent d2870a7 commit 3829f35
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 224 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/contributor/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
// Prerequisite for Code Generation, see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites#code-generation
// Adding workspace as safe directory to avoid permission issues
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 && go install go.uber.org/mock/mockgen@v0.4.0",
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.0 && go install go.uber.org/mock/mockgen@v0.4.0",
"hostRequirements": {
"memory": "8gb"
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Install mockgen
run: go install go.uber.org/mock/mockgen@v0.4.0
- name: Install controller-gen
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.0
- name: Install helm
uses: azure/setup-helm@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Install controller-gen
run: |
cd radius
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.0
# Generate Bicep docs
- name: Generate Bicep docs
run: |
Expand Down
4 changes: 2 additions & 2 deletions build/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ generate: generate-genericcliclient generate-rad-corerp-client generate-rad-data
.PHONY: generate-tsp-installed
generate-tsp-installed:
@echo "$(ARROW) Detecting tsp..."
cd typespec/ && npx$(CMD_EXT) -q tsp --help > /dev/null || { echo "run 'npm ci' in typespec directory."; exit 1; }
cd typespec/ && npx$(CMD_EXT) -q -y tsp --help > /dev/null || { echo "run 'npm ci' in typespec directory."; exit 1; }
@echo "$(ARROW) OK"

.PHONY: generate-openapi-spec
Expand All @@ -56,7 +56,7 @@ generate-autorest-installed:
.PHONY: generate-controller-gen-installed
generate-controller-gen-installed:
@echo "$(ARROW) Detecting controller-gen..."
@which controller-gen > /dev/null || { echo "run 'go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0'"; exit 1; }
@which controller-gen > /dev/null || { echo "run 'go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.0'"; exit 1; }
@echo "$(ARROW) OK"

.PHONY: generate-ucp-crd
Expand Down
5 changes: 3 additions & 2 deletions deploy/Chart/crds/radius/radapp.io_recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.16.0
name: recipes.radapp.io
spec:
group: radapp.io
Expand Down Expand Up @@ -72,6 +72,8 @@ spec:
type:
description: 'Type is the type of resource to create. eg: ''Applications.Datastores/redisCaches''.'
type: string
required:
- type
type: object
status:
description: RecipeStatus defines the observed state of Recipe
Expand Down Expand Up @@ -126,7 +128,6 @@ spec:
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
TODO: this design is not final and this field is subject to change in the future.
type: string
kind:
description: |-
Expand Down
2 changes: 1 addition & 1 deletion deploy/Chart/crds/ucpd/ucp.dev_queuemessages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.16.0
name: queuemessages.ucp.dev
spec:
group: ucp.dev
Expand Down
2 changes: 1 addition & 1 deletion deploy/Chart/crds/ucpd/ucp.dev_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.16.0
name: resources.ucp.dev
spec:
group: ucp.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ Enter the following commands to install all of the required tools.
cd typespec && npm ci
npm install -g autorest
npm install -g oav
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.0
go install go.uber.org/mock/mockgen@v0.4.0
```
46 changes: 24 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0
github.com/projectcontour/contour v1.29.0
github.com/prometheus/client_golang v1.20.2
github.com/prometheus/client_golang v1.20.4
github.com/spaolacci/murmur3 v1.1.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand All @@ -82,17 +82,17 @@ require (
go.uber.org/mock v0.4.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.8.0
golang.org/x/text v0.18.0
golang.org/x/text v0.19.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.15.4
k8s.io/api v0.30.3
k8s.io/apiextensions-apiserver v0.30.3
k8s.io/apimachinery v0.30.3
k8s.io/cli-runtime v0.30.3
k8s.io/client-go v0.30.3
k8s.io/kubectl v0.30.3
k8s.io/api v0.31.1
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/cli-runtime v0.31.1
k8s.io/client-go v0.31.1
k8s.io/kubectl v0.31.1
oras.land/oras-go/v2 v2.5.0
sigs.k8s.io/controller-runtime v0.18.2
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/secrets-store-csi-driver v1.4.5
)

Expand Down Expand Up @@ -122,6 +122,7 @@ require (
github.com/distribution/reference v0.6.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
Expand Down Expand Up @@ -150,11 +151,12 @@ require (
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.mongodb.org/mongo-driver v1.15.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/api v0.185.0 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
Expand Down Expand Up @@ -248,7 +250,7 @@ require (
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
Expand Down Expand Up @@ -282,7 +284,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rubenv/sql-migrate v1.6.1 // indirect
Expand Down Expand Up @@ -314,13 +316,13 @@ require (
go.starlark.net v0.0.0-20240520160348-046347dcd104 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
Expand All @@ -330,11 +332,11 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiserver v0.30.3 // indirect
k8s.io/component-base v0.30.3 // indirect
k8s.io/apiserver v0.31.1 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240620174524-b456828f718b // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.17.2 // indirect
Expand Down
Loading

0 comments on commit 3829f35

Please sign in to comment.