Sometimes the ARGOCD_APP_NAMESPACE environment variable isn't set when a CMP's discover.find.command is executed.
To Reproduce
Create a CMP that tells you the the environment variables. Mine looks like this:
# To be put in /home/argocd/cmp-server/config/plugin.yaml
# Read also https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/#sidecar-plugin
apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
name: nyl
spec:
# note: Plugin name in ArgoCD will be `nyl-v1`.
version: v1
discover:
find:
command:
- sh
- -c
- 'nyl --log-file=/var/log/nyl/${ARGOCD_APP_NAMESPACE}-${ARGOCD_APP_NAME}.log argocd discovery'
# init:
# command:
# - sh
# - -c
# - |
# nyl version >&2
# argocd version --client >&2
generate:
command:
- sh
- -c
- 'nyl --log-file=/var/log/nyl/${ARGOCD_APP_NAMESPACE}-${ARGOCD_APP_NAME}.log template --in-cluster .'
parameters: {}
# If set to `true` then the plugin receives repository files with original file mode. Dangerous since the repository
# might have executable files. Set to true only if you trust the CMP plugin authors.
preserveFileMode: false
What I find is that for every application, there is a variant without the namespace:
Looking through these files, it seems they are only from invoking the discover.find.command. However, I can also find logs about discover.find.command where the namespace is set. From the behaviour I've observed so far, this appears to maybe be an issue only immediately after the argocd-repo-server restarted.
The debug logs of my CMP also log all environment variables beginning with ARGOCD where you can also confirm that ARGOCD_APP_NAMESPACE is not set:
Checklist:
argocd version
.Describe the bug
Sometimes the
ARGOCD_APP_NAMESPACE
environment variable isn't set when a CMP'sdiscover.find.command
is executed.To Reproduce
Create a CMP that tells you the the environment variables. Mine looks like this:
What I find is that for every application, there is a variant without the namespace:
Looking through these files, it seems they are only from invoking the
discover.find.command
. However, I can also find logs aboutdiscover.find.command
where the namespace is set. From the behaviour I've observed so far, this appears to maybe be an issue only immediately after theargocd-repo-server
restarted.The debug logs of my CMP also log all environment variables beginning with
ARGOCD
where you can also confirm thatARGOCD_APP_NAMESPACE
is not set:Expected behavior
In
/var/log/nyl
I can only find files formatted as{namespace}-{name}.log
because theARGOCD_APP_NAMESPACE
is always set.Version