Skip to content

Commit

Permalink
kubevirt: fix default diskpool check for primary disk
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jan 12, 2025
1 parent 35ce6ab commit 1855ab5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kvirt/providers/kubevirt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
lun = disk.get('lun', False)
if 'name' in disk:
existingpvc = True
pool = self.check_pool(diskpool)
pool_details = self.get_sc_details(pool)
if volume_mode not in pool_details:
return {'result': 'failure', 'reason': f"Pool {pool} doesn't support volume mode {volume_mode}"}
elif volume_access not in pool_details[volume_mode]:
return {'result': 'failure', 'reason': f"Pool {pool} doesn't support volume access {volume_access}"}
myvolume = {'name': diskname}
if image is not None and index == 0:
if '/' in image:
Expand Down Expand Up @@ -384,12 +390,6 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
continue
if existingpvc:
continue
pool = self.check_pool(diskpool)
pool_details = self.get_sc_details(pool)
if volume_mode not in pool_details:
return {'result': 'failure', 'reason': f"Pool {pool} doesn't support volume mode {volume_mode}"}
elif volume_access not in pool_details[volume_mode]:
return {'result': 'failure', 'reason': f"Pool {pool} doesn't support volume access {volume_access}"}
pvc = {'kind': 'PersistentVolumeClaim', 'spec': {'storageClassName': pool,
'volumeMode': volume_mode,
'accessModes': [volume_access],
Expand Down Expand Up @@ -499,7 +499,7 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt', cpu
if index == 0 and image is not None:
owners.pop()
dvt = {'metadata': {'name': pvcname, 'annotations': {'sidecar.istio.io/inject': 'false'}},
'spec': {'pvc': {'storageClassName': diskpool,
'spec': {'pvc': {'storageClassName': pool,
'volumeMode': pvc_volume_mode,
'accessModes': pvc_access_mode,
'resources':
Expand Down

0 comments on commit 1855ab5

Please sign in to comment.