Merge ~tai271828/plainbox-provider-resource:mr-graphic-resource-exception into plainbox-provider-resource:master

Proposed by Taihsiang Ho
Status: Rejected
Rejected by: Sylvain Pineau
Proposed branch: ~tai271828/plainbox-provider-resource:mr-graphic-resource-exception
Merge into: plainbox-provider-resource:master
Diff against target: 18 lines (+7/-0)
1 file modified
bin/graphics_card_resource (+7/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Disapprove
Jonathan Cave (community) Disapprove
Gavin Lin (community) Approve
Review via email: mp+355594@code.launchpad.net

Description of the change

In the previous commit[1] we add gpu_count to render our jobs with jinja2 templates. This commit add an corner case (0 gpu_count) so the script could still return meta data unless jinja2 will complain missing key "gpu_count".

This corner case is useful for devices without video components on pci bus, e.g. rpi.

[1] 277751b7b7c3213325c0f243b6713193c0451371

More Information:

Without the gpu_count: 0 entry, we will get the error:

=========[ Bootstrap com.canonical.certification::graphics_card (2/2) ]=========
WARNING:plainbox.ctrl:Ignoring graphics/{index}_resolution-change_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_resolution_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screen_resolution_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_modes_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_color_depth_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_fresh_rate_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_graphic_memory_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_video_{product_slug} with missing template parameter driver
WARNING:plainbox.ctrl:Ignoring graphics/{index}_unity_support_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_glxgears_{product_slug} with missing template parameter driver
WARNING:plainbox.ctrl:Ignoring graphics/{index}_glxgears_fullscreen_{product_slug} with missing template parameter driver
WARNING:plainbox.ctrl:Ignoring graphics/{index}_3d_window_open_close_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_3d_window_suspend_resume_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_multi_3d_windows_open_close_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_3d_window_move_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screenshot_{product_slug} with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screenshot_{product_slug}.jpg with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screenshot_fullscreen_video_{product_slug} with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_switch_card_{product_slug} with missing template parameter vendor
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screenshot_fullscreen_video_{product_slug}.jpg with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screen-capture-internal_{product_slug} with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_screen-capture-internal_{product_slug}.png with missing template parameter index
WARNING:plainbox.ctrl:Ignoring graphics/{index}_auto_switch_card_{product_slug} with missing template parameter switch_to_cmd
ERROR:plainbox.bug:Undeclared exception UndefinedError raised from use_job_result
                        Application Malfunction Detected

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/guacamole/core.py", line 248, in eat
    return self._dispatch()
  File "/usr/lib/python3/dist-packages/guacamole/core.py", line 298, in _dispatch
    result = ingredient.dispatch(self.context)
  File "/usr/lib/python3/dist-packages/guacamole/ingredients/cmdtree.py", line 152, in dispatch
    return self._dispatch(context, 0)
  File "/usr/lib/python3/dist-packages/guacamole/ingredients/cmdtree.py", line 179, in _dispatch
    return self._dispatch_None(context, level, retval, command)
  File "/usr/lib/python3/dist-packages/guacamole/ingredients/cmdtree.py", line 208, in _dispatch_None
    return self._dispatch(context, level + 1)
  File "/usr/lib/python3/dist-packages/guacamole/ingredients/cmdtree.py", line 165, in _dispatch
    retval = command.invoked(context)
  File "/usr/lib/python3/dist-packages/checkbox_ng/launcher/subcommands.py", line 252, in invoked
    self._start_new_session()
  File "/usr/lib/python3/dist-packages/checkbox_ng/launcher/subcommands.py", line 417, in _start_new_session
    self._run_bootstrap_jobs(bs_jobs)
  File "/usr/lib/python3/dist-packages/checkbox_ng/launcher/stages.py", line 245, in _run_bootstrap_jobs
    self.sa.use_job_result(job_id, result_builder.get_result())
  File "/usr/lib/python3/dist-packages/plainbox/impl/decorators.py", line 142, in wrapper
    raise exc
  File "/usr/lib/python3/dist-packages/plainbox/impl/decorators.py", line 136, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/plainbox/impl/session/assistant.py", line 1422, in use_job_result
    self._context.state.update_job_result(job, result)
  File "/usr/lib/python3/dist-packages/plainbox/impl/session/state.py", line 1003, in update_job_result
    self, job, result, fake_resources=self._fake_resources)
  File "/usr/lib/python3/dist-packages/plainbox/impl/ctrl.py", line 264, in observe_result
    session_state, job, result, fake_resources)
  File "/usr/lib/python3/dist-packages/plainbox/impl/ctrl.py", line 274, in _process_resource_result
    session_state, job, result, fake_resources)
  File "/usr/lib/python3/dist-packages/plainbox/impl/ctrl.py", line 315, in _instantiate_templates
    check_result = new_unit.check()
  File "/usr/lib/python3/dist-packages/plainbox/impl/unit/unit.py", line 919, in check
    return list(self._check_gen(context))
  File "/usr/lib/python3/dist-packages/plainbox/impl/unit/unit.py", line 923, in _check_gen
    for issue in validator.check(self):
  File "/usr/lib/python3/dist-packages/plainbox/impl/unit/unit.py", line 126, in check
    for issue in validator.check(self, unit, field):
  File "/usr/lib/python3/dist-packages/plainbox/impl/unit/validators.py", line 442, in check
    if (unit.get_record_value(field) and
  File "/usr/lib/python3/dist-packages/plainbox/impl/unit/unit.py", line 644, in get_record_value
    value = Template(value).render(tmp_params)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
jinja2.exceptions.UndefinedError: 'gpu_count' is undefined

  Please report a bug including the information from the paragraph above. To
  report the bug visit https://bugs.launchpad.net/checkbox-ng/+filebug

  We are sorry for the inconvenience!

To post a comment you must log in.
Revision history for this message
Gavin Lin (gavin.lin) wrote :

+1, we need this to run rpi2 sru.

review: Approve
Revision history for this message
Jonathan Cave (jocave) wrote :

I think we want to try and keep resource jobs only producing entries if at least one example of that resource exists on the system.

If there is a problem with a job using this resource as the template-resource then that suggests some other bug that needs fixing.

review: Disapprove
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

The right fix is in checkbox-ng as we should really not instancuating templates when there's nothing to create. The proposed solution fixes the crash and removes all those warnings about missing parameters.

See https://code.launchpad.net/~sylvain-pineau/checkbox-ng/+git/checkbox-ng/+merge/355777

review: Disapprove

Unmerged commits

d00350c... by Taihsiang Ho

graphics_card_resource: Add gpu_count corner case

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/graphics_card_resource b/bin/graphics_card_resource
2index e3e9ed7..7c0ab21 100755
3--- a/bin/graphics_card_resource
4+++ b/bin/graphics_card_resource
5@@ -184,6 +184,13 @@ def main():
6 for k in sorted(record.keys())]
7 print("\n".join(items))
8 print("")
9+ # Some devices have no gpu on pci bus e.g. rpi, and we still report the
10+ # gpu_count so the jinja2 template for gpu could catch this corner
11+ # case. Ref to the commit 277751b7b7c3213325c0f243b6713193c0451371 as
12+ # well.
13+ if len(video_devices) == 0:
14+ print("gpu_count: 0")
15+ print("")
16 except OSError as err:
17 raise SystemExit(err)
18 return 0

Subscribers

People subscribed via source and target branches