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

feat: Get all state #15

Merged
merged 1 commit into from
Mar 23, 2023
Merged

feat: Get all state #15

merged 1 commit into from
Mar 23, 2023

Conversation

kingluo
Copy link

@kingluo kingluo commented Mar 22, 2023

@monkeyDluffy6017
Copy link

Why do we need get all state?

@kingluo
Copy link
Author

kingluo commented Mar 22, 2023

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

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?

Copy link
Author

@kingluo kingluo Mar 22, 2023

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

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

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?

Copy link
Author

@kingluo kingluo Mar 23, 2023

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.

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).

Choose a reason for hiding this comment

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

LGTM

Copy link

@leslie-tsang leslie-tsang left a comment

Choose a reason for hiding this comment

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

LGTM

@monkeyDluffy6017 monkeyDluffy6017 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