Skip to content

fix: missing etcd init_dir and unable to list resource#10569

Merged
bzp2010 merged 3 commits into
apache:masterfrom
AlinsRan:fix/admin-list
Nov 30, 2023
Merged

fix: missing etcd init_dir and unable to list resource#10569
bzp2010 merged 3 commits into
apache:masterfrom
AlinsRan:fix/admin-list

Conversation

@AlinsRan

@AlinsRan AlinsRan commented Nov 30, 2023

Copy link
Copy Markdown
Contributor

Description

Fixes #9618

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@AlinsRan AlinsRan closed this Nov 30, 2023
@AlinsRan AlinsRan reopened this Nov 30, 2023
@AlinsRan
AlinsRan marked this pull request as ready for review November 30, 2023 08:04

@bzp2010 bzp2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is only a temporary solution to get the API working again with a patch, but does not address its underlying issues.

We can fix the problem completely in a future PR.

Comment thread apisix/core/etcd.lua
nodes = setmetatable({}, array_mt)
}
local kvs = res.body.kvs
if #kvs >= 1 and not kvs[1].value then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not kvs[1].value

With all due respect, this is a completely false assumption. Why is the value null?

The lua-resty-etcd uses cjson.safe to parse JSON, so init_dir values that are not in JSON format will be parsed as nil.

Therefore, I think this is only a temporary solution that cannot solve the problem completely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the previous logic, I did not modify it.
The previous non empty processing method was incorrect, I just improved it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, agree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

However, I think you are right. To improve this, I think we can add a judgment, such as or value="init_dir"

@bzp2010
bzp2010 merged commit 7836601 into apache:master Nov 30, 2023
shreemaan-abhishek pushed a commit to shreemaan-abhishek/apisix that referenced this pull request Jan 2, 2026
## Description
Backport apache#10569

Follow up changes:
https://github.com/apache/apisix/pull/11601/files#diff-e180fd4745b8f8c30fa91a6298e91a0b4dde186a1527b892539d6f9bc9c41c3eR222
   
## Checklist
- [ ] I have explained **WHY** we need this PR and **HOW** the problem
it solves
- [ ] The title of the PR concisely describes the code modification and
complies with APISIX specifications.
 - [ ] I have explained the changes or the new features added to this PR
 - [ ] I have added **e2e test cases** corresponding to this change
 - [ ] I have updated the documentation to reflect this change

**NOTE: This PR will not be reviewed and merged until the contents of
these checklists are completed.**

---------

Co-authored-by: AlinsRan <[email protected]>
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.

bug: restart etcd admin api /apisix/admin/routes response is error

4 participants