apache / apache/apisix

bug: APISIX rewrites yaml configuration file to cause restarting errors

Open
#12,170 26 comments 0 reactions 1 assignee Assigned to @AlinsRan View on GitHub
bug
Dominant language
Lua
Stars
17.1k
Forks
2.9k
Avg merge
3d 16h
Merged PRs (30d)
63

Description

### Current Behavior

APISIX generates and writes a configuration file when the Admin API key is empty, which causes the configuration file to be exported from memory and encoded in YAML and then written.
https://github.com/apache/apisix/blob/master/apisix/core/id.lua#L124-L133
During this process, comments in the configuration file will be lost, and some will be generated containing `...` ending, which will result in an error on the next startup.

### Expected Behavior

Configuration files should not be rewritten in any way. If the Admin API key is empty, we need to write it to the logs and also warn the user there that you need to configure your own key, otherwise every reboot will cause the key to change.

### Error Logs

No need

### Steps to Reproduce

1. Set `deployment.admin.admin_key` in the configuration file to the empty string
2. Start APISIX
3. Check config.yaml

### Environment

- APISIX version (run `apisix version`): master
- Operating system (run `uname -a`): unrelated
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): unrelated
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): unrelated
- APISIX Dashboard version, if relevant: unrelated
- Plugin runner version, for issues related to plugin runners: unrelated
- LuaRocks version, for installation issues (run `luarocks --version`): unrelated

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.