Skip to content

Implement Quotas v3 #5012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Nov 14, 2022
Merged

Implement Quotas v3 #5012

merged 33 commits into from
Nov 14, 2022

Conversation

ammario
Copy link
Member

@ammario ammario commented Nov 10, 2022

Some background here.

  • Implement Resource Metadata parsing in Provisioner
  • Modify terraform-provider-coder and publish a new release there
    • Clean up English
  • Give back error to Frontend when Quota cost exceeded
  • Show Quota consumption per resource in Workspace page
  • Idea: show overall cost of workspace in Workspace page, and use a tiny Pie Chart to give a sense of how much quota the workspace consumes
  • Provide quotas to groups
  • Allow provision to bypass quota cost if net workspace cost decreases
  • Specify cost — use hourly/daily/monthly and smallest denomination of currency (e.g. cents for USD)
  • Remove "1 item block" requirement from coder-provisioner-terraform
  • Write basic docs
    • Add images (once Kyle pretties things up)
  • Combine Quotas and Groups into a single licensable feature
  • Verify in coder/license too
  • Ensure nothing breaks in CE

Later

Follow-up tasks to be worked after merge:

  • Show average workspace cost in Template page
  • Give user forewarning during Create Workspace if the build will likely fail due to quota exhaustion
  • Render Quota more nicely in Build Log

@ammario
Copy link
Member Author

ammario commented Nov 12, 2022

@sharkymark @whitney-coder @ericpaulsen — once this is merged, Quotas will come with Template RBAC and the Quota field in licenses will have no effect.

@@ -0,0 +1,3 @@
ALTER TABLE workspace_builds ADD COLUMN cost int NOT NULL DEFAULT 0;
ALTER TABLE workspace_resources ADD COLUMN cost int NOT NULL DEFAULT 0;
ALTER TABLE groups ADD COLUMN quota_allowance int NOT NULL DEFAULT 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might make this daily_quota_allowance as well... although since it's not time based, that gets a bit odd... maybe maximum_concurrent_quota?

@ammario ammario marked this pull request as ready for review November 14, 2022 16:00
@ammario ammario requested a review from a team as a code owner November 14, 2022 16:00
@ammario ammario requested review from Kira-Pilot and removed request for a team November 14, 2022 16:00
@ammario ammario merged commit 97dbd4d into main Nov 14, 2022
@ammario ammario deleted the quotas-v3 branch November 14, 2022 17:57
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2022
The quota is enabled by either the `CODER_USER_WORKSPACE_QUOTA`
environment variable or the `--user-workspace-quota` flag. For example,
you may limit each user in a deployment to 5 workspaces like so:
The workspace provisioner enforces quota during workspace start and stop operations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The workspace provisioner enforces quota during workspace start and stop operations.
The workspace provisioner enforces quotas during workspace start and stop operations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops


## Enabling this feature
Coder enforces Quota on workspace start and stop operations. The workspace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Coder enforces Quota on workspace start and stop operations. The workspace
Coder enforces quotas on workspace start and stop operations. The workspace

@@ -132,7 +132,7 @@ message Resource {
bool hide = 5;
string icon = 6;
string instance_type = 7;
int32 cost = 8;
int32 daily_cost = 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure there was a conversation here, but why we did land on "daily" as the unit? I've been thinking about how we present this, and the more I thought about it the more I think giving this a unit is not ideal. Mainly because of it being lossy to our currently planned implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to encourage standard practices across all deployments for follow-on features such as reporting and burst quotas. For time units, the reasonable options are "hourly", "daily" and "monthly".

I threw out hourly because I thought it may require precision beyond a cent. For example, a $20/m instance costs 2.7 cents per hour, and we want to avoid floating point arithmetic.

I threw out monthly because it's not always clear what the exact length of a month is. It could be 30, 30.5, or 30.437 (right answer) days.

@@ -8,8 +8,8 @@ import (
)

type WorkspaceQuota struct {
UserWorkspaceCount int `json:"user_workspace_count"`
UserWorkspaceLimit int `json:"user_workspace_limit"`
CreditsConsumed int `json:"credits_consumed"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't really using the "credits" terminology anywhere else, right? Seems a little odd to introduce at this point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, it could just be "QuotaConsumed"?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants