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

ceph: move scheme initialization to the same place #8482

Merged
merged 1 commit into from Aug 6, 2021

Conversation

leseb
Copy link
Member

@leseb leseb commented Aug 4, 2021

Description of your changes:

Let's initialize the schemes in a single place instead of doing it
when each controller initializes.

Signed-off-by: Sébastien Han seb@redhat.com

Which issue is resolved by this Pull Request:
Resolves #

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

@leseb leseb added the do-not-merge DO NOT MERGE :) label Aug 4, 2021
@leseb
Copy link
Member Author

leseb commented Aug 4, 2021

I want to do more tests on this hence the DNM label.

@mergify mergify bot added the ceph main ceph tag label Aug 4, 2021
@leseb leseb requested review from rohan47, travisn and rohantmp and removed request for rohan47 August 4, 2021 17:07
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

This is the type of internal change that if the tests are passing and we let it stabilize in master for a bit, it's good to go. But it seems the tests are not happy...

@leseb leseb force-pushed the restrict-manager-cache branch 3 times, most recently from bfdc73d to a51b7ee Compare August 5, 2021 09:06
return cache.BuilderWithOptions(
cache.Options{
SelectorsByObject: cache.SelectorsByObject{
&cephv1.CephCluster{}: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

If I read the doc right, this would mean that no fields of the CephCluster and objects with value {} would be cached.
And in others only the namespace field.

https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.9.5/pkg/cache#Options

Copy link
Contributor

@rohantmp rohantmp Aug 5, 2021

Choose a reason for hiding this comment

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

Are the reconciler GETs returning empty structs?

Let's initialize the schemes in a single place instead of doing it
when each controller initializes.

Signed-off-by: Sébastien Han <seb@redhat.com>
@leseb leseb changed the title ceph: restrict the informer cache to our objects ceph: move scheme initialization to the same place Aug 6, 2021
@leseb
Copy link
Member Author

leseb commented Aug 6, 2021

In the end, I've decided to go with a small refactor instead. The more I think about this, the more I feel like we will be missing a lot of things and will get unintended behaviors. We might revisit once we have #8400 merged and also with a better resource list of what we manage. (also need to check DS possible impacts...).

@leseb leseb removed the do-not-merge DO NOT MERGE :) label Aug 6, 2021
@leseb leseb requested a review from travisn August 6, 2021 10:17
logger.Info("setting up schemes")
// Setup Scheme for all resources
scheme := runtime.NewScheme()
for _, f := range resourcesSchemeFuncs {
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of creating the schemes in this central place? It seems better to keep it with each type as it was before. If someone creates a new controller they may not see where to add the scheme here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was useful with the previous version of this patch as the schemes must be defined when building our own cached resources.
I still believe it's nice to have that centralized. If you create a new controller you still need to add the new CRD to pkg/apis/ceph.rook.io/v1/register.go.
At the end, these lines will never be touched again and fewer lines will be added in new controllers.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, the functionality is really the same. It's fine either way, we can go with this.

logger.Info("setting up schemes")
// Setup Scheme for all resources
scheme := runtime.NewScheme()
for _, f := range resourcesSchemeFuncs {
Copy link
Member

Choose a reason for hiding this comment

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

Ok, the functionality is really the same. It's fine either way, we can go with this.

@leseb leseb merged commit e4ac38e into rook:master Aug 6, 2021
@leseb leseb deleted the restrict-manager-cache branch August 6, 2021 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ceph main ceph tag
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants