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

Fix compiler and test failures with latest version of sigs.k8s.io/controller-runtime #7979

Merged

Conversation

brooke-hamilton
Copy link
Contributor

Description

A recent change to the 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, 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 is created, if existing samples are affected by the changes in this PR.
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
  • A PR for the recipes repository 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>
@brooke-hamilton brooke-hamilton requested review from a team as code owners October 6, 2024 20:50
@@ -74,7 +77,7 @@ func SetupDeploymentTest(t *testing.T) (*mockRadiusClient, client.Client) {
err = (&DeploymentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
EventRecorder: mgr.GetEventRecorderFor("recipe-controller"),
EventRecorder: mgr.GetEventRecorderFor("deployment-controller"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rynowak
Copy link
Contributor

rynowak commented Oct 6, 2024

Looks like make generate needs to run again. Your other changes probably updated a code generator we're using for the K8s controllers.

Fixed broken tests by adding the SkipNameValidation configuration parameter to unit tests for creating new controllers.

Do you know if SkipNameValidation is a new kind of warning they added to controller-runtime?

I agree with suppressing the warning. It's probably being triggered because our tests will register a new instance of the same controller for each test.

Copy link
Contributor

@rynowak rynowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this PR so far look right 👍. Will look again after you resolve build issues.

@brooke-hamilton
Copy link
Contributor Author

Looks like make generate needs to run again. Your other changes probably updated a code generator we're using for the K8s controllers.

Fixed broken tests by adding the SkipNameValidation configuration parameter to unit tests for creating new controllers.

Do you know if SkipNameValidation is a new kind of warning they added to controller-runtime?

I agree with suppressing the warning. It's probably being triggered because our tests will register a new instance of the same controller for each test.

I'm having an issue with the make generate-controller target. I will follow up.

Validation to prevent duplication of controller names was added in PR2902, and a few days later PR2918 added the SkipNameValidation configuration option which bypasses the validation for duplicate names.

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@rynowak
Copy link
Contributor

rynowak commented Oct 7, 2024

Thanks. Based on this comment, we're in exactly the same test scenario as the user here: kubernetes-sigs/controller-runtime#2902 (comment)

Sounds like it's intended we use SkipNameValidation.

@brooke-hamilton
Copy link
Contributor Author

@rynowak I needed to bump the controller-gen version to align with the current version of k8s.io/*. https://github.com/kubernetes-sigs/controller-tools

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 60.62%. Comparing base (d2870a7) to head (c9c3f41).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ucp/dataprovider/factory.go 0.00% 1 Missing ⚠️
pkg/ucp/queue/provider/factory.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7979   +/-   ##
=======================================
  Coverage   60.61%   60.62%           
=======================================
  Files         534      534           
  Lines       28488    28484    -4     
=======================================
  Hits        17269    17269           
+ Misses       9702     9698    -4     
  Partials     1517     1517           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@radius-functional-tests
Copy link

radius-functional-tests bot commented Oct 7, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository brooke-hamilton/radius
Commit ref baa66de
Unique ID funcf735b768d7
Image tag pr-funcf735b768d7
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcf735b768d7
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcf735b768d7
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcf735b768d7
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcf735b768d7
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@radius-functional-tests
Copy link

radius-functional-tests bot commented Oct 7, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository brooke-hamilton/radius
Commit ref c9c3f41
Unique ID func715cd02c94
Image tag pr-func715cd02c94
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func715cd02c94
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func715cd02c94
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func715cd02c94
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func715cd02c94
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@brooke-hamilton brooke-hamilton merged commit 3829f35 into radius-project:main Oct 7, 2024
28 checks passed
@brooke-hamilton brooke-hamilton deleted the update-controller-runtime branch October 7, 2024 19:55
ytimocin pushed a commit that referenced this pull request Oct 8, 2024
Copied over from #7980.
This is needed because original dependabot PR has conflicts now due to
the manual changes that were made in
#7979.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test Failures with latest version of sigs.k8s.io/controller-runtime
3 participants