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

--fileoutput flag creates empty file when using table formatter #225

Closed
dgdevops opened this issue Mar 6, 2024 · 8 comments
Closed

--fileoutput flag creates empty file when using table formatter #225

dgdevops opened this issue Mar 6, 2024 · 8 comments

Comments

@dgdevops
Copy link
Contributor

dgdevops commented Mar 6, 2024

Describe the bug
When using the --fileoutput flag with or without specifying the --formatter table option the script succeeds but creates a 0 byte file with no content.

To Reproduce
Steps to reproduce the behavior:

  1. Install/build version 1.7.1/1.7.0
  2. Run the script with default parameters and with the --fileoutput ./<your-file-name> flag specified
  3. Check the size & content of the output file (0 bytes in size, zero content)

Expected behavior
The script should write out the table content to the desired output file.

Are you interested in contributing a fix for this?
Yes

Desktop (please complete the following information):

  • OS: MacOS
  • Version [1.7.1]

Additional context
Changing the --formatter flag to json, yaml, pprint results in correct file output.
As a result of this issue Slack reports cannot be sent in table format.
I have tested 1.5.3 and it works perfectly so something broke in version 1.6.0.

@dgdevops dgdevops changed the title The --fileoutput flag does not work with table formatter --fileoutput flag does not work with table formatter Mar 7, 2024
@dgdevops dgdevops changed the title --fileoutput flag does not work with table formatter --fileoutput flag created empty file when using table formatter Mar 7, 2024
@dgdevops dgdevops changed the title --fileoutput flag created empty file when using table formatter --fileoutput flag creates empty file when using table formatter Mar 7, 2024
@dgdevops
Copy link
Contributor Author

Hello @aantn,
Is there a way to get this prioritised?
It is a main functionality that broke in the new version.

@aantn
Copy link
Contributor

aantn commented Mar 14, 2024

Hi @dgdevops,
As a workaround is it possible to use --quiet and pipe output from stdout to a file?

@dgdevops
Copy link
Contributor Author

Hello @aantn,
Thank you for your quick response.
To test this I split the action into two parts:

  1. Write out the output to a file (krr simple --prometheus-url http://localhost:53312 --quiet >> myfile)
  2. Repeat the command with the --slackoutput flag specified with value matching the name of the file that was written out in step 1): krr simple --prometheus-url http://localhost:53312 --quiet --slackoutput myfile

The second command overwrote the content of myfile so basically the content of the file was zeroized.

@aantn
Copy link
Contributor

aantn commented Mar 14, 2024

Got it. Just to clarify, it works OK for your use case with --quiet?

@dgdevops
Copy link
Contributor Author

dgdevops commented Mar 14, 2024

Using the --quiet flag on its own (krr simple --prometheus-url http://localhost:53312 --quiet --fileoutput myfile) still results in an empty file so I have to use >> to write out the output from stdout as you suggested. My initial intention with this GitHub issue was to find a workaround or implement a fix for the slack reporting that relies on file output, the --quite flag suggested above does not address this issue.

@aantn
Copy link
Contributor

aantn commented Mar 14, 2024

I've added a fix in #231. Can you confirm that it works?

@dgdevops
Copy link
Contributor Author

dgdevops commented Mar 14, 2024

Hello @aantn,
I have tested it and both the --fileoutput & --slackoutput flags work fine.
Thank you for your quick action.

One idea, when using the table formatter there is no information (name) about the cluster the information was gathered from, when using the JSON formatter for example there is a dedicated cluster_name field. Instead of displaying the namespace in the Slack message (https://github.com/robusta-dev/krr/blob/main/robusta_krr/core/runner.py#L102) the message should rather contain the name of the cluster as the namespace is part of the report regardless of the formatter used and it is currently redundant but the cluster name is not.

@aantn
Copy link
Contributor

aantn commented Mar 14, 2024 via email

@aantn aantn closed this as completed Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants