Skip to content

Improve the loggingΒ #336

@greg0ire

Description

@greg0ire

In my company, we use envconsul in Docker entrypoint, as follows:

envconsul /path/to/some/binary

We use AWS's spot instances, which means our cronjob might get interrupted (as in, envconsul will receive a SIGTERM) at any time. Our SRE team knows about this, and did communicate with our development team about it, but it's hard to keep that in mind.

So when an interruption happens, we get very few logs. Some of them are from containerd, saying that Task xxxx has exited with exit code 12, and before that, we get a log from envconsul, that says: Cleaning up..., and that's it:

envconsul/cli.go

Lines 186 to 189 in d39537a

case *cfg.KillSignal:
fmt.Fprintf(cli.errStream, "Cleaning up...\n")
runner.Stop()
return ExitCodeInterrupt

Now when using unix tools, there seems to be a handy convention that consists in printing the name of the tool that encounters an error, that way, if you have an error in a pipeline, there is some indication about what tool is having an issue:

$ echo 'hi'|grep a b
grep: b: No such file or directory

I have 2 suggestions:

  1. Improve the logging so that every log is prefixed with envconsul: or add a flag allowing to do so.
  2. Improve that particular log so that it includes the Signal that was received: Received SIGTERM. Cleaning up...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions