-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
SUMMARY
PR #5304 added the ability to delete file content from disk for the action API. By altering the underlying behaviour of the action endpoint, we are breaking the contract with existing St2 installations. People using this endpoint will be confused by the new behaviour and potentially loose unsaved work in worst case scenarios. Beyond API contracts, the code is currently broken in two ways which are detailed in Expected Results
The code does not handle file removal on all nodes in StackStorm's HA installations. This problem is related to the core code being unaware of nodes operating in the HA solution and as such should be considered out of scope for the resolution of this issue. Another issue addressing HA awareness should be opened for a future release.
STACKSTORM VERSION
st2 v3.6dev
OS, environment, install method
N/A
Steps to reproduce the problem
Expected Results
- Able to remove actions from database only. (the current StackStorm behaviour with action delete).
- Able to remove actions from database and disk. (the proposed change)
- Consistent behaviour under fault conditions. I.e. the delete operation must be atomic. If errors are encountered with the database/file, the action is left in a consistent state.
1. Impossible to remove just the database entry
The CLI only allows action delete with file removal.
st2 action delete test.default_values
The resource files on disk will be deleted. Do you want to continue? (y/n): n
Action is not deleted.
The API does not offer the means to remove the action only from the database. The PR maintains the API signature of an action_ref and requester_user which makes deleting files on disk a hard requirement for API calls to delete an action.
https://github.com/orchestral-st2/st2/blob/e76573c99d5a1d403a5818fa853f0d4a8999fad1/st2api/st2api/controllers/v1/actions.py#L209
Since this changes existing API behaviour to become more destructive, the new implementation should be an explicit opt-in by the user. As suggested in #5304 a global option in st2.conf could be a solution. An API argument to delete disk content allows from more granular control. Perhaps both should be implemented: st2.conf for global policy and an API parameter for use cases where it need to be overridden?
2. Inconsistent state when file access error encountered
As describe here #5304 (comment) when a delete operation encounters an error on disk, an http 500 internal error is reported, the database entry is removed but the disk content is left. If errors are encountered during the deletion process, St2 must remain in a consistent state or there will be an administrative burden added to running StackStorm which will degrade user experience.