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

chore: change managed agent limit#20664

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
david-fraley merged 1 commit intorelease/2.28fromdean/cherry-2.28-agents
Nov 4, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
57 changes: 30 additions & 27 deletionsenterprise/coderd/license/license.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -262,6 +262,36 @@ func LicensesEntitlements(
claims.FeatureSet = codersdk.FeatureSetEnterprise
}

// Temporary: If the license doesn't have a managed agent limit, we add
// a default of 1000 managed agents per deployment for a 100
// year license term.
// This only applies to "Premium" licenses.
if claims.FeatureSet == codersdk.FeatureSetPremium {
var (
// We intentionally use a fixed issue time here, before the
// entitlement was added to any new licenses, so any
// licenses with the corresponding features actually set
// trump this default entitlement, even if they are set to a
// smaller value.
defaultManagedAgentsIsuedAt = time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC)
defaultManagedAgentsStart = defaultManagedAgentsIsuedAt
defaultManagedAgentsEnd = defaultManagedAgentsStart.AddDate(100, 0, 0)
defaultManagedAgentsSoftLimit int64 = 1000
defaultManagedAgentsHardLimit int64 = 1000
)
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, codersdk.Feature{
Enabled: true,
Entitlement: entitlement,
SoftLimit: &defaultManagedAgentsSoftLimit,
Limit: &defaultManagedAgentsHardLimit,
UsagePeriod: &codersdk.UsagePeriod{
IssuedAt: defaultManagedAgentsIsuedAt,
Start: defaultManagedAgentsStart,
End: defaultManagedAgentsEnd,
},
})
}

// Add all features from the feature set defined.
for _, featureName := range claims.FeatureSet.Features() {
if _, ok := licenseForbiddenFeatures[featureName]; ok {
Expand DownExpand Up@@ -338,33 +368,6 @@ func LicensesEntitlements(
Limit: &featureValue,
Actual: &featureArguments.ActiveUserCount,
})

// Temporary: If the license doesn't have a managed agent limit,
// we add a default of 800 managed agents per user.
// This only applies to "Premium" licenses.
if claims.FeatureSet == codersdk.FeatureSetPremium {
var (
// We intentionally use a fixed issue time here, before the
// entitlement was added to any new licenses, so any
// licenses with the corresponding features actually set
// trump this default entitlement, even if they are set to a
// smaller value.
issueTime = time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC)
defaultSoftAgentLimit = 800 * featureValue
defaultHardAgentLimit = 1000 * featureValue
)
entitlements.AddFeature(codersdk.FeatureManagedAgentLimit, codersdk.Feature{
Enabled: true,
Entitlement: entitlement,
SoftLimit: &defaultSoftAgentLimit,
Limit: &defaultHardAgentLimit,
UsagePeriod: &codersdk.UsagePeriod{
IssuedAt: issueTime,
Start: usagePeriodStart,
End: usagePeriodEnd,
},
})
}
default:
if featureValue <= 0 {
// The feature is disabled.
Expand Down
28 changes: 15 additions & 13 deletionsenterprise/coderd/license/license_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -520,8 +520,8 @@ func TestEntitlements(t *testing.T) {
t.Run("Premium", func(t *testing.T) {
t.Parallel()
const userLimit = 1
const expectedAgentSoftLimit =800 * userLimit
const expectedAgentHardLimit = 1000 * userLimit
const expectedAgentSoftLimit =1000
const expectedAgentHardLimit = 1000

db, _ := dbtestutil.NewDB(t)
licenseOptions := coderdenttest.LicenseOptions{
Expand All@@ -530,9 +530,7 @@ func TestEntitlements(t *testing.T) {
ExpiresAt: dbtime.Now().Add(time.Hour * 24 * 2),
FeatureSet: codersdk.FeatureSetPremium,
Features: license.Features{
// Temporary: allows the default value for the
// managed_agent_limit feature to be used.
codersdk.FeatureUserLimit: 1,
codersdk.FeatureUserLimit: userLimit,
},
}
_, err := db.InsertLicense(context.Background(), database.InsertLicenseParams{
Expand All@@ -557,11 +555,15 @@ func TestEntitlements(t *testing.T) {
require.Equal(t, codersdk.EntitlementEntitled, agentEntitlement.Entitlement)
require.EqualValues(t, expectedAgentSoftLimit, *agentEntitlement.SoftLimit)
require.EqualValues(t, expectedAgentHardLimit, *agentEntitlement.Limit)

// This might be shocking, but there's a sound reason for this.
// See license.go for more details.
require.Equal(t, time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC), agentEntitlement.UsagePeriod.IssuedAt)
require.WithinDuration(t, licenseOptions.NotBefore, agentEntitlement.UsagePeriod.Start, time.Second)
require.WithinDuration(t, licenseOptions.ExpiresAt, agentEntitlement.UsagePeriod.End, time.Second)
agentUsagePeriodIssuedAt := time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC)
agentUsagePeriodStart := agentUsagePeriodIssuedAt
agentUsagePeriodEnd := agentUsagePeriodStart.AddDate(100, 0, 0)
require.Equal(t, agentUsagePeriodIssuedAt, agentEntitlement.UsagePeriod.IssuedAt)
require.WithinDuration(t, agentUsagePeriodStart, agentEntitlement.UsagePeriod.Start, time.Second)
require.WithinDuration(t, agentUsagePeriodEnd, agentEntitlement.UsagePeriod.End, time.Second)
continue
}

Expand DownExpand Up@@ -1496,14 +1498,14 @@ func TestManagedAgentLimitDefault(t *testing.T) {
})

// "Premium" licenses should receive a default managed agent limit of:
// soft =800 * user_limit
// hard = 1000 * user_limit
// soft =1000
// hard = 1000
t.Run("Premium", func(t *testing.T) {
t.Parallel()

const userLimit =100
const softLimit =800 * userLimit
const hardLimit = 1000 * userLimit
const userLimit =33
const softLimit =1000
const hardLimit = 1000
lic := database.License{
ID: 1,
UploadedAt: time.Now(),
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp