Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backports for ActivityLog and Reporting 1.11.x #21210

Merged
merged 29 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2eb6aa8
backport of commit 8dedb31a78223bd1790cdd09614371ba6ef08e8c
ncabatoff Sep 7, 2022
87626c4
backport of commit 50a1f9e86a027af858a7c140288a9cc06f207053
ccapurso Oct 7, 2022
2d47471
backport of commit 840abfbe10427b571c5afde38d79a5f24435c668
raskchanky Nov 10, 2022
a156bf3
backport of commit 87aa644ca82c75449cbaaaf7e24f14907841447e
raskchanky Nov 15, 2022
4f2e5cc
backport of commit b8de2c2b4e574c5fabde01c9be8c93c4e390c897
raskchanky Dec 17, 2022
209f691
backport of commit cb61488b9a96dd79e09371add1a4c06394dacd95
raskchanky Jan 5, 2023
26e0df2
backport of commit d641bbc28e5e8cc12b81d409e5d5fc1f2cb7f66c
raskchanky Jan 9, 2023
71f8725
backport of commit 2a5a07e390bca84e5dca73a441d99528d26fad99
peteski22 Jan 16, 2023
1a9eae6
backport of commit 771bd8ba6d73bfb4d1fd870c8ccb53315378aa18
raskchanky Jan 19, 2023
e978e83
backport of commit b5d7d47ca2b22e08eda08bf4da7ee1418f753581
miagilepner Feb 6, 2023
3c7a975
backport of commit a9e17c20119ecf090ba419974bb22f4e822b8a90
miagilepner Feb 24, 2023
dec3f37
backport of commit 9f7f8d5bfad0aa3f06a4fcd86484f3e2f01a40a4
miagilepner Mar 6, 2023
95c757a
backport of commit e3c59773e969336bb4e85ddbf3a3700a6250f4c8
mpalmi Mar 20, 2023
0501594
backport of commit b4fab6ac2ae830f3bec8c287f07d5193dcfcdc22
miagilepner Mar 31, 2023
8af6cfa
backport of commit d70c17f7fd2cc3621c571d5213a2b46ffe63c00f
miagilepner Apr 6, 2023
691068a
backport of commit 4b6ec4079d1bdccde4cab416417a296c8c233c1b
miagilepner Apr 11, 2023
258a87e
backport of commit 05ba6bbddded428d2fa010f9359d0543f46af52b
mpalmi Apr 12, 2023
f8ac8b3
backport of commit 002a59a370a80c846191ece427bef92f25bf81eb
mpalmi Apr 13, 2023
bebb9e6
backport of commit 77f83d9fe8b85c126347794a460410c2025675fd
mpalmi Apr 21, 2023
b52afc8
backport of commit 730d0e2821dbc3bb1fe91ade183aa8c2908eaae5
miagilepner May 16, 2023
bfb61db
backport of commit 35e2c1665f009183088387532e17d02ded312e18
miagilepner May 19, 2023
d4dd125
backport of commit 810d504e4f676e857632230bf565eaa214927bcd
mpalmi May 22, 2023
6a1d5bc
Add ListMounts method backport for activitylog generation
mpalmi Jun 13, 2023
e8329bc
backport of commit 5b23dd506fb3d2c79f4a18b995a72548560cc799
miagilepner May 23, 2023
acb910e
backport of commit 018ea84997b49137ae3884e00e4dc9fc389f8b50
miagilepner May 23, 2023
024fe9c
backport of commit 541f18eeb782cd0c8ee28b961e99c3adf952bd22
miagilepner May 24, 2023
af28611
backport of commit b4e2751a09d411abef62a3769b08e9f1ce647e25
miagilepner May 25, 2023
28dd651
backport of commit dc5dd71c72a981e703379484bcac57e32af01fec
ncabatoff Jun 2, 2023
2ccb340
backport of commit 5002489d279ea2a98342ae31f342e0cd9c888e85
miagilepner Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/17028.txt
@@ -0,0 +1,3 @@
```release-note:improvement
core: Activity log goroutine management improvements to allow tests to be more deterministic.
```
3 changes: 3 additions & 0 deletions changelog/17856.txt
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,3 @@
```release-note:improvement
core (enterprise): add configuration for license reporting
```
3 changes: 3 additions & 0 deletions changelog/20073.txt
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Expand Up @@ -1644,6 +1644,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
Expand Up @@ -955,6 +955,7 @@ func testParseSeals(t *testing.T) {
},
},
}
addExpectedDefaultEntConfig(expected)
raskchanky marked this conversation as resolved.
Show resolved Hide resolved
config.Prune()
require.Equal(t, config, expected)
}
Expand Down
1 change: 1 addition & 0 deletions command/server/config_test_helpers_util.go
Expand Up @@ -3,4 +3,5 @@
package server

func addExpectedEntConfig(c *Config, sentinelModules []string) {}
func addExpectedDefaultEntConfig(c *Config) {}
raskchanky marked this conversation as resolved.
Show resolved Hide resolved
func addExpectedEntSanitizedConfig(c map[string]interface{}, sentinelModules []string) {}
23 changes: 4 additions & 19 deletions helper/metricsutil/gauge_process.go
Expand Up @@ -7,24 +7,9 @@ import (
"time"

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 @@ -69,7 +54,7 @@ type GaugeCollectionProcess struct {
ticker *time.Ticker

// time source
clock clock
clock timeutil.Clock
}

// NewGaugeCollectionProcess creates a new collection process for the callback
Expand All @@ -88,7 +73,7 @@ func (m *ClusterMetricSink) NewGaugeCollectionProcess(
id,
collector,
logger,
defaultClock{},
timeutil.DefaultClock{},
)
}

Expand All @@ -98,7 +83,7 @@ func (m *ClusterMetricSink) newGaugeCollectionProcessWithClock(
id []Label,
collector GaugeCollector,
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
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
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
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;
mpalmi marked this conversation as resolved.
Show resolved Hide resolved
}