Skip to content

passive healthcheck not working after configuration changing #4077

Description

@Ben0625

Issue description

When both active and passive configuration are updated from only active configuration, the http statuses of passive become an empty table which causes passive healthcheck not working.

Environment

  • apisix version: 2.0
  • OS: 3.10.0-693.el7.x86_64
  • OpenResty version: openresty/1.17.8.2
  • etcd version: 3.4.13
  • apisix-dashboard version: 2.0

Minimal test code / Steps to reproduce the issue

  1. Set a route with two upstreams(/test.do) and healthcheck active configuration(/check.do).
  2. Send a request to trigger creating new checker.
  3. Update this route only by changing healthcheck configuration to both active and passive. Let one of the upstream return 500 code to act like a unnormal node. Send some requests, but the unnormal node cannot be set to be unhealthy even reaching the passive.unhealthy.http_failures.

What's the actual result?

I prints some debug info inside this function: https://github.com/Kong/lua-resty-healthcheck/blob/master/lib/resty/healthcheck.lua#L1372
I prints out the "defaults" table at line 1443.

After doing Step 2, the type of defaults.checks.passive.unhealthy.http_statuses changes from array to dict!

defaults.checks.passive.unhealthy.http_statuses before to_set() function:
{
1 = 429,
2 = 500,
3 = 503,
}

defaults.checks.passive.unhealthy.http_statuses after to_set() function:
{
429 = true,
500 = true,
503 = true,
}

It seems that to_set() changes the "self" object, result in changing "defaults" as well.

What's the expected result?

In my opinion, the "defaults" object should not be changed. Maybe there's some problem with fill_in_settings() function at line 1377. Or am I doing something wrong during these operations?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions