Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Sep 19, 2024
1 parent 17ccea4 commit 5e85cfa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/middlewared/middlewared/plugins/apps/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def create_internal(
app_version_details = complete_app_details['versions'][version]
self.middleware.call_sync('catalog.version_supported_error_check', app_version_details)

app_volume_ds_exists = bool(self.get_app_volume_ds(app_name))
# The idea is to validate the values provided first and if it passes our validation test, we
# can move forward with setting up the datasets and installing the catalog item
new_values = self.middleware.call_sync(
Expand All @@ -226,7 +227,6 @@ def create_internal(

job.set_progress(25, 'Initial Validation completed')

app_volume_ds_exists = bool(self.get_app_volume_ds(app_name))
# Now that we have completed validation for the app in question wrt values provided,
# we will now perform the following steps
# 1) Create relevant dir for app
Expand Down Expand Up @@ -265,9 +265,9 @@ def remove_failed_resources(self, app_name, version, remove_ds=False):
for method, args, kwargs in (
(compose_action, (app_name, version, 'down'), {'remove_orphans': True}),
(shutil.rmtree, (get_installed_app_path(app_name),), {}),
) + (
(self.middleware.call_sync, ('zfs.dataset.delete', apps_volume_ds, {'recursive': True})),
) if apps_volume_ds and remove_ds else ():
) + ((
(self.middleware.call_sync, ('zfs.dataset.delete', apps_volume_ds, {'recursive': True}), {}),
) if apps_volume_ds and remove_ds else ()):
with contextlib.suppress(Exception):
method(*args, **kwargs)

Expand Down Expand Up @@ -375,4 +375,8 @@ def get_app_volume_ds(self, app_name):
# This will return volume dataset of app if it exists, otherwise null
apps_volume_ds = get_app_parent_volume_ds(self.middleware.call_sync('docker.config')['dataset'], app_name)
with contextlib.suppress(InstanceNotFound):
return self.middleware.call_sync('pool.dataset.get_instance_quick', apps_volume_ds)['id']
return self.middleware.call_sync(
'zfs.dataset.get_instance', apps_volume_ds, {
'extra': {'retrieve_children': False, 'retrieve_properties': False}
}
)['id']

0 comments on commit 5e85cfa

Please sign in to comment.