mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
adding retention months to census reports CE (#26405)
* adding retention months to census reports CE changes * using stubmaker * make fmt * change reload census agent to reload census
This commit is contained in:
@@ -1167,9 +1167,6 @@ func (c *Core) setupActivityLogLocked(ctx context.Context, wg *sync.WaitGroup) e
|
|||||||
manager.retentionWorker(ctx, manager.clock.Now(), months)
|
manager.retentionWorker(ctx, manager.clock.Now(), months)
|
||||||
close(manager.retentionDone)
|
close(manager.retentionDone)
|
||||||
}(manager.retentionMonths)
|
}(manager.retentionMonths)
|
||||||
|
|
||||||
manager.CensusReportDone = make(chan bool, 1)
|
|
||||||
go c.activityLog.CensusReport(ctx, c.CensusAgent(), c.BillingStart())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
12
vault/census_stubs_oss.go
Normal file
12
vault/census_stubs_oss.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) HashiCorp, Inc.
|
||||||
|
// SPDX-License-Identifier: BUSL-1.1
|
||||||
|
|
||||||
|
//go:build !enterprise
|
||||||
|
|
||||||
|
package vault
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
//go:generate go run github.com/hashicorp/vault/tools/stubmaker
|
||||||
|
|
||||||
|
func (c *Core) StartCensusReports(ctx context.Context) {}
|
||||||
@@ -2460,12 +2460,6 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsDRSecondary() {
|
if !c.IsDRSecondary() {
|
||||||
if !c.perfStandby {
|
|
||||||
if err := c.setupCensusManager(); err != nil {
|
|
||||||
logger.Error("failed to instantiate the license reporting agent", "error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// not waiting on wg to avoid changing existing behavior
|
// not waiting on wg to avoid changing existing behavior
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
if err := c.setupActivityLog(ctx, &wg); err != nil {
|
if err := c.setupActivityLog(ctx, &wg); err != nil {
|
||||||
@@ -2473,6 +2467,12 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.perfStandby {
|
if !c.perfStandby {
|
||||||
|
if err := c.setupCensusManager(); err != nil {
|
||||||
|
logger.Error("failed to instantiate the license reporting agent", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.StartCensusReports(ctx)
|
||||||
|
|
||||||
c.StartManualCensusSnapshots()
|
c.StartManualCensusSnapshots()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,6 +353,8 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevRetentionMonths := config.RetentionMonths
|
||||||
|
|
||||||
{
|
{
|
||||||
// Parse the default report months
|
// Parse the default report months
|
||||||
if defaultReportMonthsRaw, ok := d.GetOk("default_report_months"); ok {
|
if defaultReportMonthsRaw, ok := d.GetOk("default_report_months"); ok {
|
||||||
@@ -438,6 +440,11 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
|
|||||||
// Set the new config on the activity log
|
// Set the new config on the activity log
|
||||||
a.SetConfig(ctx, config)
|
a.SetConfig(ctx, config)
|
||||||
|
|
||||||
|
// reload census agent if retention months change during update when reporting is enabled
|
||||||
|
if prevRetentionMonths != config.RetentionMonths {
|
||||||
|
a.core.ReloadCensus()
|
||||||
|
}
|
||||||
|
|
||||||
if len(warnings) > 0 {
|
if len(warnings) > 0 {
|
||||||
return &logical.Response{
|
return &logical.Response{
|
||||||
Warnings: warnings,
|
Warnings: warnings,
|
||||||
|
|||||||
Reference in New Issue
Block a user