fix: correctly reject quota-violating builds (#9233)

Due to a logical error in CommitQuota, all workspace Stop->Start operations
were being accepted, regardless of the Quota limit. This issue only
appeared after #9201, so this was a minor regression in main for about
3 days. This PR adds a test to make sure this kind of bug doesn't recur.

To make the new test possible, we give the echo provisioner the ability
to simulate responses to specific transitions.
This commit is contained in:
Ammar Bandukwala
2023-08-21 21:55:39 -05:00
committed by GitHub
parent 69ec8d774b
commit 545a256b57
7 changed files with 293 additions and 55 deletions

View File

@ -498,7 +498,10 @@ func (api *API) updateEntitlements(ctx context.Context) error {
if initial, changed, enabled := featureChanged(codersdk.FeatureTemplateRBAC); shouldUpdate(initial, changed, enabled) {
if enabled {
committer := committer{Database: api.Database}
committer := committer{
Log: api.Logger.Named("quota_committer"),
Database: api.Database,
}
ptr := proto.QuotaCommitter(&committer)
api.AGPL.QuotaCommitter.Store(&ptr)
} else {