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

[1.3.x] MODCLUSTER-801 mod_proxy_cluster returns 404 now instead of 503 when there's no matching context #746

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

jfclere
Copy link
Member

@jfclere jfclere commented Nov 1, 2023

Fix for https://issues.redhat.com/browse/MODCLUSTER-801

mod_proxy_cluster returns 404 now instead of 503 when there's no matching context

modcluster/mod_proxy_cluster#173

@jfclere jfclere requested a review from jajik November 1, 2023 15:55
Copy link
Collaborator

@jajik jajik left a comment

Choose a reason for hiding this comment

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

Few details, but ok overall.

Do we want to support this in 2.0 too? If so, I would consider the proposed naming.

native/mod_proxy_cluster/mod_proxy_cluster.c Outdated Show resolved Hide resolved
native/mod_proxy_cluster/mod_proxy_cluster.c Outdated Show resolved Hide resolved
native/mod_proxy_cluster/mod_proxy_cluster.c Outdated Show resolved Hide resolved
@rhusar rhusar changed the title Fix for https://issues.redhat.com/browse/MODCLUSTER-801 [1.3.x] Fix for https://issues.redhat.com/browse/MODCLUSTER-801 Nov 3, 2023
@rhusar rhusar changed the title [1.3.x] Fix for https://issues.redhat.com/browse/MODCLUSTER-801 [1.3.x] MODCLUSTER-801 mod_proxy_cluster returns 404 now instead of 503 when there's no matching context Nov 3, 2023
@jfclere
Copy link
Member Author

jfclere commented Nov 15, 2023

Return503WhenNoContext.... Return503NoContext?

@jajik
Copy link
Collaborator

jajik commented Nov 15, 2023

NoContext503, NoContextCode503, NoContextGive503, NoContextResp503...

In theory, this could be parametrized, require one argument – the value, then it could be something like NoContextResponse, NoContextStatus, NoContextCode... + an argument.

@rhusar
Copy link
Member

rhusar commented Nov 16, 2023

NoContext503, NoContextCode503, NoContextGive503, NoContextResp503...

In theory, this could be parametrized, require one argument – the value, then it could be something like NoContextResponse, NoContextStatus, NoContextCode... + an argument.

Then we can call it something like - 'ResponseStatusCodeOnNoContext' / 'ResponseStatusCodeWhenNoContext'. The question though is which of the codes are appropriate in this case anyway other than 503? Looking at e.g. https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors, perhaps 502 or 504 - if there were a timeout waiting for contexts to register - which there should be anyway, no?

@rhusar
Copy link
Member

rhusar commented Nov 16, 2023

@jfclere Shouldn't we be attempting to wait until context is available? IIUC we don't but we should - we are expecting to servers boot again and register again.

@jfclere
Copy link
Member Author

jfclere commented Nov 16, 2023

@jfclere Shouldn't we be attempting to wait until context is available? IIUC we don't but we should - we are expecting to servers boot again and register again.

No we might wait "for ever" and get deny of service too easily.

@sgala
Copy link
Collaborator

sgala commented Nov 17, 2023

NoContext503, NoContextCode503, NoContextGive503, NoContextResp503...
In theory, this could be parametrized, require one argument – the value, then it could be something like NoContextResponse, NoContextStatus, NoContextCode... + an argument.

Then we can call it something like - 'ResponseStatusCodeOnNoContext' / 'ResponseStatusCodeWhenNoContext'. The

I like the idea, it is clear on what the configuration does

question though is which of the codes are appropriate in this case anyway other than 503? Looking at e.g. https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors, perhaps 502 or 504 - if there were a timeout waiting for contexts to register - which there should be anyway, no?

502 seems assumes that an invalid response was received from the server proxied, so I guess it should be 503 or 504.

Copy link
Member

@rhusar rhusar left a comment

Choose a reason for hiding this comment

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

I think the changes are in the right direction of flexibility. However, this makes me wonder, if we shouldn't limit the response codes to a reasonable set? e.g. if someone configured code to be 600 and we don't sanitize it, that would violate the standard.

Copy link
Collaborator

@jajik jajik left a comment

Choose a reason for hiding this comment

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

LGTM overall, but wouldn't it be better to have

static int responsecode_when_no_context = HTTPD_NOT_FOUND;

and then the block could be replaced with single

ap_log_error(APLOG_MARK, response_when_no_context == HTTPD_NOT_FOUND ? APLOG_DEBUG : 
             "proxy: CLUSTER: (%s). No context for the URL returns %d",
             (*balancer)->s->name, response_when_no_context);

?

native/mod_proxy_cluster/mod_proxy_cluster.c Outdated Show resolved Hide resolved
@jfclere
Copy link
Member Author

jfclere commented Dec 8, 2023

@rhusar invalid codes are replaced by 500 and an error message:
+++
Fri Dec 08 14:08:29.107638 2023] [core:error] [pid 80785:tid 140242959771328] [client 127.0.0.1:41278] AH00524: Handler for proxy-server returned invalid result code 666
+++

@jajik
Copy link
Collaborator

jajik commented Dec 8, 2023

LGTM overall, but wouldn't it be better to have

static int responsecode_when_no_context = HTTPD_NOT_FOUND;

and then the block could be replaced with single

ap_log_error(APLOG_MARK, response_when_no_context == HTTPD_NOT_FOUND ? APLOG_DEBUG : 
             "proxy: CLUSTER: (%s). No context for the URL returns %d",
             (*balancer)->s->name, response_when_no_context);

?

The reason I ask is also that this would change the logging level only in case something different than the default is returned. The current PR would change the level even in case of

ResponseStatusCodeOnNoContext 404

but I would expect this should behave as the default one.

@jajik jajik self-requested a review December 8, 2023 15:39
Copy link
Collaborator

@jajik jajik left a comment

Choose a reason for hiding this comment

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

LGTM. Could you please just remove the unnecessary double blank space and squash those four commits into one before merging?

native/mod_proxy_cluster/mod_proxy_cluster.c Outdated Show resolved Hide resolved
@rhusar
Copy link
Member

rhusar commented Dec 8, 2023

@rhusar invalid codes are replaced by 500 and an error message: +++ Fri Dec 08 14:08:29.107638 2023] [core:error] [pid 80785:tid 140242959771328] [client 127.0.0.1:41278] AH00524: Handler for proxy-server returned invalid result code 666 +++

OK great, so that is sanitized.

@rhusar
Copy link
Member

rhusar commented Dec 8, 2023

As @jajik says, please squash into a single commit.

@rhusar
Copy link
Member

rhusar commented Dec 8, 2023

@jfclere Can you please prepare PR for https://github.com/modcluster/mod_proxy_cluster ?

@rhusar rhusar added this to the 1.3.20.Final milestone Dec 10, 2023
@rhusar
Copy link
Member

rhusar commented Dec 11, 2023

@aogburn Could you please give this a quick look (given you are the original reporter)? Thanks!

@jfclere jfclere merged commit c1f8a2e into modcluster:1.3.x Jan 22, 2024
3 checks passed
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.

4 participants