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

Not handling an exception of VM creation gracefully #67

Open
nikolai-sannikov opened this issue May 28, 2020 · 2 comments
Open

Not handling an exception of VM creation gracefully #67

nikolai-sannikov opened this issue May 28, 2020 · 2 comments

Comments

@nikolai-sannikov
Copy link

Not critical, just code cleanliness.
I have managed to somehow ruin my test course (ironically, named 'The Best Course') and triggered an exception we maybe did not get in a while. In handling that exception we are referencing a missing attribute:

Unexpected error I have noticed:
File "/home/vital/vital2.0/source/virtual_lab/vital_site/vital/views/student_view.py", line 198, in start_vm
XenClient().remove_network_bridges(vm.xen_server, request.user, course_id, vm_id)
AttributeError: 'Virtual_Machine' object has no attribute 'xen_server'

Code triggering error:

except Exception as e:
        logger.error(str(e))
        audit(request, 'Error starting Virtual machine ' + str(vm.name) + '( ' + e.message + ' )')
        if 'Connection refused' not in str(e).rstrip() or started_vm is not None:
            XenClient().remove_network_bridges(**vm.xen_server**, request.user, course_id, vm_id)
            XenClient().stop_vm(started_vm['xen_server'], request.user, course_id, vm_id)
        return redirect('/courses/' + course_id + '/vms?message=Unable to start VM - ' + vm.name)
@suryansh1
Copy link
Contributor

I just tried launching a standalone VM and connecting to it via VNC, and it is working(kali-test), so looks like something wrong with the course side logic.

test-qemu

@nikolai-sannikov
Copy link
Author

Yep, and this is the point. If the course is working properly, this exception is never triggered and it is brushed under the carpet. But if the course config is ruined, it raises an exception, handling which includes a bad line I am talking about

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

No branches or pull requests

2 participants