Skip to content

feat: Get all state#15

Merged
juststillthinking merged 1 commit into
api7:masterfrom
kingluo:get_all_state
Mar 23, 2023
Merged

feat: Get all state#15
juststillthinking merged 1 commit into
api7:masterfrom
kingluo:get_all_state

Conversation

@kingluo

@kingluo kingluo commented Mar 22, 2023

Copy link
Copy Markdown

@juststillthinking

Copy link
Copy Markdown

Why do we need get all state?

@kingluo

kingluo commented Mar 22, 2023

Copy link
Copy Markdown
Author

Comment thread lib/resty/healthcheck.lua
local state_key = key_for(self.TARGET_STATE, target.ip, target.port, target.hostname)
target.status = INTERNAL_STATES[self.shm:get(state_key)]
if not target.hostheader then
target.hostheader = nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do we reset the hostheader when the target doesn't have hostheader?

@kingluo kingluo Mar 22, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@spacewander
hostheader may be false, which does not make sense and should be nil or a string value at any time.
It's due to a trivial bug of APISIX, which calculates the argument (host_hdr) to false:
https://github.com/apache/apisix/blob/3b76c45543861a0fb4a7924842d3a47c51ae83b2/apisix/upstream.lua#L129-L131

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so we need to fix this bug first

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks so strange here, could we add a validation in add_target?

@kingluo kingluo Mar 23, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@moonming Look here:
apache/apisix#9150
However, the set-nil-if-false guard logic is harmless here. It's even necessary because we need to keep compatibility with old versions of APISIX.
So we could accept PRs independently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so we need to fix this bug first

Yep, we should also keep this patch (for those who want to use this feature in other versions of apisix).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@leslie-tsang leslie-tsang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@leslie-tsang
leslie-tsang requested a review from moonming March 23, 2023 08:38
@juststillthinking
juststillthinking merged commit c199abc into api7:master Mar 23, 2023
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.

5 participants