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

reverseproxy: restore allowing upstream to contain replaceable placeholders #3776

Closed
wants to merge 2 commits into from

Conversation

mohammed90
Copy link
Member

Another regression caused by d55d50b

Updates #3768

@mohammed90 mohammed90 added the bug 🐞 Something isn't working label Oct 3, 2020
@mohammed90 mohammed90 added this to the v2.2.1 milestone Oct 3, 2020
@mohammed90 mohammed90 requested a review from mholt October 3, 2020 15:41
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
@@ -129,8 +129,12 @@ func (h *Handler) Provision(ctx caddy.Context) error {
h.ctx = ctx
h.logger = ctx.Logger(h)

re := regexp.MustCompile(`\{[[:graph:]]+\}`)
Copy link
Member

Choose a reason for hiding this comment

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

Not gonna lie, I do hate this 😆 Let me think on this for a bit and see if we can come up with something more elegant...

This didn't used to be a problem, right? Did we add code that broke this use case? Can we not remove that code? Or at least change it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the code added to fix the healthcheck on alternate port requires parsing the network address, which errors out for not having a port when using placeholders. I've moved that part into later in the Provision method where it only sets up the health checks. Now if the upstream contains a placeholder dial address, it will not accept active healthcheck config because it's like SRV and owned by another entity.

Copy link
Member

Choose a reason for hiding this comment

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

Do you think there's a way we can fix the original health checking bug without requiring host/port information up front? That would simplify the code, rather than complicate it.

@@ -101,6 +102,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
// to write tests before making any more changes to it
upstreamDialAddress := func(upstreamAddr string) (string, error) {
var network, scheme, host, port string
placeholder := regexp.MustCompile(`\{[[:graph:]]+\}`)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this logic/check have to be repeated in the Caddyfile adapter?

(If we keep it, this should be brought out into a package-level variable like var placeholderPattern = ... or something, then reused...)

@mholt
Copy link
Member

mholt commented Oct 5, 2020

Thanks so much for working on this. But the growing complexity resulting from the original fix is starting to make me nervous / give me a headache. 😅 I'm hoping we can revisit the original problem and find a better solution. I'll try taking a look at it later today.

mholt referenced this pull request Oct 5, 2020
* reverse_proxy: ensure upstream address has port range of only 1

* reverse_proxy: don't log the error if upstream range size is more than 1
mholt added a commit that referenced this pull request Oct 7, 2020
@mholt
Copy link
Member

mholt commented Oct 7, 2020

I think this will be mostly superseded by #3780, but not before we bring over the new integration tests this PR has (except for one, see linked PR).

@mholt mholt added the do not merge ⛔ Not ready yet! label Oct 7, 2020
@mholt mholt closed this Oct 12, 2020
@mohammed90 mohammed90 deleted the placeholder-upstream branch October 12, 2020 20:27
mholt added a commit that referenced this pull request Oct 13, 2020
* reverseproxy: Fix dial placeholders, SRV, active health checks

Supercedes #3776
Partially reverts or updates #3756, #3693, and #3695

* reverseproxy: add integration tests

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working do not merge ⛔ Not ready yet!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants