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
Add Ingress status management #2386
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2386 +/- ##
==========================================
- Coverage 78.05% 77.31% -0.74%
==========================================
Files 62 64 +2
Lines 5291 5379 +88
==========================================
+ Hits 4130 4159 +29
- Misses 1071 1131 +60
+ Partials 90 89 -1
Continue to review full report at Codecov.
|
46beae1
to
4bb5f70
Compare
I'll review tomorrow. |
Updates #403. Change StatusLoadBalancer name to IngressStatusUpdater, makes the purpose clearer. Minor fix to RBAC - "ingress/status" resource requires "update" for updating status. Signed-off-by: Nick Young <ynick@vmware.com>
4bb5f70
to
92ab2ba
Compare
Updates #403 Add informer to watch envoy's service document and pass the status.loadbalancer stanza to the ingress status updater. Signed-off-by: Dave Cheney <dave@cheney.net> cmd/contour: add IngressStatusWriter Updates #403 This PR adds a worker to doServe's group which writes back load balancer status to ingress.v1beta1 objects. In this PR, the population of the isw.lbStatus channel is not present but has been manually verified with the following code: g.Add(func(stop <-chan struct{}) error { tick := time.Tick(2 * time.Second) for { select { case <-tick: isw.lbStatus <- v1.LoadBalancerStatus{ Ingress: []v1.LoadBalancerIngress{{ Hostname: "gke.davecheney.com", }}, } case <-stop: return nil } } }) Future PRs will add workers to populate the channel. Signed-off-by: Dave Cheney <dave@cheney.net> hack: hide prepare release script from glob builds Use // +build to hide prepare-release.go from drive by go build/test ... invocations Signed-off-by: Dave Cheney <dave@cheney.net> cmd/contour: wire up envoy service name/namespace flags Updates #403 Wire up envoy service name and namespace to flags, defaults match the example deployment. Signed-off-by: Dave Cheney <dave@cheney.net> examples/contour: add ingress status subresource to Contour's role Updates #403 Signed-off-by: Dave Cheney <dave@cheney.net> internal/k8s: final cleanups Fixes #403 Signed-off-by: Dave Cheney <dave@cheney.net>
Updates #403. Change StatusLoadBalancer name to IngressStatusUpdater, makes the purpose clearer. Minor fix to RBAC - "ingress/status" resource requires "update" for updating status. Signed-off-by: Nick Young <ynick@vmware.com>
92ab2ba
to
9636b4a
Compare
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 pretty good. I had a few suggestions, but the main change is dropping the envoy deployment changes.
The squashed commit message also looks a bit messy; what do you think about doing some redrafting on it?
if svc.Name != s.ServiceName { | ||
return | ||
} | ||
s.notify(svc.Status.LoadBalancer) |
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.
Nit: Is a method useful here? We could just
s.LBStatus <- svc.Status.LoadBalancer
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.
Maybe this could boil down to:
if svc, ok := obj.(*v1.Service); ok && svc.Name == s.ServiceName {
s.LBStatus <- svc.Status.LoadBalancer
}
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.
Agreed about the method, it's not really necessary for now, unless we end up wanting to do something more clever than just send down the channel.
For the code though, I feel like having individual clauses is more verbose, but far easier to read. For lack of a better word, I'd call it more idiomatic.
cmd/contour/ingressstatus.go
Outdated
// OnUpdate and OnDelete events are ignored.If a new v1.LoadBalancerStatus value | ||
// is been received, operation restarts at step 3. | ||
// 5. If the worker is stopped, any existing informer is stopped before the worker stops. | ||
type ingressStatusWriter struct { |
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.
Nit: I think that calling this loadBalancerStatusWriter
as an actor that writes LoadBalancerStatuses
makes it clearer to my reading.
I went back and forth on this a bit, and I can see the perspective this name is coming from. Maybe we keep this name and think about renaming if it updates status on HTTPProxy too.
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.
Yes, in my initial reading of this file it was called StatusLoadBalanceWriter or something, and it was hard to tell what it was actually acting on. The reason to move to ingressStatusWriter was to make it clear what objects were being written onto in the end.
loadBalancerStatusWriter is fine though, that covers us for HTTPProxy as well.
Updates #403 Add informer to watch envoy's service document and pass the status.loadbalancer stanza to the ingress status updater. Signed-off-by: Dave Cheney <dave@cheney.net> cmd/contour: add IngressStatusWriter Updates #403 This PR adds a worker to doServe's group which writes back load balancer status to ingress.v1beta1 objects. In this PR, the population of the isw.lbStatus channel is not present but has been manually verified with the following code: g.Add(func(stop <-chan struct{}) error { tick := time.Tick(2 * time.Second) for { select { case <-tick: isw.lbStatus <- v1.LoadBalancerStatus{ Ingress: []v1.LoadBalancerIngress{{ Hostname: "gke.davecheney.com", }}, } case <-stop: return nil } } }) Future PRs will add workers to populate the channel. Signed-off-by: Dave Cheney <dave@cheney.net> hack: hide prepare release script from glob builds Use // +build to hide prepare-release.go from drive by go build/test ... invocations Signed-off-by: Dave Cheney <dave@cheney.net> cmd/contour: wire up envoy service name/namespace flags Updates #403 Wire up envoy service name and namespace to flags, defaults match the example deployment. Signed-off-by: Dave Cheney <dave@cheney.net> examples/contour: add ingress status subresource to Contour's role Updates #403 Signed-off-by: Dave Cheney <dave@cheney.net> internal/k8s: final cleanups Fixes #403 Signed-off-by: Dave Cheney <dave@cheney.net>
Updates #403. Change StatusLoadBalancer name to IngressStatusUpdater, makes the purpose clearer. Minor fix to RBAC - "ingress/status" resource requires "update" for updating status. Signed-off-by: Nick Young <ynick@vmware.com>
9636b4a
to
888059d
Compare
Updates #403 Add informer to watch envoy's service document and pass the status.loadbalancer stanza to the ingress status updater. cmd/contour: add IngressStatusWriter Wire up envoy service name and namespace to flags, defaults match the example deployment. examples/contour: add ingress status subresource to Contour's role Signed-off-by: Dave Cheney <dave@cheney.net>
Updates #403. Change StatusLoadBalancer name to IngressStatusUpdater, makes the purpose clearer. Minor fix to RBAC - "ingress/status" resource requires "update" for updating status. Signed-off-by: Nick Young <ynick@vmware.com>
888059d
to
f1b2a4e
Compare
Okay, ready for rereview. |
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 good.
isw.log.Info("Received a new address for status.loadBalancer") | ||
|
||
// Create new informer for the new LoadBalancerStatus | ||
factory := isw.clients.NewInformerFactory() |
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.
Should we reuse the informers created earlier? What if the informer would fail to create?
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.
The reason to throw away the old informer is to ensure that the new informer does a full resync, so that all the existing Ingress objects that are in scope will get updated (via OnAdd calls).
I think that if the informer failed to create, there would be a panic somewhere, because this method doesn't return an error for us to check.
Updates #403 Add informer to watch envoy's service document and pass the status.loadbalancer stanza to the ingress status updater. cmd/contour: add IngressStatusWriter Wire up envoy service name and namespace to flags, defaults match the example deployment. examples/contour: add ingress status subresource to Contour's role Signed-off-by: Dave Cheney <dave@cheney.net>
Updates #403. Change StatusLoadBalancer name to IngressStatusUpdater, makes the purpose clearer. Minor fix to RBAC - "ingress/status" resource requires "update" for updating status. Signed-off-by: Nick Young <ynick@vmware.com>
f1b2a4e
to
630b411
Compare
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.
/lgtm
Updates #403 Add informer to watch envoy's service document and pass the status.loadbalancer stanza to the ingress status updater. cmd/contour: add IngressStatusWriter Wire up envoy service name and namespace to flags, defaults match the example deployment. examples/contour: add ingress status subresource to Contour's role Signed-off-by: Dave Cheney <dave@cheney.net>
Updates #403.
This version of Ingress status adds the wiring to manage Ingress status, and allows the configuration of an Envoy service and namespace to watch for addresses to publish into the
status.Loadbalancer
stanza of Ingress objects.There are still TODOs, #2387 and #2388 amongst them.