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

avocado jobs command is broken #6067

Open
richtja opened this issue Nov 8, 2024 · 2 comments
Open

avocado jobs command is broken #6067

richtja opened this issue Nov 8, 2024 · 2 comments
Assignees
Labels

Comments

@richtja
Copy link
Contributor

richtja commented Nov 8, 2024

Describe the bug
The avocado jobs command makes avocado crash. Bout avocado jobs list and avocado jobs show is broken.

Steps to reproduce
Just run avocado jobs list or avocado jobs show latest

Expected behavior
Avocado will provide useful information, and it won't crash.

Current behavior

$ avocado jobs list
...
abb1d9a7875e6dde3ad96fd4976a4c4bedb246bb 2024-10-30 10:44:49.229156   1 (0/0/1/0)
dc68076acdaa2ceb7a1f5b2a06164863f02abb91 2024-10-30 10:44:00.593955   1 (0/0/0/0)
64ca178a72bef056fc859b07fb5b648e49f8d60e 2024-10-30 10:43:51.515882   1 (0/0/0/0)
d34143063b6fb1611609e794154d7514beaa5c23 2024-10-29 16:19:51.930934   2 (2/0/0/0)
Avocado crashed unexpectedly: 'start'
Traceback (most recent call last):
  File "/home/janrichter/.pyenv/versions/avocado/bin/avocado", line 33, in <module>
    sys.exit(load_entry_point('avocado-framework', 'console_scripts', 'avocado')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 189, in run
    return self.handle_list_command(results)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 122, in handle_list_command
    job["start"],
    ~~~^^^^^^^^^
KeyError: 'start'

You can also find details in /home/janrichter/avocado/data/crashes/avocado-traceback-2024-11-08_11:11:50-45p8yhss.log
$ avocado jobs show latest
JOB ID      : latest
JOB LOG     : /home/janrichter/avocado/job-results/job-2024-11-07T14.26-c5f4066/job.log

Avocado crashed unexpectedly: 'NoneType' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/janrichter/.pyenv/versions/avocado/bin/avocado", line 33, in <module>
    sys.exit(load_entry_point('avocado-framework', 'console_scripts', 'avocado')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 191, in run
    return self.handle_show_command(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 157, in handle_show_command
    self._print_job_tests(results_data.get("tests"))
  File "/home/janrichter/Avocado/avocado/avocado/plugins/jobs.py", line 60, in _print_job_tests
    end = datetime.fromtimestamp(test.get("actual_end", test.get("end")))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

You can also find details in /home/janrichter/avocado/data/crashes/avocado-traceback-2024-11-08_11:14:57-cj90psur.log

System information (please complete the following information):

  • OS: Fedora 40
  • Avocado version: master
  • Avocado installation method: github
@richtja richtja added the bug label Nov 8, 2024
@mr-avocado mr-avocado bot moved this to Triage in Default project Nov 8, 2024
@clebergnu
Copy link
Contributor

The avocado jobs list breakage can be seen only when "job results" content is created across multiple versions of Avocado. Example:

$ python3 -m pip install avocado-framework=92.3
...
$ avocado run /bin/true
...
$ python3 -m pip install avocado-framework==108.0
$ avocado jobs list
avocado jobs list
Avocado crashed unexpectedly: 'start'
Traceback (most recent call last):
  File "/usr/local/bin/avocado", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 189, in run
    return self.handle_list_command(results)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 122, in handle_list_command
    job["start"],
    ~~~^^^^^^^^^
KeyError: 'start'

You can also find details in /root/avocado/data/crashes/avocado-traceback-2024-11-12_12:32:41-9yvth7dc.log

The expected behavior here is to not crash, possibly skipping the info that was not obtained.

Now, even with a single version of Avocado generating job results, there's a possible crash with:

$ python3 -m pip install avocado-framework==108.0
$ avocado run /bin/true 
JOB ID     : 1849848b22a44828889c6b0f2648107fc55264b1
JOB LOG    : /root/avocado/job-results/job-2024-11-12T18.14-1849848/job.log
 (1/1) /bin/true: STARTED
 (1/1) /bin/true: PASS (0.01 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 0.51 s

Followed by:

$ avocado jobs show latest
JOB ID      : latest
JOB LOG     : /root/avocado/job-results/job-2024-11-12T18.14-1849848/job.log

Avocado crashed unexpectedly: 'NoneType' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/usr/local/bin/avocado", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/main.py", line 86, in main
    return app.run()
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/core/app.py", line 111, in run
    return method(self.parser.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 191, in run
    return self.handle_show_command(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 157, in handle_show_command
    self._print_job_tests(results_data.get("tests"))
  File "/usr/local/lib/python3.12/site-packages/avocado/plugins/jobs.py", line 60, in _print_job_tests
    end = datetime.fromtimestamp(test.get("actual_end", test.get("end")))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

You can also find details in /root/avocado/data/crashes/avocado-traceback-2024-11-12_18:14:42-6o_shh4c.log

@richtja
Copy link
Contributor Author

richtja commented Nov 13, 2024

Hi @clebergnu, thanks for the testing. So IIUIC the avocado jobs show latest is not some corner case with corrupted test results, it just simply doesn't work on avocado 108. Therefore, I will move this into current milestone as any other normal bug.

@richtja richtja moved this from Triage to Short Term (Current Q) Backlog in Default project Nov 13, 2024
@richtja richtja added this to the 109 - Codename TBD milestone Nov 13, 2024
@harvey0100 harvey0100 self-assigned this Nov 29, 2024
harvey0100 added a commit to harvey0100/avocado that referenced this issue Dec 2, 2024
Fix: Handle missing job data in 'avocado jobs list' command
- Updated 'handle_list_command' to use `job.get()` for safely accessing job data.
- If a key is missing, it now defaults to 'N/A' instead of causing a crash.

Reference:      avocado-framework#6067
Signed-off-by: Harvey Lynden <hlynden@redhat.com>
harvey0100 added a commit to harvey0100/avocado that referenced this issue Dec 2, 2024
Fix: Handle missing job data in 'avocado jobs list' command
- Updated 'handle_list_command' to use `job.get()` for safely accessing job data.
- If a key is missing, it now defaults to 'N/A' instead of causing a crash.

Reference:      avocado-framework#6067
Signed-off-by: Harvey Lynden <hlynden@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Short Term (Current Q) Backlog
Development

No branches or pull requests

3 participants