Skip to content

Commit

Permalink
Volume check in migration (#2770)
Browse files Browse the repository at this point in the history
This commit checks if a volume exists before selecting the first volume as in the case where we don't have any volumes i.e build, this will result in a failure.
  • Loading branch information
sonicaj committed Mar 19, 2019
1 parent bf08377 commit 4d13f04
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gui/vm/migrations/0009_auto_20190315_1058.py
Expand Up @@ -11,9 +11,13 @@ def migrate_rancher_to_grub(apps, schemaeditor):
VM = apps.get_model('vm', 'vm')
Volume = apps.get_model('storage', 'volume')

volumes = Volume.objects.order_by('id')
if not volumes:
return

# Getting the first volume is a compromise to ease the migration.
# It wont work if the user has multiple pools and VM does not live in first one.
volume = Volume.objects.order_by('id')[0]
volume = volumes[0]

for vm in VM.objects.filter(vm_type='Container Provider'):
password = 'docker'
Expand Down

0 comments on commit 4d13f04

Please sign in to comment.