Skip to content

Commit

Permalink
allows nor to start new permanent volumes if a name is given. One cou…
Browse files Browse the repository at this point in the history
…ld consider adding tmp to not named volumes for additional clarity
  • Loading branch information
XaverStiensmeier committed Oct 28, 2024
1 parent 84e96be commit aae6c68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ def create_server_volumes(self, provider, instance, name):
if volume.get('snapshot'):
if not volume.get("name"):
volume["name"] = base_volume_name
else:
volume["name"] = f"{base_volume_name}-{volume['name']}"
return_volume = provider.create_volume_from_snapshot(volume['snapshot'], volume["name"])
if not return_volume:
raise ConfigurationException(f"Snapshot {volume['snapshot']} not found!")
Expand All @@ -276,7 +278,8 @@ def create_server_volumes(self, provider, instance, name):
self.log.debug(f"Trying to find volume {volume['name']}")
return_volume = provider.get_volume_by_id_or_name(volume["name"])
if not return_volume:
raise ConfigurationException(f"Couldn't find volume {volume['name']}")
volume["name"] = f"{base_volume_name}-{volume['name']}"
return_volume = provider.create_volume(size=volume.get("size", 50), name=volume['name'])
return_volume["name"] = volume["name"]
else:
volume["name"] = base_volume_name
Expand Down
2 changes: 1 addition & 1 deletion bibigrid/core/actions/terminate.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def delete_tmp_volumes(provider, cluster_id, log):
log.info("Deleting tmp volumes on provider %s...", provider.cloud_specification['identifier'])
volume_list = provider.list_volumes()
cluster_volume_state = []
volume_regex = re.compile(fr"^bibigrid-(master-{cluster_id}|(worker|vpngtw)-{cluster_id}-(.*))$")
volume_regex = re.compile(fr"^bibigrid-(master-{cluster_id}|(worker|vpngtw)-{cluster_id}-(\d+))$")
for volume in volume_list:
if volume_regex.match(volume["name"]):
log.info("Trying to delete volume %s on cloud %s.", volume['name'], provider.cloud_specification[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def create_server_volumes(connection, host_vars, name):
if volume.get('snapshot'):
if not volume.get("name"):
volume["name"] = base_volume_name
else:
volume["name"] = f"{base_volume_name}-{volume['name']}"
return_volume = create_volume_from_snapshot(connection, volume['snapshot'], volume["name"])
if not return_volume:
raise ConfigurationException(f"Snapshot {volume['snapshot']} not found!")
Expand All @@ -136,7 +138,8 @@ def create_server_volumes(connection, host_vars, name):
logging.debug(f"Trying to find volume {volume['name']}")
return_volume = connection.get_volume_by_id_or_name(volume["name"])
if not return_volume:
raise ConfigurationException(f"Couldn't find volume {volume['name']}")
volume["name"] = f"{base_volume_name}-{volume['name']}"
return_volume = connection.create_volume(size=volume.get("size", 50), name=volume['name'])
return_volume["name"] = volume["name"]
else:
volume["name"] = base_volume_name
Expand Down

0 comments on commit aae6c68

Please sign in to comment.