Updating /st2common/services/packs.py
Raising INTERNAL_SERVER_ERROR if there is problem in removal of action files. It means API will fail.
@@ -26,6 +26,7 @@ from oslo_config import cfg
from st2common import log as logging
from st2common.content.utils import get_pack_base_path
from st2common.persistence.pack import Pack
+from st2common.router import abort
from st2common.util.misc import lowercase_value
from st2common.util.jsonify import json_encode
@@ -43,6 +44,8 @@ SEARCH_PRIORITY = ["name", "keywords"]
LOG = logging.getLogger(__name__)
+http_client = six.moves.http_client
+
def _build_index_list(index_url):
if not index_url:
@@ -237,12 +240,25 @@ def delete_action_files_from_pack(pack_name, entry_point, metadata_file):
'No permission to delete the "%s" file',
action_entrypoint_file_path,
)
+ msg = 'No permission to delete "{0}" file from disk'.format(
+ action_entrypoint_file_path
+ )
+ abort(
+ http_client.INTERNAL_SERVER_ERROR,
+ six.text_type(msg),
+ )
except Exception as e:
LOG.error(
'Unable to delete "%s" file. Exception was "%s"',
action_entrypoint_file_path,
e,
)
+ msg = (
+ 'Delete operation unsuccessful. "{0}" file still exists on disk'.format(
+ action_entrypoint_file_path
+ )
+ )
+ abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(msg))
if os.path.exists(action_metadata_file_path):
try:
@@ -252,9 +268,22 @@ def delete_action_files_from_pack(pack_name, entry_point, metadata_file):
'No permission to delete the "%s" file',
action_metadata_file_path,
)
+ msg = 'No permission to delete "{0}" file from disk'.format(
+ action_metadata_file_path
+ )
+ abort(
+ http_client.INTERNAL_SERVER_ERROR,
+ six.text_type(msg),
+ )
except Exception as e:
LOG.error(
'Unable to delete "%s" file. Exception was "%s"',
action_metadata_file_path,
e,
)
+ msg = (
+ 'Delete operation unsuccessful. "{0}" file still exists on disk'.format(
+ action_metadata_file_path
+ )
+ )
+ abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(msg))
