`az aks get-credentials` writes to stderr on successful acquisition starting in 2.27.1
See original GitHub issueDescribe the bug
az aks get-credentials
writes to stderr when merging kubernetes context into file starting in Azure CLI version 2.27.1
To Reproduce
az aks get-credentials --subscription ***** --resource-group ***** --name ***** --file 'test.kubeconfig' --admin 1> 'test.kubeconfig.stdout' 2> 'test.kubeconfig.stderr'
The test.kubeconfig.stdout file is empty but the test.kubeconfig.stderr file contains WARNING: Merged "*****" as current context in *****\test.kubeconfig
. The test.kubeconfig file did not exist before executing the get-credentials
command.
Expected behavior
The command should not write to stderr when no issue occurs. This message used to be written to stdout (Merged "*****" as current context in *****\test.kubeconfig
) instead of stderr in 2.27.0 and prior.
Environment summary Install method: MSI CLI Version: 2.27.2 OS Version: Windows 10 Shell Type: pwsh.exe on Windows
Additional context This started to cause Azure DevOps deployments to fail on August 18th because our tasks by default fail when stderr lines are detected. Tested that this issue reproduces in both Azure DevOps Azure CLI Task 2.1.1 as well as on a local machine.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
I would contend that:
diagnostics issued by the program
portion of the explanation is not acceptable. What remains iswhich is used for error messages
; the message is not not an error. Since it does not meet either explanation, it should not be written to stderr under these conditions.Merged "*****" as current context in *****\test.kubeconfig
should only reasonably be a written when credentials were actually merged into an existing file, not when writing into a new file. This warning is being written out when the file doesn’t exist in the first place.I’ve already mitigated this issue by using
--only-show-errors
. I will not setfailOnStderr: false
so that we can catch other actual errors when they occur.I think the script which call the commands should not depends on whether the stderr is empty or not. we should only check the exit code and so on. but there’s one option --only-show-errors may help in this case.