Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMP write to container log #15921

Closed
peschmae opened this issue Oct 12, 2023 · 7 comments · Fixed by #15973
Closed

CMP write to container log #15921

peschmae opened this issue Oct 12, 2023 · 7 comments · Fixed by #15973
Labels
enhancement New feature or request

Comments

@peschmae
Copy link
Contributor

Summary

Currently it's not possible to write any logs from within the commands run in the CMP sidecars.
Everything written to stdout is passed to kubectl while the things written to stderr are only visible if the commands fail.

Motivation

To enable easier debugging it would be great to be able to write some logs from the commands within CMP.

In our setup we had a sidecar that sometimes stopped processing the repos, and we don't have a way to debug it, beside writting into a log file within the sidecar and check that from a shell.
Beeing able to write some logs from a plugin sidecar command, would be really helpful.

Proposal

One way to implement this, would be to provide an additional command for the cmp-plugin-server, that can be called with the log level (and thus beeing able to respect the configured log level) and the message, eg
/var/run/argocd/argocd-cmp-server log --level=DEBUG --msg="Hello world"

Another alternative might be to have a pipe, that is always just written to the container logs by the cmp-server, but then the handling of the log level would need to be done by command itself, and the log level would need to be exposed to the commands somehow (or make the loglevel for the cmp-server configurable through an environment variable, that can then be read from the commands)

@peschmae peschmae added the enhancement New feature or request label Oct 12, 2023
@peschmae
Copy link
Contributor Author

This would also make development of sidecars easier and would support #15006

@crenshaw-dev
Copy link
Member

How about logging to stdout? Argo CD could pick that up and write it directly to the sidecar logs, regardless of whether the generate command succeeds.

@peschmae
Copy link
Contributor Author

How about logging to stdout? Argo CD could pick that up and write it directly to the sidecar logs, regardless of whether the generate command succeeds.

This would be the easiest solution, but currently CMP assumes that everything written to stdout is a kubernetes object, in either YAML or JSON, at least according to the documentation: https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/#write-the-plugin-configuration-file

Maybe logging to stderr and forwarding that to the sidecar logs, regardless of the command exit code, would be an alternative.

@crenshaw-dev
Copy link
Member

Ah, yep, I meant stderr. Yay Friday brain. I think that would be a fine solution!

@peschmae
Copy link
Contributor Author

Ah, yep, I meant stderr. Yay Friday brain. I think that would be a fine solution!

That would also be quite easy to implement I think.

Looking at the code in the cmpserver/plugin I think it just needs an additional log statement for the success cases around here: https://github.com/argoproj/argo-cd/blob/master/cmpserver/plugin/plugin.go#L123

If you're open to this change, I would create a pull request for it.
I might however need some pointers how to write a test for it, if that's needed. I couldn't see another test that handles stderr/stdout in the plugin_test.go file, but maybe I missed something

@crenshaw-dev
Copy link
Member

Yep, please open a PR! For just some logging, I think we're okay without a test

@peschmae
Copy link
Contributor Author

I've opened the pull request
@crenshaw-dev would it be possible to get that int 2.9 or is that too late as there are already RCs out?

crenshaw-dev pushed a commit that referenced this issue Oct 23, 2023
…15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
gcp-cherry-pick-bot bot pushed a commit that referenced this issue Oct 23, 2023
…15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
crenshaw-dev pushed a commit that referenced this issue Oct 23, 2023
…15973) (#16075)

* feat(cmp): Print stderr output from command even on success



* docs(cmp): Document logging from cmp sidecard for development purposes



---------

Signed-off-by: Mathias Petermann <[email protected]>
Co-authored-by: Mathias Petermann <[email protected]>
thomassandslyst pushed a commit to thomassandslyst/argo-cd that referenced this issue Oct 26, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
thomassandslyst pushed a commit to thomassandslyst/argo-cd that referenced this issue Oct 26, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
Signed-off-by: Thomas Sands <[email protected]>
crenshaw-dev pushed a commit that referenced this issue Oct 26, 2023
…15973) (#16124)

* feat(cmp): Print stderr output from command even on success



* docs(cmp): Document logging from cmp sidecard for development purposes



---------

Signed-off-by: Mathias Petermann <[email protected]>
Signed-off-by: Thomas Sands <[email protected]>
Co-authored-by: Mathias Petermann <[email protected]>
ymktmk pushed a commit to ymktmk/argo-cd that referenced this issue Oct 29, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
jmilic1 pushed a commit to jmilic1/argo-cd that referenced this issue Nov 13, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
Signed-off-by: jmilic1 <[email protected]>
vladfr pushed a commit to vladfr/argo-cd that referenced this issue Dec 13, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
tesla59 pushed a commit to tesla59/argo-cd that referenced this issue Dec 16, 2023
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this issue Jun 16, 2024
…#15921) (argoproj#15973)

* feat(cmp): Print stderr output from command even on success

Signed-off-by: Mathias Petermann <[email protected]>

* docs(cmp): Document logging from cmp sidecard for development purposes

Signed-off-by: Mathias Petermann <[email protected]>

---------

Signed-off-by: Mathias Petermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants