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

Add Ingress status management #2386

Merged
merged 2 commits into from Apr 1, 2020
Merged

Conversation

youngnick
Copy link
Member

@youngnick youngnick commented Mar 26, 2020

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.

@youngnick youngnick requested a review from jpeach March 26, 2020 03:42
@youngnick youngnick self-assigned this Mar 26, 2020
@youngnick youngnick added this to the 1.4.0 milestone Mar 26, 2020
@youngnick youngnick added this to In progress in Contour Project Board via automation Mar 26, 2020
@youngnick youngnick added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 26, 2020
@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #2386 into master will decrease coverage by 0.73%.
The diff coverage is 31.46%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
cmd/contour/ingressstatus.go 0.00% <0.00%> (ø)
cmd/contour/serve.go 0.00% <0.00%> (ø)
internal/k8s/ingressstatus.go 69.44% <69.44%> (ø)
cmd/contour/servecontext.go 93.04% <100.00%> (+0.12%) ⬆️
internal/contour/handler.go 74.52% <100.00%> (ø)
internal/dag/cache.go 96.12% <0.00%> (+0.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa02842...630b411. Read the comment docs.

@jpeach
Copy link
Contributor

jpeach commented Mar 26, 2020

I'll review tomorrow.

youngnick added a commit that referenced this pull request Mar 26, 2020
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>
youngnick pushed a commit that referenced this pull request Mar 26, 2020
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>
youngnick added a commit that referenced this pull request Mar 26, 2020
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>
Copy link
Contributor

@jpeach jpeach left a 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?

cmd/contour/ingressstatus.go Outdated Show resolved Hide resolved
cmd/contour/ingressstatus.go Outdated Show resolved Hide resolved
examples/contour/03-envoy.yaml Outdated Show resolved Hide resolved
examples/contour/03-envoy.yaml Outdated Show resolved Hide resolved
cmd/contour/ingressstatus.go Outdated Show resolved Hide resolved
if svc.Name != s.ServiceName {
return
}
s.notify(svc.Status.LoadBalancer)
Copy link
Contributor

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

Copy link
Contributor

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
}

Copy link
Member Author

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.

internal/k8s/ingressstatus_test.go Outdated Show resolved Hide resolved
// 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 {
Copy link
Contributor

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.

Copy link
Member Author

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.

cmd/contour/ingressstatus.go Outdated Show resolved Hide resolved
internal/k8s/ingressstatus.go Show resolved Hide resolved
youngnick pushed a commit that referenced this pull request Mar 31, 2020
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>
youngnick added a commit that referenced this pull request Mar 31, 2020
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>
youngnick pushed a commit that referenced this pull request Mar 31, 2020
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>
youngnick added a commit that referenced this pull request Mar 31, 2020
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>
@youngnick youngnick requested a review from jpeach March 31, 2020 05:04
@youngnick
Copy link
Member Author

Okay, ready for rereview.

Copy link
Contributor

@jpeach jpeach left a 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()
Copy link
Member

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?

Copy link
Member Author

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.

cmd/contour/servecontext.go Outdated Show resolved Hide resolved
davecheney and others added 2 commits April 1, 2020 09:18
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>
Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

/lgtm

@youngnick youngnick merged commit eeda348 into master Apr 1, 2020
Contour Project Board automation moved this from In progress to 1.4 release Apr 1, 2020
youngnick pushed a commit that referenced this pull request Apr 1, 2020
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>
@youngnick youngnick deleted the ingress-status-loadbalancer branch April 2, 2020 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants