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

internal/dag: update TLS fallbackCertificate logic to require tlscertificatedelegation #2528

Merged

Conversation

stevesloka
Copy link
Member

Updates #1503 by requiring TLSCertificateDelegation to each namespace where a root HTTPProxy enables tls fallback certificate.

Signed-off-by: Steve Sloka slokas@vmware.com

@stevesloka stevesloka added this to the 1.5.0 milestone May 17, 2020
@codecov
Copy link

codecov bot commented May 17, 2020

Codecov Report

Merging #2528 into master will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2528      +/-   ##
==========================================
+ Coverage   76.78%   76.84%   +0.06%     
==========================================
  Files          72       72              
  Lines        5889     5892       +3     
==========================================
+ Hits         4522     4528       +6     
+ Misses       1268     1264       -4     
- Partials       99      100       +1     
Impacted Files Coverage Δ
internal/dag/builder.go 91.18% <100.00%> (+0.03%) ⬆️
internal/dag/cache.go 97.08% <0.00%> (+1.09%) ⬆️

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.

This looks great, just a small issue with status message consistency. FWIW this merge conflicts with #2483.

if err != nil {
sw.SetInvalid("Spec.Virtualhost.TLS fallback certificate Secret %q is invalid: %s", b.FallbackCertificate, err)
return
}

if !b.delegationPermitted(*b.FallbackCertificate, proxy.Namespace) {
sw.SetInvalid("Spec.VirtualHost.TLS fallback secret %s is not configured for certificate delegation to namespace %s", b.FallbackCertificate.Name, b.FallbackCertificate.Namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sw.SetInvalid("Spec.VirtualHost.TLS fallback secret %s is not configured for certificate delegation to namespace %s", b.FallbackCertificate.Name, b.FallbackCertificate.Namespace)
sw.SetInvalid("Spec.VirtualHost.TLS fallback Secret %q certificate delegation not permitted", b.FallbackCertificate.Name)

Suggest this status message, which is consistent with the certificate delegation status message for the non-fallback case.

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 problem is that the certificate isn't delegated, not that it's not permitted to be delegated. So the suggestion doesn't read properly as to what's wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the problem here is identical to the delegation check for regular certificates, we should align the status message. If you prefer your more specific message, then I'd suggest updating both occurrences. Just please use %q (which clarifies the distinction between object names and message test), and check that we are consistently capitalizing Kubernetes kind names. I know this is super picky, but I think that it's worth trying to make the error status message as clear and consistent as we can.

Copy link
Member Author

@stevesloka stevesloka May 21, 2020

Choose a reason for hiding this comment

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

I dislike %q because you get \"log messages\" like \"this\".

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it quotes in the JSON output? In general, JSON logs work better when tooling consumes them I think :)

In this case, it's a status field. The %q makes it clearer to the person reading this that its refers to a object name and that it's not part of the message text. If the string is ever empty, %q makes it clear that there is an empty string. So I get that the quoting looks awkward in JSON, but because this is the only place where we tell the user about errors, I'd argue that reducing any ambiguity as much as possible makes the quoting worth it.

Copy link
Member

Choose a reason for hiding this comment

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

I like the use of %q because of how it shows the empty string case, although I agree the quoting is awkward when it's JSON. This should be mitigated as we move to Conditions anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

cool cool I updated to use the %q

@stevesloka stevesloka force-pushed the fallbackCertTLSDelegation branch 3 times, most recently from d803875 to fe6ee4a Compare May 22, 2020 13:47
…ion to each namespace where a root HTTPProxy enables fallbackCertificate for a fqdn.

Signed-off-by: Steve Sloka <slokas@vmware.com>
@stevesloka stevesloka force-pushed the fallbackCertTLSDelegation branch from 6bcea3e to d3c914d Compare May 22, 2020 16:29
@stevesloka stevesloka merged commit 255cf9d into projectcontour:master May 22, 2020
@stevesloka stevesloka deleted the fallbackCertTLSDelegation branch May 22, 2020 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants