-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
[Federation] Segregate DNS related code to separate controller #45034
[Federation] Segregate DNS related code to separate controller #45034
Conversation
@k8s-bot bazel test this |
@k8s-bot unit test this |
@@ -790,17 +699,6 @@ func (s *ServiceController) updateFederatedService(fedService *v1.Service, newLB | |||
} | |||
} | |||
|
|||
// Ensure DNS records based on Annotations in federated service for all federated clusters | |||
if needUpdate && wantsDNSRecords(fedService) { |
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.
It's not clear to me where this block of code (and the two removed blocks above) have been moved 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.
@quinton-hoole, We may not need this anymore. We look for service status and update the federated ingress annotation. In case of non-loadbalancer type of service, service status will have empty LoadBalancer field and so we don't update the ingress annotation. is this ok?
53b1a3a
to
ecee9ca
Compare
PR rebased. @quinton-hoole, @marun request to PTAL |
/assign @marun |
@shashidharatd Have you considered using a shared informer to serve up services to both the service and dns controllers? My naive assumption is the data requirements are going to be the same between the 2 controllers. |
@marun, its a good suggestion. i will check it out and update. Thanks |
ecee9ca
to
815fa66
Compare
@k8s-bot gce etcd3 e2e test this |
@marun, i gave a shot at using shared informer. Currently shared informer cannot be used by federation controllers since it expects a clientset.Interface. here is the reference. Federation controllers use federation_clientset.Interface. There is incompatibility as of now. So my suggestion is to go forward without using shared informer for this PR and optimize it in the future. Do you agree? This is also related to this issue #41302 which we need to address in future. |
@shashidharatd Ok, that's fine. I didn't realize that it wouldn't be compatible. |
Modulo some inline concerns, this looks reasonable. I also think this extraction of the dns code is a good opportunity for further cleanup that will enable better unit test coverage. Would you be willing to commit to doing that work in a follow-on PR? Reviewed 6 of 6 files at r1, 1 of 4 files at r2. federation/cmd/federation-controller-manager/app/controllermanager.go, line 146 at r1 (raw file):
The previous behavior initialized the dns provider before the services controller. Is there a reason this PR doens't maintain that behavior (i.e. failing on dns initialization failure before starting services controller)? (No action required) Not sure why controllerEnabled accepts the defaultValue parameter if it never varies. federation/pkg/federation-controller/service/dns.go, line 1 at r1 (raw file):
Is there a reason to keep this controller in the service package if the controller manager instantiates it separately? That also prompts the question of whether the dns controller should be initialized if the services controller is disabled (as is proposed in the this revision). When would that configuration make sense? federation/pkg/federation-controller/service/dns.go, line 48 at r1 (raw file):
Why is DNS in all caps but TTL is not? federation/pkg/federation-controller/service/dns.go, line 61 at r1 (raw file):
Should this comment apply to federation/pkg/federation-controller/service/dns.go, line 68 at r1 (raw file):
I'm assuming this comment should be applied to federation/pkg/federation-controller/service/dns.go, line 77 at r1 (raw file):
I think this log line should be removed or at the least downgraded from fatal, since the controller manager will fail if it receives an error from this method. federation/pkg/federation-controller/service/dns.go, line 93 at r1 (raw file):
ditto federation/pkg/federation-controller/service/dns.go, line 133 at r1 (raw file):
(No action required) Ugh, ingress is such an overloaded term. federation/pkg/federation-controller/service/dns.go, line 146 at r1 (raw file):
A catch-all function name like federation/pkg/federation-controller/service/dns.go, line 344 at r1 (raw file):
Similarly, why is DNS capitalized but ResourceRecordSets abreviated to Rrsets? federation/pkg/federation-controller/service/dns.go, line 362 at r1 (raw file):
Ttl -> TTL (same comment where this appears elsewhere in the file) federation/pkg/federation-controller/service/dns.go, line 491 at r1 (raw file):
Consider using strings.Join() to concatenate with a federation/pkg/federation-controller/service/servicecontroller.go, line 387 at r1 (raw file):
How does the new controller avoid processing services that aren't of type load balancer? I can't seem to find a check for the service type. Should there be one in the Comments from Reviewable |
815fa66
to
d014468
Compare
Thanks for the review @marun, have addressed the comments. PTAL. I am for bettering unit test coverage. shall pick it up in follow-up PR. Review status: 4 of 7 files reviewed at latest revision, 13 unresolved discussions. federation/cmd/federation-controller-manager/app/controllermanager.go, line 146 at r1 (raw file): In any case i am starting the DNS controller before the service controller now.
Currently all controllers are by default enabled and i feel thats why we see defaultValue to controllerEnabled func may be not required. But in future may be there will be some controller which by default we want to disable. federation/pkg/federation-controller/service/dns.go, line 1 at r1 (raw file):
Yes you are right. DNS controller should not be enabled if service controller is disabled. I have update the code now. federation/pkg/federation-controller/service/dns.go, line 48 at r1 (raw file): Previously, marun (Maru Newby) wrote…
DNS is made all caps, because there were warnings from federation/pkg/federation-controller/service/dns.go, line 61 at r1 (raw file): Previously, marun (Maru Newby) wrote…
yes, its mistake carried over from previous code. updated. federation/pkg/federation-controller/service/dns.go, line 68 at r1 (raw file): Previously, marun (Maru Newby) wrote…
yes, another mistake. updated now federation/pkg/federation-controller/service/dns.go, line 77 at r1 (raw file): Previously, marun (Maru Newby) wrote…
yes, you are right. changed to error. federation/pkg/federation-controller/service/dns.go, line 93 at r1 (raw file): Previously, marun (Maru Newby) wrote…
Done. federation/pkg/federation-controller/service/dns.go, line 133 at r1 (raw file): Previously, marun (Maru Newby) wrote…
yes agree. lack of better term. I am very bad at coining terms :). request you to suggest a better one. federation/pkg/federation-controller/service/dns.go, line 146 at r1 (raw file): Previously, marun (Maru Newby) wrote…
split the init function according to the suggestion. federation/pkg/federation-controller/service/dns.go, line 344 at r1 (raw file): Previously, marun (Maru Newby) wrote…
Again there were no warnings from federation/pkg/federation-controller/service/dns.go, line 362 at r1 (raw file): Previously, marun (Maru Newby) wrote…
Done. federation/pkg/federation-controller/service/dns.go, line 491 at r1 (raw file): Previously, marun (Maru Newby) wrote…
Done. federation/pkg/federation-controller/service/servicecontroller.go, line 387 at r1 (raw file): Previously, marun (Maru Newby) wrote…
Ok. i have added back an old function which used to do this in service controller, but at a different place. Comments from Reviewable |
Thank you for cleanup. There appears to be some strangeness introduced in the most recent revision around the Reviewed 1 of 4 files at r2, 3 of 3 files at r3. federation/pkg/federation-controller/service/dns.go, line 77 at r1 (raw file): Previously, shashidharatd (Shashidhara T D) wrote…
(No action required) Is it desirable to handle any of the errors in this function vs just returning the federation/pkg/federation-controller/service/dns.go, line 133 at r1 (raw file): Previously, shashidharatd (Shashidhara T D) wrote…
Can you describe what it is? I'm not familiar enough with the service controller to suggest a better name. federation/pkg/federation-controller/service/dns.go, line 491 at r1 (raw file): Previously, shashidharatd (Shashidhara T D) wrote…
(No action required) Consider joining the dns names separately from their components rather than inline. federation/pkg/federation-controller/service/dns.go, line 75 at r3 (raw file):
Ah, I see that you've moved the check for dns to here. I don't think the error handling will be correct, though, since err may be nil and provide no detail to either federation/pkg/federation-controller/service/dns.go, line 88 at r3 (raw file):
Paremeters -> Parameters (could also just use validateConfig) federation/pkg/federation-controller/service/dns.go, line 140 at r3 (raw file):
Why is it desirable to wrap this in a function? Couldn't a similar result be achieved by using federation/pkg/federation-controller/service/dns.go, line 211 at r3 (raw file):
Am I missing something, or will this statement always be executed (function will always return an error)? federation/pkg/federation-controller/service/servicecontroller.go, line 253 at r3 (raw file):
What's to stop this function from starting and shutting down the controller in a single invocation now that the stop channel is not being checked before running the Comments from Reviewable |
af3b312
to
57662d1
Compare
I had caused an issue in previous commit which is fixed now and all tests are passing. Also i tried addressing all the comments. PTAL Review status: 5 of 7 files reviewed at latest revision, 6 unresolved discussions. federation/pkg/federation-controller/service/dns.go, line 77 at r1 (raw file): Previously, marun (Maru Newby) wrote…
The error handling is at the source of the error and also caller of this function is not doing federation/pkg/federation-controller/service/dns.go, line 133 at r1 (raw file): Previously, marun (Maru Newby) wrote…
The federated service holds information about how the service within a cluster can be accessed from outside the cluster in annotation with the type as described here federation/pkg/federation-controller/service/dns.go, line 491 at r1 (raw file): Previously, marun (Maru Newby) wrote…
This is done like this to provide similar readability as earlier code. federation/pkg/federation-controller/service/dns.go, line 75 at r3 (raw file): Previously, marun (Maru Newby) wrote…
moved it back. federation/pkg/federation-controller/service/dns.go, line 88 at r3 (raw file): Previously, marun (Maru Newby) wrote…
mistake, :) fixed now. federation/pkg/federation-controller/service/dns.go, line 140 at r3 (raw file): Previously, marun (Maru Newby) wrote…
the wrapper function is for defer statement to do workQueue.Done. Also the worker will always be blocked at Get waiting for items. Only when the queue is shutdown the worker will quit the loop, and we had to use wait.Until to restart the worker. This pattern for worker is quite common and we can find this in few other places within kubernetes code. I have done some update to make this more clear & also updated the serviceController worker to do the same. federation/pkg/federation-controller/service/dns.go, line 211 at r3 (raw file): Previously, marun (Maru Newby) wrote…
yeah, i introduced a bug mistakenly. Fixed it now. federation/pkg/federation-controller/service/servicecontroller.go, line 253 at r3 (raw file): Previously, marun (Maru Newby) wrote…
there is <-stopCh at the end of this function. Comments from Reviewable |
Thank you for fixing. Code looks to be in good shape. My primary concern is avoiding non-trivial nested functions, which are really hard to test effectively. Reviewed 2 of 2 files at r4. federation/pkg/federation-controller/service/dns.go, line 133 at r1 (raw file): Previously, shashidharatd (Shashidhara T D) wrote…
Ah, so it stems from the LoadBalancerIngress collection. Not really something to be changed in federation then. federation/pkg/federation-controller/service/dns.go, line 139 at r4 (raw file):
I think this should be a first-class method of ServiceDNSController to ensure that it can be unit tested. federation/pkg/federation-controller/service/servicecontroller.go, line 248 at r4 (raw file):
I think localization of defer statements makes sense, so that addition or removal of a given controller component can be done in one place. I don't think this change needs to be included in this PR, though. Consider submitting it separately. federation/pkg/federation-controller/service/servicecontroller.go, line 293 at r4 (raw file):
Same comment about making this a first-class function that can be unit tested. Comments from Reviewable |
57662d1
to
c9454f8
Compare
@k8s-bot kops aws e2e test this |
Review status: 5 of 7 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed. federation/pkg/federation-controller/service/dns.go, line 139 at r4 (raw file): Previously, marun (Maru Newby) wrote…
I have a separate function for workerFunction now which could be tested. is this ok? federation/pkg/federation-controller/service/servicecontroller.go, line 248 at r4 (raw file): Previously, marun (Maru Newby) wrote…
Okie, will send them in separate PR. preserved old code. federation/pkg/federation-controller/service/servicecontroller.go, line 293 at r4 (raw file): Previously, marun (Maru Newby) wrote…
ditto. Comments from Reviewable |
@marun, i have addressed your comments. PTAL. Thanks! |
/lgtm I think this is another good step in refactoring the service controller. I'm hoping future iterations can focus on ensuring good unit test coverage. Reviewed 2 of 2 files at r5. Comments from Reviewable |
Thanks @marun for lgtm. |
/assign @csbell |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csbell, marun, shashidharatd
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 45247, 45810, 45034, 45898, 45899) |
What this PR does / why we need it:
This is the continuation of service controller re-factor work as outlined in #41253
This PR segregates DNS related code from service controller to another controller
service-dns controller
which manages the DNS records on the configured DNS provider.service-dns controller
monitors the federated services for the ingress annotations and create/update/delete DNS records accordingly.service-dns controller
can be optionally disabled and DNS record management could be done by third party components by monitoring the ingress annotations on federated services. (This would enable something like federation middleware for CoreDNS where federation api server could be used as a backend to CoreDNS eliminating the need for etcd storage.)Special notes for your reviewer:
Release note:
cc @kubernetes/sig-federation-pr-reviews