mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
Vault 34678-Removing estimates from counters api: Handle billing start date updates CE (#30266)
* adding handle billing start date changes ce * fix ce version for reload census manager
This commit is contained in:
parent
46aa6454a5
commit
e8071a4890
@ -1692,7 +1692,7 @@ func (c *ServerCommand) Run(args []string) int {
|
||||
sr.NotifyConfigurationReload(srConfig)
|
||||
}
|
||||
|
||||
if err := core.ReloadCensusManager(false); err != nil {
|
||||
if err := core.ReloadCensusManager(ctx, false); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
}
|
||||
|
||||
|
||||
@ -214,12 +214,19 @@ type ActivityLog struct {
|
||||
// is written. It's used for unit testing
|
||||
precomputedQueryWritten chan struct{}
|
||||
|
||||
clientIDsUsage ClientUsageInfo
|
||||
}
|
||||
|
||||
type ClientUsageInfo struct {
|
||||
// clientIDsUsageInfoLock controls access to the ClientUsageInfo
|
||||
clientIDsUsageInfoLock sync.RWMutex
|
||||
|
||||
// setupClientIDsUsageInfoCancelCtx is used to cancel and restart setupClientIDsUsageInfo goroutine during reloads
|
||||
setupClientIDsUsageInfoCancelCtx context.CancelFunc
|
||||
|
||||
// The clientIDsUsageInfo map has clientIDs that have been used in the current billing period
|
||||
clientIDsUsageInfo map[string]struct{}
|
||||
|
||||
// clientIDsUsageInfoLock controls access to the clientIDsUsageInfo
|
||||
clientIDsUsageInfoLock sync.RWMutex
|
||||
|
||||
// clientIDsUsageInfoLoaded is set to true when the clientIDsUsageInfo has up-to date information upon startup.
|
||||
// This ensures that the counters api returns exact values for new clients in the current month upon startup.
|
||||
clientIDsUsageInfoLoaded *atomic.Bool
|
||||
@ -342,8 +349,10 @@ func NewActivityLog(core *Core, logger log.Logger, view *BarrierView, metrics me
|
||||
standbyFragmentsReceived: make([]*activity.LogFragment, 0),
|
||||
inprocessExport: atomic.NewBool(false),
|
||||
precomputedQueryWritten: make(chan struct{}),
|
||||
clientIDsUsageInfo: make(map[string]struct{}),
|
||||
clientIDsUsageInfoLoaded: new(atomic.Bool),
|
||||
clientIDsUsage: ClientUsageInfo{
|
||||
clientIDsUsageInfo: make(map[string]struct{}),
|
||||
clientIDsUsageInfoLoaded: new(atomic.Bool),
|
||||
},
|
||||
}
|
||||
|
||||
config, err := a.loadConfigOrDefault(core.activeContext)
|
||||
|
||||
@ -559,19 +559,19 @@ func (a *ActivityLog) namespaceRecordToCountsResponse(record *activity.Namespace
|
||||
}
|
||||
|
||||
func (a *ActivityLog) GetClientIDsUsageInfo() map[string]struct{} {
|
||||
a.clientIDsUsageInfoLock.Lock()
|
||||
defer a.clientIDsUsageInfoLock.Unlock()
|
||||
return a.clientIDsUsageInfo
|
||||
a.clientIDsUsage.clientIDsUsageInfoLock.Lock()
|
||||
defer a.clientIDsUsage.clientIDsUsageInfoLock.Unlock()
|
||||
return a.clientIDsUsage.clientIDsUsageInfo
|
||||
}
|
||||
|
||||
func (a *ActivityLog) SetClientIDsUsageInfo(inMemClientIDsMap map[string]struct{}) {
|
||||
a.clientIDsUsageInfoLock.Lock()
|
||||
defer a.clientIDsUsageInfoLock.Unlock()
|
||||
a.clientIDsUsage.clientIDsUsageInfoLock.Lock()
|
||||
defer a.clientIDsUsage.clientIDsUsageInfoLock.Unlock()
|
||||
|
||||
a.clientIDsUsageInfo = inMemClientIDsMap
|
||||
a.clientIDsUsage.clientIDsUsageInfo = inMemClientIDsMap
|
||||
}
|
||||
|
||||
// GetclientIDsUsageInfoLoaded gets a.clientIDsUsageInfoLoaded for external tests
|
||||
func (a *ActivityLog) GetClientIDsUsageInfoLoaded() bool {
|
||||
return a.clientIDsUsageInfoLoaded.Load()
|
||||
return a.clientIDsUsage.clientIDsUsageInfoLoaded.Load()
|
||||
}
|
||||
|
||||
@ -15,17 +15,17 @@ const utilizationBasePath = "utilization"
|
||||
// CensusAgent is a stub for OSS
|
||||
type CensusReporter interface{}
|
||||
|
||||
func (c *Core) BillingStart() time.Time { return time.Time{} }
|
||||
func (c *Core) AutomatedLicenseReportingEnabled() bool { return false }
|
||||
func (c *Core) CensusAgent() CensusReporter { return nil }
|
||||
func (c *Core) teardownCensusManager() error { return nil }
|
||||
func (c *Core) StartManualCensusSnapshots() {}
|
||||
func (c *Core) ManualLicenseReportingEnabled() bool { return false }
|
||||
func (c *Core) ManualCensusSnapshotInterval() time.Duration { return time.Duration(0) }
|
||||
func (c *Core) ManualCensusSnapshotRetentionTime() time.Duration { return time.Duration(0) }
|
||||
func (c *Core) StartCensusReports(ctx context.Context) {}
|
||||
func (c *Core) SetRetentionMonths(months int) error { return nil }
|
||||
func (c *Core) ReloadCensusManager(licenseChange bool) error { return nil }
|
||||
func (c *Core) BillingStart() time.Time { return time.Time{} }
|
||||
func (c *Core) AutomatedLicenseReportingEnabled() bool { return false }
|
||||
func (c *Core) CensusAgent() CensusReporter { return nil }
|
||||
func (c *Core) teardownCensusManager() error { return nil }
|
||||
func (c *Core) StartManualCensusSnapshots() {}
|
||||
func (c *Core) ManualLicenseReportingEnabled() bool { return false }
|
||||
func (c *Core) ManualCensusSnapshotInterval() time.Duration { return time.Duration(0) }
|
||||
func (c *Core) ManualCensusSnapshotRetentionTime() time.Duration { return time.Duration(0) }
|
||||
func (c *Core) StartCensusReports(ctx context.Context) {}
|
||||
func (c *Core) SetRetentionMonths(months int) error { return nil }
|
||||
func (c *Core) ReloadCensusManager(ctx context.Context, licenseChange bool) error { return nil }
|
||||
func (c *Core) parseCensusManagerConfig(conf *CoreConfig) (CensusManagerConfig, error) {
|
||||
return CensusManagerConfig{}, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user