argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.47k stars 5.31k forks source link

Provide way for sidecar plugin to persist git repository for debugging purposes #18547

Open paololazzari opened 3 months ago

paololazzari commented 3 months ago

Summary

Add option to persist git repository on filesystem on sidecar plugin execution.

Motivation

I am seeing diffs for a bunch of secrets in the argo UI, which I do not see locally when running kustomize locally and then diffing against the cluster. To debug this, it would be helpful if I could run the same commands the plugin is running in the plugin container itself.

Currently this is awkward to do because the plugin does not persist the git repository in /tmp/_cmp_server. I've been able to cp the repository during the plugin execution from /tmp/_cmp_server during the execution but this is not ideal.

Proposal

Add option to plugin configuration, e.g.:

apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
  name: pluginName
spec:
  init:
    command: ["sample command"]
    args: ["sample args"]
  generate:
    command: ["sample command"]
    args: ["sample args"]
  preserveRepository: true
crenshaw-dev commented 3 months ago

tbh I think the cp hack is the way to go. It's the same thing we'd implement in go, and it's not something people should be doing long term.

paololazzari commented 3 months ago

@crenshaw-dev I could only do it because the plugin took some time to execute

crenshaw-dev commented 3 months ago

Ah you exec'd in. I'd recommend including the cp at the end of your generate command.

paololazzari commented 3 months ago

It's the same thing we'd implement in go, and it's not something people should be doing long term.

Ok, fair enough. Should there maybe be a note in the docs to mention how the sidecar concontainer plugin execution can be troubleshooted?

crenshaw-dev commented 3 months ago

Probably, I'd happily review that docs PR!