thoughtspot / cs_tools

Scale your ThoughtSpot adoption with tools created by the ThoughtSpot Solutions Consulting organization.
https://thoughtspot.github.io/cs_tools/
Other
8 stars 6 forks source link

Exit with error code when encountering errors + readable log in GitHub Action #161

Closed sp-aaflalo closed 1 month ago

sp-aaflalo commented 1 month ago

First Stop

Platform Configuration

╭──────────────────────────────────────────────────────────────────────────────╮
│                                                                              │
│           Info snapshot taken on 2024-07-29                                  │
│                                                                              │
│               CS Tools: 1.5.9                                                │
│         Python Version: Python 3.12.4 (main, Jul 15 2024, 21:50:45) [GCC     │
│    11.4.0]                                                                   │
│            System Info: Linux (detail:                                       │
│    Linux-6.5.0-1024-azure-x86_64-with-glibc2.35)                             │
│      Configs Directory: /home/ {anonymous} /.config/cs_tools                 │
│    Activate VirtualEnv: source                                               │
│    "/opt/hostedtoolcache/Python/3.12.4/x64/bin/activate"                     │
│     System Python Path: /opt/hostedtoolcache/Python/3.12.4/x64/bin/python    │
│          Platform Tags: linux-x86_64                                         │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

Description

Couple of annoyance with the CLI tool:

  1. Doesn't return an exit error code like -1 on any encountered error.
  2. When error are triggered, they can't be read inside the log of the github action
    ┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    ┃ File Name              ┃ Status ┃ Message                                     
    ┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    │ 21b98abf-8fa5-43d5-b7… │ ERROR  │ Visualization <b> Viz_1 </b> has following e
    │                        │        │ <b>NAME_OF_LIVEBOARD</b><br/><b
    │                        │        │ 21653e13-6c[17](https://github.com/XXX/XXX/actions/runs/XXX/job/XXXX#step:5:18)-44db-8372-62a983d44f0a found f
    └────────────────────────┴────────┴─────────────────────────────────────────────

It makes the tool hard to use in the context of a CI/CD.

Need to upload log files securely?

No response

boonhapus commented 1 month ago

@sp-aaflalo ACK on this one -- let me sync with the author of this tool on when this can be improved.

Will put it in the next release as well, but will the changes will involve using logging as opposed to stdout for warnings/errors .. the nonzero error code is partially a byproduct of the current alerting approach in this tool, so that should get fixed as well. Generally, if an error occurs, we should be returning a 1 for error state (known or unknown errors), or a 0 for success.

sp-aaflalo commented 1 month ago

Thanks for implementing proper error code (and yes, 1 not -1, thanks for the correction).

About logging, only command I can find relating to it is cs_tools logs report but that doesn't provide any error in the log, only the log of the request etc ...

Is there another settings to get a log file with errors ?

boonhapus commented 1 month ago

This is something that will need to be changed in the tool's code itself. Right now, a lot of the output it going to terminal stdout (eg. printing it) instead of logged stdout. The update should bring this tool back in line with logging relevant info, rather than printing it.

cs_tools logs report --latest K <path> simply copies K number of files from /home/ {anonymous} /.config/cs_tools/.logs to the path that you specify in <path>.