mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 10:12:35 +00:00
VAULT-13191: OSS changes (#19891)
* add open source changes for reporting * fix function signature * add changelog
This commit is contained in:
3
changelog/19891.txt
Normal file
3
changelog/19891.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
core (enterprise): add configuration for license reporting
|
||||||
|
```
|
||||||
@@ -1100,6 +1100,7 @@ func testParseSeals(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
addExpectedDefaultEntConfig(expected)
|
||||||
config.Prune()
|
config.Prune()
|
||||||
require.Equal(t, config, expected)
|
require.Equal(t, config, expected)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,5 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
func addExpectedEntConfig(c *Config, sentinelModules []string) {}
|
func addExpectedEntConfig(c *Config, sentinelModules []string) {}
|
||||||
|
func addExpectedDefaultEntConfig(c *Config) {}
|
||||||
func addExpectedEntSanitizedConfig(c map[string]interface{}, sentinelModules []string) {}
|
func addExpectedEntSanitizedConfig(c map[string]interface{}, sentinelModules []string) {}
|
||||||
|
|||||||
@@ -196,6 +196,9 @@ type ActivityLogCoreConfig struct {
|
|||||||
|
|
||||||
// CensusReportInterval is the testing configuration for time
|
// CensusReportInterval is the testing configuration for time
|
||||||
CensusReportInterval time.Duration
|
CensusReportInterval time.Duration
|
||||||
|
|
||||||
|
// MinimumRetentionMonths defines the minimum value for retention
|
||||||
|
MinimumRetentionMonths int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewActivityLog creates an activity log.
|
// NewActivityLog creates an activity log.
|
||||||
@@ -956,6 +959,10 @@ func (a *ActivityLog) SetConfigInit(config activityConfig) {
|
|||||||
a.defaultReportMonths = config.DefaultReportMonths
|
a.defaultReportMonths = config.DefaultReportMonths
|
||||||
a.retentionMonths = config.RetentionMonths
|
a.retentionMonths = config.RetentionMonths
|
||||||
|
|
||||||
|
if a.retentionMonths < a.configOverrides.MinimumRetentionMonths {
|
||||||
|
a.retentionMonths = a.configOverrides.MinimumRetentionMonths
|
||||||
|
}
|
||||||
|
|
||||||
if a.configOverrides.CensusReportInterval > 0 {
|
if a.configOverrides.CensusReportInterval > 0 {
|
||||||
a.CensusReportInterval = a.configOverrides.CensusReportInterval
|
a.CensusReportInterval = a.configOverrides.CensusReportInterval
|
||||||
}
|
}
|
||||||
@@ -1013,6 +1020,9 @@ func (a *ActivityLog) SetConfig(ctx context.Context, config activityConfig) {
|
|||||||
|
|
||||||
a.defaultReportMonths = config.DefaultReportMonths
|
a.defaultReportMonths = config.DefaultReportMonths
|
||||||
a.retentionMonths = config.RetentionMonths
|
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
|
// check for segments out of retention period, if it has changed
|
||||||
go a.retentionWorker(ctx, time.Now(), a.retentionMonths)
|
go a.retentionWorker(ctx, time.Now(), a.retentionMonths)
|
||||||
|
|||||||
@@ -644,6 +644,9 @@ type Core struct {
|
|||||||
// censusAgent is the mechanism used for reporting Vault's billing data.
|
// censusAgent is the mechanism used for reporting Vault's billing data.
|
||||||
censusAgent *CensusAgent
|
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
|
// activeTime is set on active nodes indicating the time at which this node
|
||||||
// became active.
|
// became active.
|
||||||
activeTime time.Time
|
activeTime time.Time
|
||||||
|
|||||||
@@ -325,6 +325,11 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
|
|||||||
if config.Enabled == "enable" && enabledStr == "disable" ||
|
if config.Enabled == "enable" && enabledStr == "disable" ||
|
||||||
!activityLogEnabledDefault && config.Enabled == "enable" && enabledStr == "default" ||
|
!activityLogEnabledDefault && config.Enabled == "enable" && enabledStr == "default" ||
|
||||||
activityLogEnabledDefault && config.Enabled == "default" && enabledStr == "disable" {
|
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")
|
warnings = append(warnings, "the current monthly segment will be deleted because the activity log was disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ func TestCoreWithSealAndUINoCleanup(t testing.T, opts *CoreConfig) *Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conf.ActivityLogConfig = opts.ActivityLogConfig
|
conf.ActivityLogConfig = opts.ActivityLogConfig
|
||||||
|
testApplyEntBaseConfig(conf, opts)
|
||||||
|
|
||||||
c, err := NewCore(conf)
|
c, err := NewCore(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user