More than one ScriptResult traceback when processing commissioning

Bug #1988976 reported by Adam Collard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
High
Unassigned

Bug Description

Traceback repeatedly present on bolla's regiond.log

2022-09-06 15:32:06 maasserver: [error] Traceback (most recent call last):
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/snap/maas/23613/lib/python3.10/site-packages/maasserver/utils/views.py", line 293, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/snap/maas/23613/lib/python3.10/site-packages/maasserver/api/support.py", line 62, in __call__
    response = super().__call__(request, *args, **kwargs)
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/views/decorators/vary.py", line 20, in inner_func
    response = func(*args, **kwargs)
  File "/snap/maas/23613/usr/lib/python3.10/dist-packages/piston3/resource.py", line 197, in __call__
    result = self.error_handler(e, request, meth, em_format)
  File "/snap/maas/23613/usr/lib/python3.10/dist-packages/piston3/resource.py", line 195, in __call__
    result = meth(request, *args, **kwargs)
  File "/snap/maas/23613/lib/python3.10/site-packages/maasserver/api/support.py", line 370, in dispatch
    return function(self, request, *args, **kwargs)
  File "/snap/maas/23613/lib/python3.10/site-packages/metadataserver/api.py", line 860, in signal
    target_status = process(node, request, status)
  File "/snap/maas/23613/lib/python3.10/site-packages/metadataserver/api.py", line 682, in _process_commissioning
    self._store_results(
  File "/snap/maas/23613/lib/python3.10/site-packages/metadataserver/api.py", line 559, in _store_results
    process_file(
  File "/snap/maas/23613/lib/python3.10/site-packages/metadataserver/api.py", line 292, in process_file
    script_result, _ = script_set.scriptresult_set.get_or_create(
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/db/models/fields/related_descriptors.py", line 683, in get_or_create
    return super(RelatedManager, self.db_manager(db)).get_or_create(**kwargs)
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
  File "/snap/maas/23613/usr/lib/python3/dist-packages/django/db/models/query.py", line 439, in get
    raise self.model.MultipleObjectsReturned(
metadataserver.models.scriptresult.ScriptResult.MultipleObjectsReturned: get() returned more than one ScriptResult -- it returned 2!

seems like our use of `get_or_create` is buggy.

Revision history for this message
Christian Grabowski (cgrabowski) wrote :

able to reproduce, it appears the issue is a combination of we're only fetching the scriptresult by script name, and likely the same issue as LP:1964024 as I am able to find multiple scriptresults for smartctl-validate with the same script_set_id.

Changed in maas:
status: New → Triaged
importance: Undecided → High
Changed in maas:
milestone: none → 3.4.0
Revision history for this message
Jerzy Husakowski (jhusakowski) wrote :

Is it still reproducible after the LP:1964024 was fixed?

Changed in maas:
status: Triaged → Incomplete
Revision history for this message
Björn Tillenius (bjornt) wrote :

It seems that there has been a fix to not use get_or_create anymore. What's more interesting to know is why there are multiple results with the same name in the same script set? Is this a valid situation, or did the fix hide another bug?

Revision history for this message
Adam Collard (adam-collard) wrote (last edit ): Re: [Bug 1988976] Re: More than one ScriptResult traceback when processing commissioning

> It seems that there has been a fix to not use get_or_create anymore.
>

I disagree, we are still using get_or_create
```
        script_result, _ = script_set.scriptresult_set.get_or_create(
            script_name=script_name,
            defaults={
                "script_id": script_id,
                "status": SCRIPT_STATUS.RUNNING,
            },
        )
 ```

Changed in maas:
status: Incomplete → Triaged
tags: added: bug-council
tags: removed: bug-council
Changed in maas:
milestone: 3.4.0 → 3.5.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.