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.12.x #21133

Merged
merged 26 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7fa126f
backport of commit 840abfbe10427b571c5afde38d79a5f24435c668
raskchanky Nov 10, 2022
ce41a91
backport of commit 87aa644ca82c75449cbaaaf7e24f14907841447e
raskchanky Nov 15, 2022
309cf80
backport of commit b8de2c2b4e574c5fabde01c9be8c93c4e390c897
raskchanky Dec 17, 2022
bc08333
backport of commit cb61488b9a96dd79e09371add1a4c06394dacd95
raskchanky Jan 5, 2023
7309865
backport of commit d641bbc28e5e8cc12b81d409e5d5fc1f2cb7f66c
raskchanky Jan 9, 2023
1e8f1b6
backport of commit 2a5a07e390bca84e5dca73a441d99528d26fad99
Jan 16, 2023
761878d
backport of commit 771bd8ba6d73bfb4d1fd870c8ccb53315378aa18
raskchanky Jan 19, 2023
45ffa71
backport of commit b5d7d47ca2b22e08eda08bf4da7ee1418f753581
miagilepner Feb 6, 2023
baddce8
backport of commit a9e17c20119ecf090ba419974bb22f4e822b8a90
miagilepner Feb 24, 2023
914431b
backport of commit 9f7f8d5bfad0aa3f06a4fcd86484f3e2f01a40a4
miagilepner Mar 6, 2023
1d8a6d5
backport of commit e3c59773e969336bb4e85ddbf3a3700a6250f4c8
mpalmi Mar 20, 2023
40bc460
backport of commit b4fab6ac2ae830f3bec8c287f07d5193dcfcdc22
miagilepner Mar 31, 2023
7c70383
backport of commit 54904e4cd6d6cb37e876d8b93c37d292b3419dd3
miagilepner Apr 4, 2023
9576b89
backport of commit 4b6ec4079d1bdccde4cab416417a296c8c233c1b
miagilepner Apr 11, 2023
f31148d
backport of commit 05ba6bbddded428d2fa010f9359d0543f46af52b
mpalmi Apr 12, 2023
49eef41
backport of commit 002a59a370a80c846191ece427bef92f25bf81eb
mpalmi Apr 13, 2023
d040b69
backport of commit 77f83d9fe8b85c126347794a460410c2025675fd
mpalmi Apr 21, 2023
e9872e6
backport of commit 730d0e2821dbc3bb1fe91ade183aa8c2908eaae5
miagilepner May 16, 2023
aa7f940
backport of commit 35e2c1665f009183088387532e17d02ded312e18
miagilepner May 19, 2023
9c07a1c
backport of commit 810d504e4f676e857632230bf565eaa214927bcd
mpalmi May 22, 2023
0bb3bad
backport of commit 5b23dd506fb3d2c79f4a18b995a72548560cc799
miagilepner May 23, 2023
d0cde52
backport of commit 018ea84997b49137ae3884e00e4dc9fc389f8b50
miagilepner May 23, 2023
2148f66
backport of commit 541f18eeb782cd0c8ee28b961e99c3adf952bd22
miagilepner May 24, 2023
592a288
backport of commit b4e2751a09d411abef62a3769b08e9f1ce647e25
miagilepner May 25, 2023
92fa1f4
backport of commit dc5dd71c72a981e703379484bcac57e32af01fec
ncabatoff Jun 2, 2023
89247a2
backport of commit 5002489d279ea2a98342ae31f342e0cd9c888e85
miagilepner Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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