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

checker:get_target_status fail to get result #154

Open
bourne-3 opened this issue Mar 4, 2024 · 1 comment
Open

checker:get_target_status fail to get result #154

bourne-3 opened this issue Mar 4, 2024 · 1 comment
Labels

Comments

@bourne-3
Copy link

bourne-3 commented Mar 4, 2024

Thank you for providing such a great project. I encountered some problems while using it.

Test according to the test case, the following code:

 location = /t {
        content_by_lua_block {
            local we = require "resty.worker.events"
            assert(we.configure{ shm = "my_worker_events", interval = 0.1 })
            local healthcheck = require("resty.healthcheck")
            local checker = healthcheck.new({
                name = "testing",
                shm_name = "test_shm",
                checks = {
                    active = {
                        http_path = "/status",
                        healthy  = {
                            interval = 999, -- we don't want active checks
                            successes = 1,
                        },
                        unhealthy  = {
                            interval = 999, -- we don't want active checks
                            tcp_failures = 1,
                            http_failures = 1,
                        }
                    },
                    passive = {
                        healthy  = {
                            successes = 1,
                        },
                        unhealthy  = {
                            tcp_failures = 1,
                            http_failures = 1,
                        }
                    }
                }
            })
            ngx.sleep(0.1) -- wait for initial timers to run once
            local ok, err = checker:add_target("127.0.0.1", 8088, nil, true)
            ngx.say(checker:get_target_status("127.0.0.1", 8088))  -- true
            checker:report_tcp_failure("127.0.0.1", 8088)
            ngx.say(checker:get_target_status("127.0.0.1", 8088))  -- false
            checker:report_success("127.0.0.1", 8088)
            ngx.say(checker:get_target_status("127.0.0.1", 8088))  -- true
        }
    }

The result of execution is:

curl http://127.0.0.1:8085/t
false
false
true

Why can't I reproduce the same results as your test case?
In other words, after executing checker:add_target, the result of executing checker:get_target_status for the first time is false.
I can confirm that my corresponding interface exists: as follows

curl -I   http://127.0.0.1:8088/status
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Mon, 04 Mar 2024 15:53:43 GMT
Content-Length: 15

Please tell me if there is anything wrong here;Thx
the openresty version of mine is 1.13.

@bourne-3
Copy link
Author

bourne-3 commented Mar 4, 2024

Furthermore, when I tested according to the Synopsis method, the corresponding IP and port could not be detected;

That is to say, I executed it exactly as in the Synopsis case.

When I killed the IP and port specified in checker:add_target, I did not see any messages in the log. (It is expected that the checker.events.unhealthy event will be hit)

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

No branches or pull requests

2 participants