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:
akshya96
2024-04-15 12:07:22 -07:00
committed by GitHub
parent 6c01838269
commit 0701cc368c
4 changed files with 25 additions and 9 deletions

View File

@@ -1167,9 +1167,6 @@ func (c *Core) setupActivityLogLocked(ctx context.Context, wg *sync.WaitGroup) e
manager.retentionWorker(ctx, manager.clock.Now(), months)
close(manager.retentionDone)
}(manager.retentionMonths)
manager.CensusReportDone = make(chan bool, 1)
go c.activityLog.CensusReport(ctx, c.CensusAgent(), c.BillingStart())
}
return nil

12
vault/census_stubs_oss.go Normal file
View 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) {}

View File

@@ -2460,12 +2460,6 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
}
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
var wg sync.WaitGroup
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 err := c.setupCensusManager(); err != nil {
logger.Error("failed to instantiate the license reporting agent", "error", err)
}
c.StartCensusReports(ctx)
c.StartManualCensusSnapshots()
}

View File

@@ -353,6 +353,8 @@ func (b *SystemBackend) handleActivityConfigUpdate(ctx context.Context, req *log
return nil, err
}
prevRetentionMonths := config.RetentionMonths
{
// Parse the default report months
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
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 {
return &logical.Response{
Warnings: warnings,