Skip to content

fix(admin): use local config to fetch global rules in standalone mode#13122

Open
janiussyafiq wants to merge 7 commits intoapache:masterfrom
janiussyafiq:fix/standalone-connect-etcd
Open

fix(admin): use local config to fetch global rules in standalone mode#13122
janiussyafiq wants to merge 7 commits intoapache:masterfrom
janiussyafiq:fix/standalone-connect-etcd

Conversation

@janiussyafiq
Copy link
Copy Markdown
Contributor

Description

In standalone mode (config_provider: yaml), the get_global_rules() function in apisix/admin/global_rules.lua unconditionally calls core.etcd.get("/global_rules") to check for duplicate plugin conflicts whenever a global rule is validated. This is triggered on every PUT /apisix/admin/configs request from the ingress-controller that contains a global_rules entry, causing repeated etcd connection errors in the logs even though etcd is not used in standalone mode.

Root cause: check_conf calls get_global_rules() which has no awareness of the current config provider, so it always attempts an etcd read regardless of deployment mode.

Fix: guard get_global_rules() to return nil immediately when local_conf.deployment.config_provider == "yaml", skipping the etcd call entirely. This is safe because returning nil causes check_conf to skip the conflict loop (already guarded by if global_rules then), and in standalone mode the ingress-controller is responsible for sending a consistent config atomically.

Which issue(s) this PR fixes:

Fixes #12989

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)

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Mar 27, 2026
Baoyuantop
Baoyuantop previously approved these changes Mar 27, 2026
@janiussyafiq janiussyafiq force-pushed the fix/standalone-connect-etcd branch from 6bfd931 to fe9e2e2 Compare March 31, 2026 01:00

local function get_global_rules()
local local_conf = core.config.local_conf()
if local_conf.deployment.config_provider == "yaml" 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.

get_global_rules is used to check if the incoming global rule conflicts with existing global rules, skipping the check entirely doesn't seem correct.

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.

that is right, good catch! should still get the global rules for standalone mode cases to prevent warning log from checking etcd. will do the fix

@janiussyafiq janiussyafiq changed the title fix(admin): skip etcd call in global_rules validation for standalone mode fix(admin): use local config to fetch global rules in standalone mode Apr 3, 2026
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 3, 2026
@janiussyafiq janiussyafiq force-pushed the fix/standalone-connect-etcd branch from 648ef51 to 240555d Compare April 3, 2026 03:25
@janiussyafiq janiussyafiq requested a review from Baoyuantop April 3, 2026 08:00
Baoyuantop
Baoyuantop previously approved these changes Apr 7, 2026

local function get_global_rules()
local local_conf = core.config.local_conf()
if local_conf.deployment.config_provider == "yaml" then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The judgment of deployment.config_provider == "yaml" is not comprehensive, as its value can also be json. We can encapsulate a function to determine whether the current config_provider is local.

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.

fixed

@janiussyafiq janiussyafiq requested a review from nic-6443 April 8, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Apisix 3.15.0 tries to connect to etcd in standalone api-driven mode (non crashing)

4 participants