Skip to content

Commit

Permalink
OSS-Changes Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
divyaac committed Dec 16, 2024
1 parent 2076dec commit 47874b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
12 changes: 9 additions & 3 deletions vault/activity_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4095,11 +4095,10 @@ func (a *ActivityLog) writeExport(ctx context.Context, rw http.ResponseWriter, f
func (c *Core) activityLogMigrationTask(ctx context.Context) {
manager := c.activityLog
if !c.IsPerfSecondary() {
// If the oldest version is less than 1.19 and no migrations tasks have been run, kick off the migration task
if !manager.OldestVersionHasDeduplicatedClients(ctx) && !manager.hasDedupClientsUpgrade(ctx) {
// If no migrations tasks have been run, kick off the migration task
if !manager.hasDedupClientsUpgrade(ctx) {
go c.primaryDuplicateClientMigrationWorker(ctx)
} else {
// Store that upgrade processes have already been completed
manager.writeDedupClientsUpgrade(ctx)
}
} else {
Expand All @@ -4108,6 +4107,8 @@ func (c *Core) activityLogMigrationTask(ctx context.Context) {
// already upgraded primary
if !manager.hasDedupClientsUpgrade(ctx) {
go c.secondaryDuplicateClientMigrationWorker(ctx)
} else {
manager.writeDedupClientsUpgrade(ctx)
}
}
}
Expand All @@ -4118,7 +4119,12 @@ func (c *Core) activityLogMigrationTask(ctx context.Context) {
// current cluster. This method wil only exit once all connected secondary clusters have
// upgraded to 1.19, and this cluster receives global data from all of them.
func (c *Core) primaryDuplicateClientMigrationWorker(ctx context.Context) error {
c.activityLogLock.Lock()
a := c.activityLog
c.activityLogLock.Unlock()
if a == nil {
return fmt.Errorf("activity log not configured")
}
a.logger.Trace("started primary activity log migration worker")
ctx, cancel := context.WithCancel(ctx)
defer cancel()
Expand Down
23 changes: 0 additions & 23 deletions vault/activity_log_util_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"time"

"github.com/axiomhq/hyperloglog"
semver "github.com/hashicorp/go-version"
"github.com/hashicorp/vault/helper/timeutil"
"github.com/hashicorp/vault/sdk/logical"
"github.com/hashicorp/vault/vault/activity"
Expand Down Expand Up @@ -640,28 +639,6 @@ func (a *ActivityLog) getAllEntitySegmentsForMonth(ctx context.Context, path str
return segments, nil
}

// OldestVersionHasDeduplicatedClients returns whether this cluster is 1.19+, and
// hence supports deduplicated clients
func (a *ActivityLog) OldestVersionHasDeduplicatedClients(ctx context.Context) bool {
oldestVersionIsDedupClients := a.core.IsNewInstall(ctx)
if !oldestVersionIsDedupClients {
if v, _, err := a.core.FindOldestVersionTimestamp(); err == nil {
oldestVersion, err := semver.NewSemver(v)
if err != nil {
a.core.logger.Debug("could not extract version instance", "version", v)
return false
}
dedupChangeVersion, err := semver.NewSemver(DeduplicatedClientMinimumVersion)
if err != nil {
a.core.logger.Debug("could not extract version instance", "version", DeduplicatedClientMinimumVersion)
return false
}
oldestVersionIsDedupClients = oldestVersionIsDedupClients || oldestVersion.GreaterThanOrEqual(dedupChangeVersion)
}
}
return oldestVersionIsDedupClients
}

func (a *ActivityLog) loadClientDataIntoSegment(ctx context.Context, pathPrefix string, startTime time.Time, seqNum uint64, currentSegment *segmentInfo) ([]*activity.EntityRecord, error) {
path := pathPrefix + activityEntityBasePath + fmt.Sprint(startTime.Unix()) + "/" + strconv.FormatUint(seqNum, 10)
out, err := a.readEntitySegmentAtPath(ctx, path)
Expand Down

0 comments on commit 47874b7

Please sign in to comment.