Skip to content

Commit 9a05b46

Browse files
authored
chore: fix TestManagedAgentLimit flake (#19026)
Closes coder/internal#812
1 parent 5319d47 commit 9a05b46

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

enterprise/coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
830830
}
831831
api.derpMesh.SetAddresses(addresses, false)
832832
}
833-
_ = api.updateEntitlements(ctx)
833+
_ = api.updateEntitlements(api.ctx)
834834
})
835835
} else {
836836
coordinator = agpltailnet.NewCoordinator(api.Logger)
@@ -840,7 +840,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
840840
api.replicaManager.SetCallback(func() {
841841
// If the amount of replicas change, so should our entitlements.
842842
// This is to display a warning in the UI if the user is unlicensed.
843-
_ = api.updateEntitlements(ctx)
843+
_ = api.updateEntitlements(api.ctx)
844844
})
845845
}
846846

enterprise/coderd/license/license.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,15 @@ func LicensesEntitlements(
432432
if featureArguments.ManagedAgentCountFn != nil {
433433
managedAgentCount, err = featureArguments.ManagedAgentCountFn(ctx, agentLimit.UsagePeriod.Start, agentLimit.UsagePeriod.End)
434434
}
435-
if err != nil {
435+
switch {
436+
case xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded):
437+
// If the context is canceled, we want to bail the entire
438+
// LicensesEntitlements call.
439+
return entitlements, xerrors.Errorf("get managed agent count: %w", err)
440+
case err != nil:
436441
entitlements.Errors = append(entitlements.Errors,
437442
fmt.Sprintf("Error getting managed agent count: %s", err.Error()))
438-
} else {
443+
default:
439444
agentLimit.Actual = &managedAgentCount
440445
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, agentLimit)
441446

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy