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

Avoid misleading error message from qemu-img #1372

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

perlpunk
Copy link
Contributor

@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #1372 into master will increase coverage by 1.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1372      +/-   ##
==========================================
+ Coverage   62.38%   63.58%   +1.19%     
==========================================
  Files          52       52              
  Lines        6187     6189       +2     
==========================================
+ Hits         3860     3935      +75     
+ Misses       2327     2254      -73     
Impacted Files Coverage Δ
OpenQA/Qemu/Proc.pm 76.32% <100.00%> (+0.23%) ⬆️
consoles/vnc_base.pm 47.47% <0.00%> (+1.01%) ⬆️
backend/qemu.pm 51.43% <0.00%> (+1.18%) ⬆️
consoles/VNC.pm 54.78% <0.00%> (+1.52%) ⬆️
backend/baseclass.pm 74.74% <0.00%> (+7.63%) ⬆️
consoles/sshIucvconn.pm 36.00% <0.00%> (+16.00%) ⬆️
consoles/network_console.pm 100.00% <0.00%> (+16.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b5e117...ad2f058. Read the comment docs.

@okurz
Copy link
Member

okurz commented Mar 26, 2020

Let's try again :)

@okurz okurz merged commit 0e70620 into os-autoinst:master Mar 26, 2020
@perlpunk perlpunk deleted the qemu-img-fail2 branch March 26, 2020 20:10
# 1 even for a successful command on ppc
# Did we get JSON or an error message?
my $map = eval { decode_json($json) };
if (my $err = $@) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $err is unused.

my $map = decode_json($json);
# We can't check the exit code of qemu-img, because it sometimes returns
# 1 even for a successful command on ppc
# Did we get JSON or an error message?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't ask questions in comments. What about:

# determine whether we've got JSON or an error message
# note: We can't check the exit code of qemu-img because it sometimes returns 1 even
#       on success under PowerPC.

okurz added a commit to okurz/os-autoinst that referenced this pull request Mar 30, 2020
…dler

os-autoinst#1370 was the original approach
which we reverted after encountering problems relying on the exit code of
qemu-img, especially on ppc64le. Instead we went with
os-autoinst#1372 which ended up not really
addressing the original problem of preventing the confusing JSON parsing error
when we erroneously try to parse an error string as JSON. This commit addresses
all the following:

* Replace a question in the comment by a statement as we should not ask the
  reader a question from source code
* Delete unused variable "$err"
* Prevent any error output from "decode_json"
* Ensure to output the error message from qemu-img once and only after "Backend
  process died", this addresses
os-autoinst#1370 (comment)

Also verified manually with

```
isotovideo -d iso=/dev/shm/ flavor=DVD casedir=/var/lib/openqa/tests/opensuse
```

Old output:

```
[2020-03-30T16:40:31.535 CEST] [debug] running /usr/bin/qemu-img info --output=json /dev/shm/
[2020-03-30T16:40:31.609 CEST] [debug] qemu-img: Could not open '/dev/shm/': A regular file was expected by the 'file' driver, but something else was given
[2020-03-30T16:40:31.609 CEST] [debug] Backend process died, backend errors are reported below in the following lines:
malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "qemu-img: Could not ...") at /usr/lib/perl5/vendor_perl/5.26.1/Mojo/JSON.pm line 39.

```

Example output:

```
[2020-03-30T16:39:20.498 CEST] [debug] running /usr/bin/qemu-img info --output=json /dev/shm/
[2020-03-30T16:39:20.508 CEST] [debug] Backend process died, backend errors are reported below in the following lines:
qemu-img: Could not open '/dev/shm/': A regular file was expected by the 'file' driver, but something else was given

```

Related progress issue: https://progress.opensuse.org/issues/64854
@okurz
Copy link
Member

okurz commented Mar 30, 2020

Somehow this PR managed to not address the original problem at all and I completely overlooked this. See #1376 for another approach by me.

@Martchus This also addresses both your concerns.

@perlpunk
Copy link
Contributor Author

Somehow this PR managed to not address the original problem at all

Then the original problem was not explained enough in the issue ;-)

@okurz
Copy link
Member

okurz commented Mar 30, 2020

sorry if https://progress.opensuse.org/issues/64854 wasn't clear enough. The idea was simply that there is no error about malformed JSON. This is what the acceptance criterion describes and actually you nailed it in #1370 and I have not realized you "brought back" that error line in this PR including a test covering this. I hope you like #1376

@perlpunk
Copy link
Contributor Author

I didn't bring back the error message. It will not be in the log, it's hidden by eval, but it's still counted as a warning in the test due to the warnings handler.

@okurz
Copy link
Member

okurz commented Mar 31, 2020

And yet it is still visible in openQA tests, e.g. see https://openqa.opensuse.org/tests/1215921 as written in https://progress.opensuse.org/issues/64854#note-10

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 this pull request may close these issues.

3 participants