kimchi-project / kimchi

An HTML5 management interface for KVM guests
https://github.com/kimchi-project/kimchi/releases/latest
Other
3.12k stars 364 forks source link

clean_old_tasks fails due dictionary size change while iterating. #1315

Open mayafox opened 4 years ago

mayafox commented 4 years ago

Describe the bug

[2020-03-19 01:20:53 UTC] POST   500 kimchi      134.141.56.67   user: Create guest 'build_anonftp_http-101.80' from template '/plugins/kimchi/templates/Ubuntu1804'

When creating a VM from template, a 500 error is thrown, but the VM is created. dump of wok-error.log shows the following indicating that the task dictionary changed during processing.

[19/Mar/2020:01:20:53] HTTP 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python3/dist-packages/cherrypy/lib/encoding.py", line 220, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/cherrypy/_cpdispatch.py", line 60, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/lib/python3/dist-packages/wok/control/base.py", line 490, in index
    result = self.create(params, *args)
  File "/usr/lib/python3/dist-packages/wok/control/base.py", line 533, in create
    task = create(*args)
  File "/usr/lib/python3/dist-packages/wok/plugins/kimchi/model/vms.py", line 193, in create
    f'/plugins/kimchi/vms/{name}', self._create_task, data).id
  File "/usr/lib/python3/dist-packages/wok/asynctask.py", line 79, in __init__
    clean_old_tasks()
  File "/usr/lib/python3/dist-packages/wok/asynctask.py", line 43, in clean_old_tasks
    for id, task in tasks_queue.items():
RuntimeError: dictionary changed size during iteration