Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b1e3cb

Browse files
authored
chore: change managed agent limit (#20664)
(cherry picked from commitb3f651d)
1 parentea0aca0 commit1b1e3cb

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

‎enterprise/coderd/license/license.go‎

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,36 @@ func LicensesEntitlements(
262262
claims.FeatureSet=codersdk.FeatureSetEnterprise
263263
}
264264

265+
// Temporary: If the license doesn't have a managed agent limit, we add
266+
// a default of 1000 managed agents per deployment for a 100
267+
// year license term.
268+
// This only applies to "Premium" licenses.
269+
ifclaims.FeatureSet==codersdk.FeatureSetPremium {
270+
var (
271+
// We intentionally use a fixed issue time here, before the
272+
// entitlement was added to any new licenses, so any
273+
// licenses with the corresponding features actually set
274+
// trump this default entitlement, even if they are set to a
275+
// smaller value.
276+
defaultManagedAgentsIsuedAt=time.Date(2025,7,1,0,0,0,0,time.UTC)
277+
defaultManagedAgentsStart=defaultManagedAgentsIsuedAt
278+
defaultManagedAgentsEnd=defaultManagedAgentsStart.AddDate(100,0,0)
279+
defaultManagedAgentsSoftLimitint64=1000
280+
defaultManagedAgentsHardLimitint64=1000
281+
)
282+
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, codersdk.Feature{
283+
Enabled:true,
284+
Entitlement:entitlement,
285+
SoftLimit:&defaultManagedAgentsSoftLimit,
286+
Limit:&defaultManagedAgentsHardLimit,
287+
UsagePeriod:&codersdk.UsagePeriod{
288+
IssuedAt:defaultManagedAgentsIsuedAt,
289+
Start:defaultManagedAgentsStart,
290+
End:defaultManagedAgentsEnd,
291+
},
292+
})
293+
}
294+
265295
// Add all features from the feature set defined.
266296
for_,featureName:=rangeclaims.FeatureSet.Features() {
267297
if_,ok:=licenseForbiddenFeatures[featureName];ok {
@@ -338,33 +368,6 @@ func LicensesEntitlements(
338368
Limit:&featureValue,
339369
Actual:&featureArguments.ActiveUserCount,
340370
})
341-
342-
// Temporary: If the license doesn't have a managed agent limit,
343-
// we add a default of 800 managed agents per user.
344-
// This only applies to "Premium" licenses.
345-
ifclaims.FeatureSet==codersdk.FeatureSetPremium {
346-
var (
347-
// We intentionally use a fixed issue time here, before the
348-
// entitlement was added to any new licenses, so any
349-
// licenses with the corresponding features actually set
350-
// trump this default entitlement, even if they are set to a
351-
// smaller value.
352-
issueTime=time.Date(2025,7,1,0,0,0,0,time.UTC)
353-
defaultSoftAgentLimit=800*featureValue
354-
defaultHardAgentLimit=1000*featureValue
355-
)
356-
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, codersdk.Feature{
357-
Enabled:true,
358-
Entitlement:entitlement,
359-
SoftLimit:&defaultSoftAgentLimit,
360-
Limit:&defaultHardAgentLimit,
361-
UsagePeriod:&codersdk.UsagePeriod{
362-
IssuedAt:issueTime,
363-
Start:usagePeriodStart,
364-
End:usagePeriodEnd,
365-
},
366-
})
367-
}
368371
default:
369372
iffeatureValue<=0 {
370373
// The feature is disabled.

‎enterprise/coderd/license/license_test.go‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ func TestEntitlements(t *testing.T) {
520520
t.Run("Premium",func(t*testing.T) {
521521
t.Parallel()
522522
constuserLimit=1
523-
constexpectedAgentSoftLimit=800*userLimit
524-
constexpectedAgentHardLimit=1000*userLimit
523+
constexpectedAgentSoftLimit=1000
524+
constexpectedAgentHardLimit=1000
525525

526526
db,_:=dbtestutil.NewDB(t)
527527
licenseOptions:= coderdenttest.LicenseOptions{
@@ -530,9 +530,7 @@ func TestEntitlements(t *testing.T) {
530530
ExpiresAt:dbtime.Now().Add(time.Hour*24*2),
531531
FeatureSet:codersdk.FeatureSetPremium,
532532
Features: license.Features{
533-
// Temporary: allows the default value for the
534-
// managed_agent_limit feature to be used.
535-
codersdk.FeatureUserLimit:1,
533+
codersdk.FeatureUserLimit:userLimit,
536534
},
537535
}
538536
_,err:=db.InsertLicense(context.Background(), database.InsertLicenseParams{
@@ -557,11 +555,15 @@ func TestEntitlements(t *testing.T) {
557555
require.Equal(t,codersdk.EntitlementEntitled,agentEntitlement.Entitlement)
558556
require.EqualValues(t,expectedAgentSoftLimit,*agentEntitlement.SoftLimit)
559557
require.EqualValues(t,expectedAgentHardLimit,*agentEntitlement.Limit)
558+
560559
// This might be shocking, but there's a sound reason for this.
561560
// See license.go for more details.
562-
require.Equal(t,time.Date(2025,7,1,0,0,0,0,time.UTC),agentEntitlement.UsagePeriod.IssuedAt)
563-
require.WithinDuration(t,licenseOptions.NotBefore,agentEntitlement.UsagePeriod.Start,time.Second)
564-
require.WithinDuration(t,licenseOptions.ExpiresAt,agentEntitlement.UsagePeriod.End,time.Second)
561+
agentUsagePeriodIssuedAt:=time.Date(2025,7,1,0,0,0,0,time.UTC)
562+
agentUsagePeriodStart:=agentUsagePeriodIssuedAt
563+
agentUsagePeriodEnd:=agentUsagePeriodStart.AddDate(100,0,0)
564+
require.Equal(t,agentUsagePeriodIssuedAt,agentEntitlement.UsagePeriod.IssuedAt)
565+
require.WithinDuration(t,agentUsagePeriodStart,agentEntitlement.UsagePeriod.Start,time.Second)
566+
require.WithinDuration(t,agentUsagePeriodEnd,agentEntitlement.UsagePeriod.End,time.Second)
565567
continue
566568
}
567569

@@ -1496,14 +1498,14 @@ func TestManagedAgentLimitDefault(t *testing.T) {
14961498
})
14971499

14981500
// "Premium" licenses should receive a default managed agent limit of:
1499-
// soft =800 * user_limit
1500-
// hard = 1000 * user_limit
1501+
// soft =1000
1502+
// hard = 1000
15011503
t.Run("Premium",func(t*testing.T) {
15021504
t.Parallel()
15031505

1504-
constuserLimit=100
1505-
constsoftLimit=800*userLimit
1506-
consthardLimit=1000*userLimit
1506+
constuserLimit=33
1507+
constsoftLimit=1000
1508+
consthardLimit=1000
15071509
lic:= database.License{
15081510
ID:1,
15091511
UploadedAt:time.Now(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp