You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2020/03/06 15:34:44 UTC
mod_proxy_ajp equivalent for JK_LB_ACTIVATION?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
At $work, we use mod_jk for proxying and I'd like to move to
mod_proxy_ajp with an eye toward moving to mod_proxy_http eventually.
We use the JK_LB_ACTIVATION state to perform load-balanced
node-draining[1] for maintenance and I'm trying to find out how to get
mod_proxy to give me its current status.
I don't see anything in the documentation for mod_proxy_balancer or
mod_proxy_ajp.
- From the balancer-manager, I can see that there are several items of
status metadata that might be useful:
- - worker "draining mode"
- - worker "disabled" state
- - worker "hot standby" state
- - worker "stopped" state
Each worker has a "status" value, which can be any of D/S/I/R/H/E/N
but it also looks like each of those can be set independently. So the
worker can be in "hot standby" + "error" states. Hmm.
Is that state available in an environment variable I can forward-over
to the origin node?
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5ibZQACgkQHPApP6U8
pFgAnA//W4YL1edSOGE3P11DcgAbmAkemxi+h6gjM9oU54S5Yc+/3rwwg1Hxnnam
t5PeAiO8OyEl3eq/Vr2gF87Xco04x1YEFmj844+TPC8VdGx5Em6hFWxFYBvLNY30
pzt2jKMVKUf+wdtZMvhT2uQYdtTxUbc3aVuCaaXBcR62ihAQ39CaRDalX2vr903Y
8fqT2YQXsYZlO0h6zX0vK37WB1DG4/iqYohcKKtEOvvwL9ZB5iMS40r+MqDulur+
1q9WQPF25oemieC2G9pzRf014ftBdcnzJ5P7xQtWj5xy2b7+WQ7ZNlMyLNEc336K
1iVdM8AtyS4B2tax7hJIPDLlNQUUVTr1SAp1Jj6brEQFVFM+K0ilWjQnSWKBZdW1
lzs7KBzRTxDrsxl92G9cKBX3+2LqOLwjzWTwnjS7dA5P1mWvXGUkKuZLreaeyDod
+WDjPhgK3lxAAXj+WP4NJPSrEbmzZZigN+Ad1BgRk0wsaXejudwYB1fvFnYMWHJC
F9Ty16GlQGtaVI6aACeDX7zV2lO8kKXszKcPks0tZG7abpgom3s99WJvaeGfYEhh
h+YC1Wjyym8EQdCjO0hQU1RiJvRifCuuJbI+DyupxsFEJLjM2zGSkaRYMEn9b2/V
mkQeNPnsDCCr2NADdp1e0mRbAYUs9O0EsVrDs2wTKRw6HiUx1pk=
=XKMA
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: mod_proxy_ajp equivalent for JK_LB_ACTIVATION?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
Maybe I can earn myself a beer.
>> On 3/6/20 13:44, Rainer Jung wrote:
>>> no, the status unfortunately is not available as an Apache env
>>> var.
>
>>> mod_proxy_ajp has a builtin provision for automatic env var
>>> forwarding: alle env vars named AJP_SOMETHING will be
>>> forwarded as request attribute SOMETHING. But I see no easy way
>>> of detecting drain mode and setting an env var and there seems
>>> to be nothing builtin. I remember having added the forwarding
>>> for the LB activation to mod_jk many years ago but well after
>>> mod_proxy_ajp was done by Mladen. It seems to be one of the
>>> missing features in mod_proxy_ajp.
>
>> I'd of course want this to be available in mod_proxy_balancer so
>> any protocol would get it.
>
>>> But of course it could be added ...
In Apache 2.4.x, mod_proxy_balancer.c looks like this starting at line
636:
/* Add session info to env. */
apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_STICKY", sticky);
apr_table_setn(r->subprocess_env,
"BALANCER_SESSION_ROUTE", route);
This seems like a great place to add:
apr_table_setn(r->subprocess_env,
"BALANCER_WORKER_STATUS", ???);
The question is "what should the '???' be?"
The local "proxy_worker **worker" is the place to start. It looks like
I can get the status bits using:
(*worker)->s->status
So I could either convert that into a char* (because the environment
works on strings) or use ap_proxy_parse_wstatus to convert the status
into a human-readable char*.
In either case, what's the proper way to handle memory management for
strings in httpd/mod_proxy/etc.?
There is the brute-force yet safe:
char *status = apr_table_get(r->subprocess_env,
"BALANCER_WORKER_STATUS");
if(NULL == status) {
free(status);
}
status = (char*)malloc(5 * sizeof char); // 4 characters is enough + \0
if(NULL != status) {
if(0 <= snprintf(status, 5, "%d", (*worker)->s->status)) {
apr_table_setn(r->subprocess_env,
"BALANCER_WORKER_STATUS", status);
} else {
apr_table_unset(r->subprocess_env,
"BALANCER_WORKER_STATUS");
free(status);
}
} else {
apr_table_unset(r->subprocess_env,
"BALANCER_WORKER_STATUS");
}
This is a little wasteful, as it re-allocates a 5-byte buffer for
every request. I can get away with a /single/ allocation if I
understand the worker lifecycle a little better.
Is this moving toward the right approach?
Other thoughts:
* Would hex be a better representation?
* Would a spelled-out version be better? It looks like
ap_proxy_parse_wstatus will generate a string like "ONH".
- How to handle memory management of the return value?
(Is this what the apt_pool_r* is being passed-around for?)
Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl6QuEcACgkQHPApP6U8
pFhObg/9EXNZSta9cLCBBNnrRYpZM/+OKY9tnWjAdzOgx6X9p8uM6bOXFVTiPpor
m7+bF57bph6+bg1yxtynk13AFty9HbXkLQkPfsfoMg03SPRMWWTmHvMDV2ISIDIg
CAhKAEjMV5e5nF9gkmxVvIXKRg6ULVVF6Gjb4Dn9dlMFFjHpjqpD+AEYjS+31grf
PCt5OMmUOWyumDPOOWtP/AErmPVxIfeHT7IiK9GB+2FYpeCq1Ty98htxg6j8mbEu
qt2FMWgWGIA3WnOfidHDoTT/HEkYWoVaHQyZLJwpZI//FqUmmx4tuIRh7zRBHcdB
yiSjsO/KkbsHpQ6OkMo5Mm06++Y5l81+Cge4oPD62eUs55sh1pL45RlmlxL1ecFx
wBEOidM6ZsiJJ7x7+uuUCsXFxJXk3sFX57z0S+MLtUSBce8siBm7/+mnr3XXzhjJ
AK+C3BsNQ+yVpRB2l3cLghgr7SSDYTmnEGLfHTwqSjrP2cTxMNdHObl35enj9mr5
rDV9bgCZkwjvKgytk6u0MkZ16JUqd4v5MElGM2NQDMa0eiwWHRAcNznDQG17C8L0
9uDPO0ZjGTtB5h4OpNNx7DC5ts5X+ecMn7fIBHIJewfxXQUdAA5fdSRkrozJCq5o
WD6Tjuar78oeIiD5CRFLg6AB4m7HElcdzuPcSBRcEHpFE7Ev3t4=
=UElj
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: mod_proxy_ajp equivalent for JK_LB_ACTIVATION?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
https://bz.apache.org/bugzilla/show_bug.cgi?id=64338
For anyone who likes beer. Or whatever you like to drink (within reason)
.
- -chris
On 3/9/20 17:44, Christopher Schultz wrote:
> Rainer,
>
> On 3/6/20 13:44, Rainer Jung wrote:
>> Hi Chris,
>
>> no, the status unfortunately is not available as an Apache env
>> var.
>
>> mod_proxy_ajp has a builtin provision for automatic env var
>> forwarding: alle env vars named AJP_SOMETHING will be forwarded
>> as request attribute SOMETHING. But I see no easy way of
>> detecting drain mode and setting an env var and there seems to be
>> nothing builtin. I remember having added the forwarding for the
>> LB activation to mod_jk many years ago but well after
>> mod_proxy_ajp was done by Mladen. It seems to be one of the
>> missing features in mod_proxy_ajp.
>
> I'd of course want this to be available in mod_proxy_balancer so
> any protocol would get it.
>
>> But of course it could be added ...
>
> :)
>
> I'll happily buy a round of drinks at ApacheCon if someone would
> look into this. Without it, my "how to easily move from mod_jk to
> mod_proxy_http" presentation is going to have a bit of a hole in
> it. :(
>
> Thanks, -chris
>
>> Am 06.03.2020 um 16:34 schrieb Christopher Schultz:
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>>>
>>> All,
>>>
>>> At $work, we use mod_jk for proxying and I'd like to move to
>>> mod_proxy_ajp with an eye toward moving to mod_proxy_http
>>> eventually.
>>>
>>> We use the JK_LB_ACTIVATION state to perform load-balanced
>>> node-draining[1] for maintenance and I'm trying to find out
>>> how to get mod_proxy to give me its current status.
>>>
>>> I don't see anything in the documentation for
>>> mod_proxy_balancer or mod_proxy_ajp.
>>>
>>> - From the balancer-manager, I can see that there are several
>>> items of status metadata that might be useful:
>>>
>>> - - worker "draining mode" - - worker "disabled" state - -
>>> worker "hot standby" state - - worker "stopped" state
>>>
>>> Each worker has a "status" value, which can be any of
>>> D/S/I/R/H/E/N but it also looks like each of those can be set
>>> independently. So the worker can be in "hot standby" + "error"
>>> states. Hmm.
>>>
>>> Is that state available in an environment variable I can
>>> forward-over to the origin node?
>>>
>>> - -chris
>
>> ---------------------------------------------------------------------
>
>>
>
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl6QrhIACgkQHPApP6U8
pFgBahAAhXGUNBAobLyBRgT3BtY+x9OrFVS5DnG1sMzJSej9V6wEm003Q83GSlB1
eTrC9wcJM2vuqiC+eZc2u5ruWDpsUnt/FxiU16URAjtXqwbbSg+LZ1qmtqkX7l6J
eSE2NuEKHxeB0JoqFwxfpDI5uaulVJCb71bQzh/xQEbCbKLwt0uQVJ8h/z2XmfEh
nYhhmY2spmfCsdMl0l+pnqjXAjQ70qK36JRNlGGlIkHD111BsOtN41vlg3WlCQ/v
jpHqmB0b2Y7VwiQjXBDCXuwZxQ69+1FGoo7TQ1TAmb5YQzL8iSJ45Pzz9DSiVO+j
3lSfDJG8pCGQIFSuX/FagMWWJHOR9ZF+11/n8B/iOLv3RAWsKfEJwTS1y+Xxurzw
M/64nQyXmfAqladkLXAFwTWqtFeuLFKmN3taBvVgX73SQ89HXLiUpOjOyG6U1HO8
rvn7E/lIMPFGPUZGFUWXMKMns9lXaDsfI5T/DfPhSjLxO2fX6W4LpJpe2OAd3uhA
LgPsCZENLxOpe5J9DKpeMygV9MwSZ3TJgyXTtOBmXs9nWJeY83dy7PHNGad/Jpcp
hpINTVMDp4cxvFSNz46dJ5Wkh9v3ss5esH8XglueaYUFzsf+/KqOvn3zrNKWdAqJ
pgtAK0azSieW4oU7Ukn8nWUAwNl9LXastgzwKBuoJAMXAb7iIvw=
=hiGB
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: mod_proxy_ajp equivalent for JK_LB_ACTIVATION?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Rainer,
On 3/6/20 13:44, Rainer Jung wrote:
> Hi Chris,
>
> no, the status unfortunately is not available as an Apache env
> var.
>
> mod_proxy_ajp has a builtin provision for automatic env var
> forwarding: alle env vars named AJP_SOMETHING will be forwarded as
> request attribute SOMETHING. But I see no easy way of detecting
> drain mode and setting an env var and there seems to be nothing
> builtin. I remember having added the forwarding for the LB
> activation to mod_jk many years ago but well after mod_proxy_ajp
> was done by Mladen. It seems to be one of the missing features in
> mod_proxy_ajp.
I'd of course want this to be available in mod_proxy_balancer so any
protocol would get it.
> But of course it could be added ...
:)
I'll happily buy a round of drinks at ApacheCon if someone would look
into this. Without it, my "how to easily move from mod_jk to
mod_proxy_http" presentation is going to have a bit of a hole in it. :(
Thanks,
- -chris
> Am 06.03.2020 um 16:34 schrieb Christopher Schultz:
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>>
>> All,
>>
>> At $work, we use mod_jk for proxying and I'd like to move to
>> mod_proxy_ajp with an eye toward moving to mod_proxy_http
>> eventually.
>>
>> We use the JK_LB_ACTIVATION state to perform load-balanced
>> node-draining[1] for maintenance and I'm trying to find out how
>> to get mod_proxy to give me its current status.
>>
>> I don't see anything in the documentation for mod_proxy_balancer
>> or mod_proxy_ajp.
>>
>> - From the balancer-manager, I can see that there are several
>> items of status metadata that might be useful:
>>
>> - - worker "draining mode" - - worker "disabled" state - - worker
>> "hot standby" state - - worker "stopped" state
>>
>> Each worker has a "status" value, which can be any of
>> D/S/I/R/H/E/N but it also looks like each of those can be set
>> independently. So the worker can be in "hot standby" + "error"
>> states. Hmm.
>>
>> Is that state available in an environment variable I can
>> forward-over to the origin node?
>>
>> - -chris
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5muMEACgkQHPApP6U8
pFhNfw//c0JqDs7CQoCpc9u7eYZUU86yMr1Nlj/IXabIuyU0hfiwCWpmxpOgex+3
iPEXoO0qje0+lOW/D61FfzIJ+zZqIBJpq/e2MixLVntvfsDjfVpFZF7TpdHAwEfy
rZx0k7ErNP3vNJT089sCyu7+XxPJocY5avk7b5va5z9TTOHNT136wqphRf4ka9yc
AimmKhTNs3SsGiy7CJp47BXvyl5Nybhm5i1NkJF39oEXdiAVodUTThexjedTjwoi
VESvX1K5A+ST5Zt8dw/teJmJPn3pV70LJz/JFnvTqIZ1aa0xB+niTqw/B4jTVW6W
FUdnuRH9Z1choh7n9ipop62/suJpLaIwCXjm1n4iWKVhEDKntT1WtfUrp1BTr5UQ
3Z6BQX2TkAIVQ1rE3oMYbT7fSHCmEp86XQCg1tCm9cu9T2xlA4Ab09mpSrdEInQg
+IPaUnvuHXmMghdULxjKuKGYGwdNTGfOTkLz9hMh3ghplZpZwg0lugba4+tN2z1y
bp0pN+FaeSDTGwkF12xwSftr0+kt20WRO2l0MdbU9/xAQtf1tOgzH8CR1yxh1j0L
YX3J8iHm7N6OzOL6vCbXDoYV0AL6KSbfeYboJu8fnvUEre6aw+ERz7RdWpaoGzYI
uRO69QJpBE/fqoS7LIor4VTaFXU8khhO+KwwGObmfuYApT78Css=
=jM3C
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: mod_proxy_ajp equivalent for JK_LB_ACTIVATION?
Posted by Rainer Jung <ra...@kippdata.de>.
Hi Chris,
no, the status unfortunately is not available as an Apache env var.
mod_proxy_ajp has a builtin provision for automatic env var forwarding:
alle env vars named AJP_SOMETHING will be forwarded as request attribute
SOMETHING. But I see no easy way of detecting drain mode and setting an
env var and there seems to be nothing builtin. I remember having added
the forwarding for the LB activation to mod_jk many years ago but well
after mod_proxy_ajp was done by Mladen. It seems to be one of the
missing features in mod_proxy_ajp.
But of course it could be added ...
Regards,
Rainer
Am 06.03.2020 um 16:34 schrieb Christopher Schultz:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> At $work, we use mod_jk for proxying and I'd like to move to
> mod_proxy_ajp with an eye toward moving to mod_proxy_http eventually.
>
> We use the JK_LB_ACTIVATION state to perform load-balanced
> node-draining[1] for maintenance and I'm trying to find out how to get
> mod_proxy to give me its current status.
>
> I don't see anything in the documentation for mod_proxy_balancer or
> mod_proxy_ajp.
>
> - From the balancer-manager, I can see that there are several items of
> status metadata that might be useful:
>
> - - worker "draining mode"
> - - worker "disabled" state
> - - worker "hot standby" state
> - - worker "stopped" state
>
> Each worker has a "status" value, which can be any of D/S/I/R/H/E/N
> but it also looks like each of those can be set independently. So the
> worker can be in "hot standby" + "error" states. Hmm.
>
> Is that state available in an environment variable I can forward-over
> to the origin node?
>
> - -chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org