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

feat: allow users to opt-in to direct reconciliation #2645

Merged

Conversation

justinsb
Copy link
Collaborator

@justinsb justinsb commented Sep 6, 2024

Add support for a new label, 'alpha.cnrm.cloud.google.com/reconciler'

If set to direct, the direct reconciler will be used.

@justinsb justinsb changed the title feat: allow users to opt-in to direct reconciliation WIP: feat: allow users to opt-in to direct reconciliation Sep 6, 2024
@justinsb
Copy link
Collaborator Author

justinsb commented Sep 6, 2024

WIP because I think this presumes that all controllers are TF & Direct.

cc @yuwenma

@justinsb justinsb added this to the 1.122 milestone Sep 6, 2024
@jasonvigil
Copy link
Collaborator

@justinsb seems there is some code missing? It doesn't compile.

@justinsb justinsb force-pushed the opt_in_to_new_controller branch 5 times, most recently from a95e33d to b9710f7 Compare September 6, 2024 20:56
@jasonvigil
Copy link
Collaborator

Should we update

// Determine the type of controller for the resource: TF, DCL, or Direct.
crd, err := crdloader.GetCRDForGVK(rc.ResourceGVK)
if err != nil {
return ResourceContext{}, err
}
if crd.GetLabels()[crdgeneration.TF2CRDLabel] == "true" {
rc.IsTFResource = true
} else if crd.GetLabels()[crdgeneration.Dcl2CRDLabel] == "true" {
rc.IsDCLResource = true
} else {
rc.IsDirectResource = true
}
also? I actually think it's ok to leave as-is (even with this new behavior), it would just mean our periodic tests would be based on the CRD labels only (not the CR opt-in label).


var _ kccpredicate.ReconcileGate = &SQLInstanceReconcileGate{}

func (*SQLInstanceReconcileGate) ShouldReconcile(o *unstructured.Unstructured) bool {
func (r *SQLInstanceReconcileGate) ShouldReconcile(o *unstructured.Unstructured) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to update the other direct resources to include the optIn ReconcileGate also, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the default now :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(Check out RegisterModel)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see, cool!

@justinsb
Copy link
Collaborator Author

justinsb commented Sep 6, 2024

And good question re the update; I think though that those tests probably should be based on the "primary" controller, rather than the "opt-in" / "override" controller... at least that's what I think looking at how IsTFResource etc are used. Open to other views though!

@jasonvigil
Copy link
Collaborator

And good question re the update; I think though that those tests probably should be based on the "primary" controller, rather than the "opt-in" / "override" controller... at least that's what I think looking at how IsTFResource etc are used. Open to other views though!

Right now, the behavior is based on the labels in the CRD. If TF label -> use TF reconciler. If DCL label -> use DCL reconciler. If neither TF or DCL labels -> use Direct reconciler. Does that seem ok?

@justinsb
Copy link
Collaborator Author

justinsb commented Sep 6, 2024

(I switched to an annotation, feels more consistent, and added a test)

@justinsb justinsb force-pushed the opt_in_to_new_controller branch 3 times, most recently from 7c71e91 to 3aead8c Compare September 7, 2024 15:47
@justinsb justinsb changed the title WIP: feat: allow users to opt-in to direct reconciliation feat: allow users to opt-in to direct reconciliation Sep 8, 2024
@yuwenma
Copy link
Collaborator

yuwenma commented Sep 9, 2024

I like the idea of allowing users to opt-in the alpha direct reconciler ( a big relief on migrating the stable resources). My main concern is that we basically surface the TF reconciler in the KCC object level, but to me these are the implementation details to users and they should not care. Also, when we have to recommend users to switch back to the TF-reconciler due to a regression (rather than fully control the reconciler and fixing it in the next release ourselves), we are basically sending the signals that Direct is less stable than TF. Or we can only turn on this feature in very specific resources like sql.

BTW, looks like this PR does not have test for sqlinstance (the test suite is for dataflowflextemplatejob), can we add one?

Add support for a new annotation, 'alpha.cnrm.cloud.google.com/reconciler'

If set to `direct`, the direct reconciler will be used.
We just create a parallel version of an existing test.
@justinsb
Copy link
Collaborator Author

So I imagine this annotation will be used to let customers opt-in to early access to the direct controller. That is going to be less tested than a beta controller in widespread use, I think that's OK and understandable. I don't think we would recommend using this to force the terraform controller once we've promoted the direct controller to be the default (I guess we could, though it isn't supported today)

I don't understand why SQLInstance, is that because it has the complex predicate? The problem is that it's already in KCC_USE_DIRECT_RECONCILERS, so we're testing the direct controller right now (and only the direct controller).

@yuwenma
Copy link
Collaborator

yuwenma commented Sep 10, 2024

So I imagine this annotation will be used to let customers opt-in to early access to the direct controller. That is going to be less tested than a beta controller in widespread use, I think that's OK and understandable. I don't think we would recommend using this to force the terraform controller once we've promoted the direct controller to be the default (I guess we could, though it isn't supported today)

That sounds good. basically you mean the alpha.cnrm.cloud.google.com/reconciler only accepts direct and not extend to other value like tf / dcl.

I don't understand why SQLInstance, is that because it has the complex predicate? The problem is that it's already in KCC_USE_DIRECT_RECONCILERS, so we're testing the direct controller right now (and only the direct controller).

Yes and also because this PR adds the opt-in in sqlinstance and no test covers it (I think?).

@yuwenma
Copy link
Collaborator

yuwenma commented Sep 10, 2024

/lgtm
/approve

Still have some open questions to discuss. But no blockers.

Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yuwenma

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:

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

@google-oss-prow google-oss-prow bot merged commit c55a528 into GoogleCloudPlatform:master Sep 10, 2024
15 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants