Skip to content

Commit

Permalink
backports for Activitylog and Reporting 1.12.x (#21133)
Browse files Browse the repository at this point in the history
* backport of commit 840abfb

* backport of commit 87aa644

* backport of commit b8de2c2

* backport of commit cb61488

* backport of commit d641bbc

* backport of commit 2a5a07e

* backport of commit 771bd8b

* backport of commit b5d7d47

* backport of commit a9e17c2

* backport of commit 9f7f8d5

* backport of commit e3c5977

* backport of commit b4fab6a

* backport of commit 54904e4

* backport of commit 4b6ec40

* backport of commit 05ba6bb

* backport of commit 002a59a

* backport of commit 77f83d9

* backport of commit 730d0e2

* backport of commit 35e2c16

* backport of commit 810d504

* backport of commit 5b23dd5

* backport of commit 018ea84

* backport of commit 541f18e

* backport of commit b4e2751

* backport of commit dc5dd71

* backport of commit 5002489

---------

Co-authored-by: Josh Black <[email protected]>
Co-authored-by: Peter Wilson <[email protected]>
Co-authored-by: miagilepner <[email protected]>
Co-authored-by: Nick Cabatoff <[email protected]>
  • Loading branch information
5 people authored Jun 14, 2023
1 parent 26c98f5 commit e81c1f2
Show file tree
Hide file tree
Showing 37 changed files with 2,486 additions and 434 deletions.
3 changes: 3 additions & 0 deletions changelog/17856.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: fix the end_date returned from the activity log endpoint when partial counts are computed
```
3 changes: 3 additions & 0 deletions changelog/17935.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: return partial month counts when querying a historical date range and no historical data exists.
```
3 changes: 3 additions & 0 deletions changelog/18452.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: de-duplicate namespaces when historical and current month data are mixed
```
3 changes: 3 additions & 0 deletions changelog/18598.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: include mount counts when de-duplicating current and historical month data
```
3 changes: 3 additions & 0 deletions changelog/18766.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: add namespace breakdown for new clients when date range spans multiple months, including the current month.
```
3 changes: 3 additions & 0 deletions changelog/18916.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core/activity: report mount paths (rather than mount accessors) in current month activity log counts and include deleted mount paths in precomputed queries.
```
4 changes: 4 additions & 0 deletions changelog/19625.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:feature
core (enterprise): Add background worker for automatic reporting of billing
information.
```
3 changes: 3 additions & 0 deletions changelog/19891.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core (enterprise): add configuration for license reporting
```
3 changes: 3 additions & 0 deletions changelog/20073.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core/activity: refactor the activity log's generation of precomputed queries
```
3 changes: 3 additions & 0 deletions changelog/20078.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
core/activity: error when attempting to update retention configuration below the minimum
```
4 changes: 4 additions & 0 deletions changelog/20086.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
api: `/sys/internal/counters/config` endpoint now contains read-only
`reporting_enabled` and `billing_start_timestamp` fields.
```
4 changes: 4 additions & 0 deletions changelog/20150.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
api: `/sys/internal/counters/config` endpoint now contains read-only
`minimum_retention_months`.
```
6 changes: 6 additions & 0 deletions changelog/20680.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:improvement
core (enterprise): support reloading configuration for automated reporting via SIGHUP
```
```release-note:improvement
core (enterprise): license updates trigger a reload of reporting and the activity log
```
4 changes: 4 additions & 0 deletions changelog/20694.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
api: GET ... /sys/internal/counters/activity?current_billing_period=true now
results in a response which contains the full billing period
```
3 changes: 3 additions & 0 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,9 @@ func (c *ServerCommand) Run(args []string) int {
c.UI.Error(err.Error())
}

if err := core.ReloadCensus(); err != nil {
c.UI.Error(err.Error())
}
select {
case c.licenseReloadedCh <- err:
default:
Expand Down
1 change: 1 addition & 0 deletions command/server/config_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ func testParseSeals(t *testing.T) {
},
},
}
addExpectedDefaultEntConfig(expected)
config.Prune()
require.Equal(t, config, expected)
}
Expand Down
1 change: 1 addition & 0 deletions command/server/config_test_helpers_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
package server

