Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
}
api.derpMesh.SetAddresses(addresses, false)
}
_ = api.updateEntitlements(ctx)
_ = api.updateEntitlements(api.ctx)
})
} else {
coordinator = agpltailnet.NewCoordinator(api.Logger)
Expand All @@ -840,7 +840,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
api.replicaManager.SetCallback(func() {
// If the amount of replicas change, so should our entitlements.
// This is to display a warning in the UI if the user is unlicensed.
_ = api.updateEntitlements(ctx)
_ = api.updateEntitlements(api.ctx)
})
}

Expand Down
9 changes: 7 additions & 2 deletions enterprise/coderd/license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,15 @@ func LicensesEntitlements(
if featureArguments.ManagedAgentCountFn != nil {
managedAgentCount, err = featureArguments.ManagedAgentCountFn(ctx, agentLimit.UsagePeriod.Start, agentLimit.UsagePeriod.End)
}
if err != nil {
switch {
case xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded):
// If the context is canceled, we want to bail the entire
// LicensesEntitlements call.
return entitlements, xerrors.Errorf("get managed agent count: %w", err)
case err != nil:
entitlements.Errors = append(entitlements.Errors,
fmt.Sprintf("Error getting managed agent count: %s", err.Error()))
} else {
default:
agentLimit.Actual = &managedAgentCount
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, agentLimit)

Expand Down
Loading