[BACKEND] Allow `max_hours_before_termination` to be updated on Workspaces
MR: Pending
Description
Allow max_hours_before_termination to be updated on Workspaces via the GraphQL API.
Acceptance Criteria
-
max_hours_before_terminationfield can be updated via GraphQL API. -
All validations are implemented as specified in the technical requirements. -
The user's PAT associated with the workspace is increased/decreased accordingly as well.
Technical Requirements
This issue only applies to the API and backend. The UI will be added as part of a separate issue.
- Allow updating the field
max_hours_before_terminationin the workspace update API. - User's can increase/decrease this value.
- Whenever
max_hours_before_terminationis updated, 2 validations will be required. If either of them fail, the update will fail. These should be handled in the standard way as we do for other errors, to ensure the error is bubbled up to the GraphQL response error field, so the UI (to be implemented in a future issue) will automatically show these validations and not allow updating the workspace if either of them fail. These are the two validations:- Invalid if the new value is greater than
max_hours_before_termination_limitfor the associated agent. - Invalid if the new value is less than or equal to the current age of the workspace.
- Invalid if the new value is greater than
- In addition, a validation should be added to ensure that no field of the workspace should be allowed to be updated if the
desired_stateis currentlyTerminated, or is being set toTerminated. - Update the expiration date of the access token associated with the workspace.
Design Requirements
None, no UI in this issue.
Impact Assessment
The workspace timeout is set during creation of the workspace but there may be situations where more time is needed to complete tasks in the workspace.
Currently there is no way to increase the timeout once set even if the new timeout would be under the allowed maximum. This could result in work being lost if the workspace times out before tasks are complete.
The ability to increase the timeout through the UI or API after initial creation would prevent lost work from timeouts and provide more flexibility for long running tasks.
Edited by Vishal Tak