func addExpectedEntConfig(c *Config, sentinelModules []string) {}
func addExpectedDefaultEntConfig(c *Config) {}
func addExpectedEntSanitizedConfig(c map[string]interface{}, sentinelModules []string) {}
25 changes: 5 additions & 20 deletions helper/metricsutil/gauge_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@ import (

"github.com/armon/go-metrics"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/helper/timeutil"
)

// This interface allows unit tests to substitute in a simulated clock.
type clock interface {
Now() time.Time
NewTicker(time.Duration) *time.Ticker
}

type defaultClock struct{}

func (_ defaultClock) Now() time.Time {
return time.Now()
}

func (_ defaultClock) NewTicker(d time.Duration) *time.Ticker {
return time.NewTicker(d)
}

// GaugeLabelValues is one gauge in a set sharing a single key, that
// are measured in a batch.
type GaugeLabelValues struct {
Expand Down Expand Up @@ -73,7 +58,7 @@ type GaugeCollectionProcess struct {
maxGaugeCardinality int

// time source
clock clock
clock timeutil.Clock
}

// NewGaugeCollectionProcess creates a new collection process for the callback
Expand All @@ -98,7 +83,7 @@ func NewGaugeCollectionProcess(
gaugeInterval,
maxGaugeCardinality,
logger,
defaultClock{},
timeutil.DefaultClock{},
)
}

Expand All @@ -121,7 +106,7 @@ func (m *ClusterMetricSink) NewGaugeCollectionProcess(
m.GaugeInterval,
m.MaxGaugeCardinality,
logger,
defaultClock{},
timeutil.DefaultClock{},
)
}

Expand All @@ -134,7 +119,7 @@ func newGaugeCollectionProcessWithClock(
gaugeInterval time.Duration,
maxGaugeCardinality int,
logger log.Logger,
clock clock,
clock timeutil.Clock,
) (*GaugeCollectionProcess, error) {
process := &GaugeCollectionProcess{
stop: make(chan struct{}, 1),
Expand Down
6 changes: 4 additions & 2 deletions helper/metricsutil/gauge_process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/armon/go-metrics"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/helper/timeutil"
)

// SimulatedTime maintains a virtual clock so the test isn't
Expand All @@ -21,9 +22,10 @@ import (
type SimulatedTime struct {
now time.Time
tickerBarrier chan *SimulatedTicker
timeutil.DefaultClock
}

var _ clock = &SimulatedTime{}
var _ timeutil.Clock = &SimulatedTime{}

type SimulatedTicker struct {
ticker *time.Ticker
Expand Down Expand Up @@ -118,7 +120,7 @@ func TestGauge_Creation(t *testing.T) {
t.Fatalf("Error creating collection process: %v", err)
}

if _, ok := p.clock.(defaultClock); !ok {
if _, ok := p.clock.(timeutil.DefaultClock); !ok {
t.Error("Default clock not installed.")
}

Expand Down
23 changes: 23 additions & 0 deletions helper/timeutil/timeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,26 @@ func SkipAtEndOfMonth(t *testing.T) {
t.Skip("too close to end of month")
}
}

// This interface allows unit tests to substitute in a simulated Clock.
type Clock interface {
Now() time.Time
NewTicker(time.Duration) *time.Ticker
NewTimer(time.Duration) *time.Timer
}

type DefaultClock struct{}

var _ Clock = (*DefaultClock)(nil)

func (_ DefaultClock) Now() time.Time {
return time.Now()
}

func (_ DefaultClock) NewTicker(d time.Duration) *time.Ticker {
return time.NewTicker(d)
}

func (_ DefaultClock) NewTimer(d time.Duration) *time.Timer {
return time.NewTimer(d)
}
72 changes: 31 additions & 41 deletions vault/activity/generation/generate_data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions vault/activity/generation/generate_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ message Clients {
message Client {
string id = 1;
int32 count = 2;
int32 times_seen = 3;
bool repeated = 4;
int32 repeated_from_month = 5;
string namespace = 6;
string mount = 7;
bool non_entity = 8;
bool repeated = 3;
int32 repeated_from_month = 4;
string namespace = 5;
string mount = 6;
bool non_entity = 7;
}
Loading

0 comments on commit e81c1f2

Please sign in to comment.