adding retention months to census reports CE (#26175)

* adding retention months to census reports CE changes

* using stubmaker

* make fmt
This commit is contained in:
akshya96
2024-04-12 13:20:49 -07:00
committed by GitHub
parent eb35916034
commit 8605230df7
4 changed files with 26 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

13
vault/census_stubs_oss.go Normal file
View File

@@ -0,0 +1,13 @@
// 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) {}
func (c *Core) ReloadCensusAgent() error { return nil }

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.ReloadCensusAgent()
}
if len(warnings) > 0 {
return &logical.Response{
Warnings: warnings,