diff --git a/vault/activity/query.go b/vault/activity/query.go index adcc17a4ec..9b15f8024f 100644 --- a/vault/activity/query.go +++ b/vault/activity/query.go @@ -46,8 +46,8 @@ type MonthlyNamespaceRecord struct { } type MountRecord struct { - Path string `json:"path"` - Counts *CountsRecord `json:"counts"` + MountPath string `json:"mount_path"` + Counts *CountsRecord `json:"counts"` } type PrecomputedQuery struct { diff --git a/vault/activity_log.go b/vault/activity_log.go index 45b0cbf3fc..95bf9fe912 100644 --- a/vault/activity_log.go +++ b/vault/activity_log.go @@ -97,7 +97,8 @@ type ActivityLog struct { // Acquire "l" before fragmentLock if both must be held. l sync.RWMutex - // fragmentLock protects enable, activeClients, fragment, standbyFragmentsReceived + // fragmentLock protects enable, partialMonthClientTracker, fragment, + // standbyFragmentsReceived. fragmentLock sync.RWMutex // enabled indicates if the activity log is enabled for this cluster. @@ -621,9 +622,9 @@ func (a *ActivityLog) loadPriorEntitySegment(ctx context.Context, startTime time return nil } -// loadCurrentClientSegment loads the most recent segment (for "this month") into memory -// (to append new entries), and to the activeClients to avoid duplication -// call with fragmentLock and l held +// loadCurrentClientSegment loads the most recent segment (for "this month") +// into memory (to append new entries), and to the partialMonthClientTracker to +// avoid duplication call with fragmentLock and l held. func (a *ActivityLog) loadCurrentClientSegment(ctx context.Context, startTime time.Time, sequenceNum uint64) error { path := activityEntityBasePath + fmt.Sprint(startTime.Unix()) + "/" + strconv.FormatUint(sequenceNum, 10) data, err := a.view.Get(ctx, path) @@ -1485,8 +1486,8 @@ type ResponseMonthlyNamespace struct { } type ResponseMount struct { - Path string `json:"path"` - Counts *ResponseCounts `json:"counts"` + MountPath string `json:"mount_path"` + Counts *ResponseCounts `json:"counts"` } // ActivityLogInjectResponse injects a precomputed query into storage for testing. @@ -1549,7 +1550,7 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T mountResponse := make([]*ResponseMount, 0, len(nsRecord.Mounts)) for _, mountRecord := range nsRecord.Mounts { mountResponse = append(mountResponse, &ResponseMount{ - Path: mountRecord.Path, + MountPath: mountRecord.MountPath, Counts: &ResponseCounts{ EntityClients: int(mountRecord.Counts.EntityClients), NonEntityClients: int(mountRecord.Counts.NonEntityClients), @@ -1617,7 +1618,7 @@ func (a *ActivityLog) handleQuery(ctx context.Context, startTime, endTime time.T } mountResponse = append(mountResponse, &ResponseMount{ - Path: mountRecord.Path, + MountPath: mountRecord.MountPath, Counts: &ResponseCounts{ EntityClients: int(mountRecord.Counts.EntityClients), NonEntityClients: int(mountRecord.Counts.NonEntityClients), @@ -2125,7 +2126,7 @@ func (a *ActivityLog) precomputedQueryWorker(ctx context.Context) error { continue } mountRecord = append(mountRecord, &activity.MountRecord{ - Path: valResp.MountPath, + MountPath: valResp.MountPath, Counts: &activity.CountsRecord{ EntityClients: len(mountData.Counts.Entities), NonEntityClients: int(mountData.Counts.Tokens) + len(mountData.Counts.NonEntities), @@ -2177,7 +2178,7 @@ func (a *ActivityLog) precomputedQueryWorker(ctx context.Context) error { continue } mountRecord = append(mountRecord, &activity.MountRecord{ - Path: valResp.MountPath, + MountPath: valResp.MountPath, Counts: &activity.CountsRecord{ EntityClients: len(mountData.Counts.Entities), NonEntityClients: int(mountData.Counts.Tokens) + len(mountData.Counts.NonEntities), @@ -2360,7 +2361,7 @@ func (a *ActivityLog) partialMonthClientCount(ctx context.Context) (map[string]i mountResponse := make([]*ResponseMount, 0, len(nsRecord.Mounts)) for mountPath, mountRecord := range nsRecord.Mounts { mountResponse = append(mountResponse, &ResponseMount{ - Path: mountPath, + MountPath: mountPath, Counts: &ResponseCounts{ EntityClients: len(mountRecord.Counts.Entities), NonEntityClients: len(mountRecord.Counts.NonEntities), @@ -2425,7 +2426,7 @@ func (a *ActivityLog) partialMonthClientCount(ctx context.Context) (map[string]i } mountResponse = append(mountResponse, &ResponseMount{ - Path: mountPath, + MountPath: mountPath, Counts: &ResponseCounts{ EntityClients: len(mountRecord.Counts.Entities), NonEntityClients: len(mountRecord.Counts.NonEntities), diff --git a/vault/activity_log_testing_util.go b/vault/activity_log_testing_util.go index e2c71e520f..14fe56c88c 100644 --- a/vault/activity_log_testing_util.go +++ b/vault/activity_log_testing_util.go @@ -53,7 +53,8 @@ func (c *Core) InjectActivityLogDataThisMonth(t *testing.T) map[string]*activity return c.activityLog.partialMonthClientTracker } -// Return the in-memory activeClients from an activity log +// GetActiveClients returns the in-memory partialMonthClientTracker from an +// activity log. func (c *Core) GetActiveClients() map[string]*activity.EntityRecord { out := make(map[string]*activity.EntityRecord) @@ -151,7 +152,7 @@ func (a *ActivityLog) ExpectCurrentSegmentRefreshed(t *testing.T, expectedStart t.Errorf("expected non-nil currentSegment.tokenCount.CountByNamespaceID") } if a.partialMonthClientTracker == nil { - t.Errorf("expected non-nil activeClients") + t.Errorf("expected non-nil partialMonthClientTracker") } if len(a.currentSegment.currentClients.Clients) > 0 { t.Errorf("expected no current entity segment to be loaded. got: %v", a.currentSegment.currentClients)