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

Running into issues with logging on Ubuntu 16.04 #15

Open
tinoadams opened this issue Aug 31, 2020 · 2 comments · May be fixed by #18
Open

Running into issues with logging on Ubuntu 16.04 #15

tinoadams opened this issue Aug 31, 2020 · 2 comments · May be fixed by #18

Comments

@tinoadams
Copy link

Running av apply --log-level debug (working) gives different result than av apply (broken).

Not providing a log level argument causes the following error:

2020-08-31 13:20:40.768 | ERROR | The command `LSLOG 10 2>&1` exited with exit code 141
2020-08-31 13:20:40.770 | ERROR | Failed

Here is a minimal example to reproduce the issue: https://github.com/tinoadams/aviary-test

@emmetog
Copy link

emmetog commented Oct 2, 2020

Also reproducible on Ubuntu 20.04:

# av apply --inventory ./infrastructure-aviary/ --log-level debug
2020-10-02 15:25:55.203 | INFO | Using local inventory /<redacted>/infrastructure-aviary
2020-10-02 15:25:55.257 | INFO | Running apply
2020-10-02 15:25:55.262 | INFO | Applying module test
2020-10-02 15:25:55.271 | DEBUG | Testing
2020-10-02 15:25:55.286 | INFO | Done
# av apply --inventory ./infrastructure-aviary/
2020-10-02 15:26:00.556 | INFO | Using local inventory /<redacted>/infrastructure-aviary
2020-10-02 15:26:00.602 | INFO | Running apply
2020-10-02 15:26:00.604 | INFO | Applying module test
2020-10-02 15:26:00.608 | ERROR | The command `LSLOG 10 2>&1` exited with exit code 141
2020-10-02 15:26:00.609 | ERROR | Failed
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal

@emmetog
Copy link

emmetog commented Oct 2, 2020

Seems to be because of this line at the very top of av:

set -euo pipefail

Removing this line seems to let things work as they should, but I'm not enough of a bash expert to know if removing it will break something else.

The actual bit of code that is breaking is here, in ./log:

  [[ $# -ne 0 ]] && _MSG="$@" || _MSG="$(cat)"
  if [[ "$LS_OUTPUT" = "/dev/stdout" ]] ; then
    echo -ne "$_LS_LEVEL_BEGIN$OUTPUT "
    echo -ne  "$_MSG"
    echo -e "$_LS_LEVEL_END"
  elif [[ "$LS_OUTPUT" = "/dev/stderr" ]] ; then
    echo -ne "$_LS_LEVEL_BEGIN$OUTPUT " >&2
    echo -ne  "$_MSG" >&2
    echo -e "$_LS_LEVEL_END" >&2
  else
    echo -ne "$_LS_LEVEL_BEGIN$OUTPUT " >> "$LS_OUTPUT"
    echo -n  "$_MSG"                    >> "$LS_OUTPUT"
    echo -e "$_LS_LEVEL_END" >> "$LS_OUTPUT"
  fi

Things break on the line echo -ne "$_MSG" >&2. Again unfortunately I'm not expert enough to suggest what the most appropriate fix is apart from removing set -euo pipefail as above.

emmetog added a commit to emmetog/aviary.sh that referenced this issue Oct 2, 2020
emmetog added a commit to emmetog/aviary.sh that referenced this issue Oct 2, 2020
@emmetog emmetog linked a pull request Oct 2, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants