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 support for nginx_upstream_check_module module #134

Merged
merged 2 commits into from
Jan 19, 2021

Conversation

pfischermx
Copy link

I believe the nginx_upstream_check_module is widely used for checking upstreams and we find this patch very useful for updating the upstream status as soon as the healthcheck fails. It check the upstream status if the nginx_upstream_check_module module is enabled/defined.

@vozlt vozlt merged commit 143a151 into vozlt:master Jan 19, 2021
@vozlt
Copy link
Owner

vozlt commented Jan 19, 2021

Thanks PR.
But I'm not going to test this patch.
Please note that I will remove this patch from master if something goes wrong.

@ergoz
Copy link

ergoz commented Feb 16, 2021

after this patch i cant build openresty 1.19.3.1 from sources with error:

/tmp/nginx-module-vts/src/ngx_http_vhost_traffic_status_display_json.c: In function 'ngx_http_vhost_traffic_status_display_set_upstream_group':
/tmp/nginx-module-vts/src/ngx_http_vhost_traffic_status_display_json.c:586:59: error: 'ngx_http_upstream_rr_peer_t' {aka 'struct ngx_http_upstream_rr_peer_s'} has no member named 'check_index'
  586 |                 if (ngx_http_upstream_check_peer_down(peer->check_index)) {
      |                                                           ^~
make[2]: *** [objs/Makefile:3749: objs/addon/src/ngx_http_vhost_traffic_status_display_json.o] Error 1

how to fix it?

@vozlt
Copy link
Owner

vozlt commented Sep 5, 2022

@ergoz
The peer->check_index variable is defined in the nginx_upstream_check_module and it looks like it can be used only by patching it in nginx.
If it continues to be a problem, remove it as below!

--- ngx_http_vhost_traffic_status_display_json.c        2021-01-25 00:21:14.610002559 +0900
+++ ngx_http_vhost_traffic_status_display_json.c.o      2022-09-05 23:43:21.015685286 +0900
@@ -10,10 +10,6 @@
 #include "ngx_http_vhost_traffic_status_display_json.h"
 #include "ngx_http_vhost_traffic_status_display.h"
 
-#if (NGX_HTTP_UPSTREAM_CHECK)
-#include "ngx_http_upstream_check_module.h"
-#endif
-
 
 u_char *
 ngx_http_vhost_traffic_status_display_set_main(ngx_http_request_t *r,
@@ -582,17 +578,7 @@ ngx_http_vhost_traffic_status_display_se
                 usn.max_fails = peer->max_fails;
                 usn.fail_timeout = peer->fail_timeout;
                 usn.backup = 0;
-#if (NGX_HTTP_UPSTREAM_CHECK)
-                if (ngx_http_upstream_check_peer_down(peer->check_index)) {
-                    usn.down = 1;
-
-                } else {
-                    usn.down = 0;
-                }
-#else
                 usn.down = (peer->fails >= peer->max_fails || peer->down);
-#endif
-
 #if nginx_version > 1007001
                 usn.name = peer->name;
 #endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants