Backend: Enforce workspaces_quota and workspaces_per_user_quota value of the agent while creating the workspace
MR: Enforce workspaces_quota and workspaces_per_use... (!141376 - merged)
Description
Enforce workspaces_quota
and workspaces_per_user_quota
value of the agent while creating the workspace
Acceptance Criteria
-
Add validation in model that acceptable values for workspaces_per_user_quota
are>= -1
. -
User cannot create a workspace if they already have workspaces_per_user_quota
existing workspaces for the given agent. An error is received in response of the workspace creation. -
Add validation in model that acceptable values for workspaces_quota
are>= -1
. -
No workspaces can be created using the agent if they already have workspaces_quota
existing workspaces for the given agent. -
An integration test is added to validate this - ee/spec/lib/remote_development/agent_config/main_integration_spec.rb
-
The query to count workspaces will use the actual_state
instead ofdesired_state
columns of the database. Furthermore, every workspace that is not currentlyTerminated
will count towards the above quotas. -
We will allow quota reductions if even 1 user is exceeds the new intended values. So, it will be possible to reduce the per user quota from 10 -> 5 even if a user has more than 5 workspaces at the time of the update. -
Assuming a user exists with more workspaces than allowed by the configured quotas, what should be done if the user chooses to start a stopped workspace or restart a running workspace. The conclusion for this case is to allow the user these actions as that will keep the domain logic simple. In short, these quotas are applicable when creating workspaces only and not when updating already created workspaces.