Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of VAULT-13191: OSS changes into release/1.13.x #20117

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
3 changes: 3 additions & 0 deletions changelog/19891.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core (enterprise): add configuration for license reporting
```
1 change: 1 addition & 0 deletions command/server/config_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ func testParseSeals(t *testing.T) {
},
},
}
addExpectedDefaultEntConfig(expected)
config.Prune()
require.Equal(t, config, expected)
}
Expand Down
1 change: 1 addition & 0 deletions command/server/config_test_helpers_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
package server

func addExpectedEntConfig(c *Config, sentinelModules []string) {}
func addExpectedDefaultEntConfig(c *Config) {}
func addExpectedEntSanitizedConfig(c map[string]interface{}, sentinelModules []string) {}
10 changes: 10 additions & 0 deletions vault/activity_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ type ActivityLogCoreConfig struct {

// CensusReportInterval is the testing configuration for time
CensusReportInterval time.Duration

// MinimumRetentionMonths defines the minimum value for retention
MinimumRetentionMonths int
}

// NewActivityLog creates an activity log.
Expand Down Expand Up @@ -953,6 +956,10 @@ func (a *ActivityLog) SetConfigInit(config activityConfig) {
a.defaultReportMonths = config.DefaultReportMonths
a.retentionMonths = config.RetentionMonths

if a.retentionMonths < a.configOverrides.MinimumRetentionMonths {
a.retentionMonths = a.configOverrides.MinimumRetentionMonths
}

if a.configOverrides.CensusReportInterval > 0 {
a.CensusReportInterval = a.configOverrides.CensusReportInterval
}
Expand Down Expand Up @@ -1010,6 +1017,9 @@ func (a *ActivityLog) SetConfig(ctx context.Context, config activityConfig) {

a.defaultReportMonths = config.DefaultReportMonths
a.retentionMonths = config.RetentionMonths
if a.retentionMonths < a.configOverrides.MinimumRetentionMonths {
a.retentionMonths = a.configOverrides.MinimumRetentionMonths
}

// check for segments out of retention period, if it has changed
go a.retentionWorker(ctx, time.Now(), a.retentionMonths)
Expand Down
3 changes: 3 additions & 0 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ type Core struct {
// censusAgent is the mechanism used for reporting Vault's billing data.
censusAgent *CensusAgent

// censusLicensingEnabled records whether Vault is exporting census metrics
censusLicensingEnabled bool

// activeTime is set on active nodes indicating the time at which this node
// became active.
activeTime time.Time
Expand Down
5 changes: 5 additions & 0 deletions vault/logical_system_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
if config.Enabled == "enable" && enabledStr == "disable" ||
!activityLogEnabledDefault && config.Enabled == "enable" && enabledStr == "default" ||
activityLogEnabledDefault && config.Enabled == "default" && enabledStr == "disable" {

// if census is enabled, the activity log cannot be disabled
if a.core.censusLicensingEnabled {
return logical.ErrorResponse("cannot disable the activity log while Reporting is enabled"), logical.ErrInvalidRequest
}
warnings = append(warnings, "the current monthly segment will be deleted because the activity log was disabled")
}

Expand Down
1 change: 1 addition & 0 deletions vault/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func TestCoreWithSealAndUINoCleanup(t testing.T, opts *CoreConfig) *Core {
}

conf.ActivityLogConfig = opts.ActivityLogConfig
testApplyEntBaseConfig(conf, opts)

c, err := NewCore(conf)
if err != nil {
Expand Down