-
Notifications
You must be signed in to change notification settings - Fork 326
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
ServiceResolver controller and webhook #325
Conversation
0f88eb7
to
070a667
Compare
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Status ConfigEntryStatus `json:"status,omitempty"` | ||
Spec ServiceDefaultsSpec `json:"spec,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't pull metav1.TypeMeta
, metav1.ObjectMeta
and Status
into a shared struct that is embedded into all config entries without breaking code generation so unfortunately we'll need to implement the ConfigEntryCRD
interface for all config entries.
@@ -0,0 +1,299 @@ | |||
package controllers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the generic controller that works for all config entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think we should do with helper/controller.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that we should move it into sync-catalog but I think it may be used for health checks. We could rename it as something, maybe CacheController
and move it into its own top-level package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should consolidate it I think, although I don't think this is required for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a partial review. I feel a bit concerned about webhooks moving into the controllers package. Here is my rationale: validation and defaulting can be specific to the version of the CRD and hence it should live in the same package as the CRD it is performing validations/defaulting for (v1alpha1) in this case. Controllers on the other hand are CRD version agnostic (conversion webhooks should ensure they are converted to the version the controller supports).
I tried tinkering with its structure and ran into code-gen issues with the interface as well.
Webhooks moved back to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Havent yet run these but this looks great!! Will try running them now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
@@ -332,6 +332,7 @@ func TestRun_SecretUpdates(t *testing.T) { | |||
// the certs or the webhook config, it retries the update every second until | |||
// it succeeds. | |||
func TestCertWatcher(t *testing.T) { | |||
t.SkipNow() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is being fixed in #326 but marking skipped now so CI is green. Won't merge with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ Love the refactor!! I've left some comments, ideas, questions, and suggestions. I haven't run it yet, but thought it'd be worth leaving the comments I have so far.
@@ -0,0 +1,299 @@ | |||
package controllers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think we should do with helper/controller.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!! A couple of minor comments, nothing blocking though.
* Also make controller and webhook code generic * Update to controller-runtime 0.6.3 to fix spurious log error message.
245b858
to
d62b005
Compare
Enterprise License Job PodSecurityPolicy
Changes proposed in this PR:
toConsul()
andmatchesConsul()
Reconciler
is implemented by each CRD-specific reconcilerConfigEntryCRD
is implemented by each CRD objectConfigEntryReconciler
ValidateConfigEntry
functionHow I've tested this PR: Acceptance tests from hashicorp/consul-helm#606
How I expect reviewers to test this PR:
ghcr.io/lkysow/consul-k8s-dev:sep17-crd-controller-resolver
that can be tested withChecklist: