manual licese reporting persist snapshots CE (#25021)

This commit is contained in:
Hamid Ghaf
2024-01-24 12:29:33 -08:00
committed by GitHub
parent 4df19379cd
commit e735f12fd4
4 changed files with 21 additions and 19 deletions

View File

@@ -1155,7 +1155,7 @@ func (c *Core) setupActivityLogLocked(ctx context.Context, wg *sync.WaitGroup) e
close(manager.retentionDone) close(manager.retentionDone)
}(manager.retentionMonths) }(manager.retentionMonths)
manager.CensusReportDone = make(chan bool) manager.CensusReportDone = make(chan bool, 1)
go c.activityLog.CensusReport(ctx, c.CensusAgent(), c.BillingStart()) go c.activityLog.CensusReport(ctx, c.CensusAgent(), c.BillingStart())
} }

View File

@@ -10,11 +10,12 @@ import "time"
// CensusAgent is a stub for OSS // CensusAgent is a stub for OSS
type CensusReporter interface{} type CensusReporter interface{}
// setupCensusAgent is a stub for OSS. func (c *Core) setupCensusManager() error { return nil }
func (c *Core) setupCensusAgent() error { return nil }
func (c *Core) BillingStart() time.Time { return time.Time{} } func (c *Core) BillingStart() time.Time { return time.Time{} }
func (c *Core) AutomatedLicenseReportingEnabled() bool { return false } func (c *Core) AutomatedLicenseReportingEnabled() bool { return false }
func (c *Core) CensusAgent() CensusReporter { return nil } func (c *Core) CensusAgent() CensusReporter { return nil }
func (c *Core) ReloadCensus() error { return nil } func (c *Core) ReloadCensus() error { return nil }
func (c *Core) teardownCensusAgent() error { return nil } func (c *Core) teardownCensusManager() error { return nil }
func (c *Core) StartManualCensusSnapshots() {}
func (c *Core) ManualLicenseReportingEnabled() bool { return false } func (c *Core) ManualLicenseReportingEnabled() bool { return false }
func (c *Core) ManualCensusSnapshotInterval() time.Duration { return time.Duration(0) }

View File

@@ -636,8 +636,6 @@ type Core struct {
// it is protected by activityLogLock // it is protected by activityLogLock
activityLogConfig ActivityLogCoreConfig activityLogConfig ActivityLogCoreConfig
censusConfig atomic.Value
// 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
@@ -833,9 +831,6 @@ type CoreConfig struct {
LicensePath string LicensePath string
LicensingConfig *LicensingConfig LicensingConfig *LicensingConfig
// Configured Census Agent
CensusAgent CensusReporter
DisablePerformanceStandby bool DisablePerformanceStandby bool
DisableIndexing bool DisableIndexing bool
DisableKeyEncodingChecks bool DisableKeyEncodingChecks bool
@@ -2422,8 +2417,10 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
} }
if !c.IsDRSecondary() { if !c.IsDRSecondary() {
if err := c.setupCensusAgent(); err != nil { if !c.perfStandby {
logger.Error("skipping reporting for nil agent", "error", err) if err := c.setupCensusManager(); err != nil {
logger.Error("skipping license reporting for nil agent", "error", err)
}
} }
// not waiting on wg to avoid changing existing behavior // not waiting on wg to avoid changing existing behavior
@@ -2431,6 +2428,11 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
if err := c.setupActivityLog(ctx, &wg); err != nil { if err := c.setupActivityLog(ctx, &wg); err != nil {
return err return err
} }
if !c.perfStandby {
c.StartManualCensusSnapshots()
}
} else { } else {
broker, err := NewAuditBroker(logger) broker, err := NewAuditBroker(logger)
if err != nil { if err != nil {
@@ -2792,8 +2794,8 @@ func (c *Core) preSeal() error {
result = multierror.Append(result, fmt.Errorf("error stopping expiration: %w", err)) result = multierror.Append(result, fmt.Errorf("error stopping expiration: %w", err))
} }
c.stopActivityLog() c.stopActivityLog()
// Clean up the censusAgent on seal // Clean up census on seal
if err := c.teardownCensusAgent(); err != nil { if err := c.teardownCensusManager(); err != nil {
result = multierror.Append(result, fmt.Errorf("error tearing down reporting agent: %w", err)) result = multierror.Append(result, fmt.Errorf("error tearing down reporting agent: %w", err))
} }

View File

@@ -232,7 +232,6 @@ func TestCoreWithSealAndUINoCleanup(t testing.T, opts *CoreConfig) *Core {
conf.PluginDirectory = opts.PluginDirectory conf.PluginDirectory = opts.PluginDirectory
conf.DetectDeadlocks = opts.DetectDeadlocks conf.DetectDeadlocks = opts.DetectDeadlocks
conf.Experiments = opts.Experiments conf.Experiments = opts.Experiments
conf.CensusAgent = opts.CensusAgent
conf.AdministrativeNamespacePath = opts.AdministrativeNamespacePath conf.AdministrativeNamespacePath = opts.AdministrativeNamespacePath
conf.ImpreciseLeaseRoleTracking = opts.ImpreciseLeaseRoleTracking conf.ImpreciseLeaseRoleTracking = opts.ImpreciseLeaseRoleTracking