ruanweihong-aaa commented on issue #13685:
URL: https://github.com/apache/apisix/issues/13685#issuecomment-6409507165

   The relevant APISIX code is in [`apisix/cli/file.lua` in the 3.19.0 
release](https://github.com/apache/apisix/blob/473043623c161966f3f6ef4e8f12d2d8667a12d2/apisix/cli/file.lua#L93-L103):
   
   ```lua
   local function resolve_conf_var_in_text(text)
       local new_text, _, err = var_sub(text)
       if err then
           return nil, err
       end
       return new_text
   end
   ```
   
   This calls `var_sub` on the raw YAML text before parsing. 
[`var_sub`](https://github.com/apache/apisix/blob/473043623c161966f3f6ef4e8f12d2d8667a12d2/apisix/cli/file.lua#L60-L90)
 matches `${{...}}` and reads the environment variable without distinguishing 
YAML comments. Consequently, this line still triggers a lookup when the 
variable is unset:
   
   ```yaml
   # ${{MY_ENV_VAR}}
   ```
   
   I also reproduced this with an actual Helm Chart **2.18.2** installation in 
Kubernetes, using its default image tag **apache/apisix:3.19.0-ubuntu**, 
file-driven Standalone mode, and no patch:
   
   - The control configuration started and returned HTTP 200.
   - Adding `# ${{REV13686_MISSING}}` inside 
`apisix.deployment.standalone.config` caused startup to fail with:
     ```text
     failed to read local yaml config of apisix: failed to handle 
configuration: can't find environment variable REV13686_MISSING
     ```
   - The comment was present in the mounted `apisix.yaml`, and the variable was 
absent from the container environment.
   - Adding it through a ConfigMap update to a running instance rejected the 
update and retained the old route; removing it allowed the new configuration to 
load without restarting the Pod.
   
   The parser file read from the Pod matched the 3.19.0 release source 
byte-for-byte. The image was already cached on the test node, consistent with 
the chart's default `IfNotPresent` policy.
   
   Chart 2.18.2 [preserves the standalone configuration string in its 
ConfigMap](https://github.com/apache/apisix-helm-chart/blob/53115d6ab51e14eec55d0689ad7e70c28b6ce11f/charts/apisix/templates/apisix-config-cm.yml#L23-L25);
 it does not remove comments inside that string. A comment outside that string 
in the Helm values file is a different case: Helm discards it while reading 
values.
   
   This does not explain the successful deployment reported above without its 
exact values and effective configuration, but the original failure remains 
reproducible with Chart 2.18.2 on this file-driven configuration path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to