-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
Why do we need get all state? |
@monkeyDluffy6017 https://lists.apache.org/thread/2j12c5fxvqpxvhlccsq6gnnpk399kf4d |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#14 (comment)