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 memory optimisation feature after upgrade to controller-runtime v0.14.5 #1543

Merged
merged 4 commits into from
Mar 15, 2023

Conversation

ccojocar
Copy link
Contributor

@ccojocar ccojocar commented Mar 14, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

It seems that after upgrading to controller-runtime v0.14.5, the BuilderWithOptins function has introduced a bug when combining
the options provided by the cluster with the custom options, which breaks the memory optimization feature.

BuilderWithOptions function creates a new scheme object which is configured in the cache object, but not into the cluster object
where the original scheme object is maintained. This means that the registered schemes in the cluster scheme are not reflected
into the cache scheme. This prevents the controller from starting with this error messages:

E0314 10:44:24.541264 1302480 source.go:146] controller-runtime/source "msg"="kind must be registered to the Scheme"
"error"="no kind is registered for the type v1beta1.SeccompProfile in scheme \"pkg/runtime/scheme.go:100\""

The issue was introduced by 892ee33.

It seems that our e2e test for memory optimization didn't catch the issue

func (e *e2e) testCaseMemOptmEnable([]string) {
.

I think because we just test the start-up but in this case the spod pods got restarted after 1-2 minutes and keep restarting because of the registration issue.

Which issue(s) this PR fixes:

Does this PR have test?

Yes

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix memory optimization feature after upgrading to controller-runtime v0.14.5.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 14, 2023
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 14, 2023
@ccojocar
Copy link
Contributor Author

/assign @saschagrunert

@ccojocar ccojocar changed the title Fix memory optimization feature after upgrade to controller-runtime v0.14.5 Fix memory optimisation feature after upgrade to controller-runtime v0.14.5 Mar 14, 2023
@ccojocar
Copy link
Contributor Author

/retest

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 14, 2023
@saschagrunert
Copy link
Member

cmd/security-profiles-operator/main.go:36: File is not `gci`-ed with --skip-generated -s standard,default,prefix(sigs.k8s.io/security-profiles-operator) (gci)
	"k8s.io/apimachinery/pkg/labels"
cmd/security-profiles-operator/main.go:43: File is not `gci`-ed with --skip-generated -s standard,default,prefix(sigs.k8s.io/security-profiles-operator) (gci)
	"k8s.io/client-go/rest"

…0.14.5

It seems that BuilderWithOptins has introduced a bug when combining the options provided by the cluster
with the custom options, which breaks the memory optimization feature.

BuilderWithOptions creates a new scheme object which is configured in the cache object
but not in the cluster object where the original scheme object is maintained. This means that the
registered schemes in the cluster scheme are not reflected into the cache. This prevents the controller from
starting with error messages such as:

E0314 10:44:24.541264 1302480 source.go:146] controller-runtime/source "msg"="kind must be registered to the Scheme"
"error"="no kind is registered for the type v1beta1.SeccompProfile in scheme \"pkg/runtime/scheme.go:100\""
@ccojocar ccojocar force-pushed the fix-memopt-kubernetes-upgrade branch from 3f58734 to 42f4bf4 Compare March 14, 2023 13:35
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 14, 2023
@ccojocar
Copy link
Contributor Author

/test all

1 similar comment
@ccojocar
Copy link
Contributor Author

/test all

@ccojocar
Copy link
Contributor Author

@saschagrunert All tests passed, please could you lgtm this again? Thanks

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ccojocar, JAORMX, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JAORMX,ccojocar,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 22cafc0 into main Mar 15, 2023
@saschagrunert saschagrunert deleted the fix-memopt-kubernetes-upgrade branch May 14, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants