VAULT-35084, VAULT-36948, VAULT-36952: Small tasks left over from the recovery work (#10083) (#10101)

* small tasks left over from the recovery work

* changelog

* fix test

Co-authored-by: miagilepner <mia.epner@hashicorp.com>
This commit is contained in:
Vault Automation 2025-10-14 05:36:20 -04:00 committed by GitHub
parent f07b613f0a
commit 5d05b1d023
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 0 deletions

3
changelog/_10083.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:improvement
core/metrics: Reading and listing from a snapshot are now tracked via the `vault.route.read-snapshot.{mount_point}` and `vault.route.list-snapshot.{mount_point}` metrics.
```

View file

@ -187,6 +187,7 @@ func init() {
"sys/storage/raft/snapshot-force",
"!sys/storage/raft/snapshot-auto/config",
"sys/storage/raft/snapshot-load",
"!sys/storage/raft/snapshot-auto/snapshot-load",
})
websocketPaths.AddPaths(websocketRawPaths)
}

View file

@ -1208,3 +1208,24 @@ func TestHandler_JSONLimitQuotaWrappers(t *testing.T) {
})
}
}
// TestAutoSnapshotLoadForwarded tests that a request to load from a cloud
// snapshot is forwarded to the active node, rather than being redirected
func TestAutoSnapshotLoadForwarded(t *testing.T) {
cluster := vault.NewTestCluster(t, &vault.CoreConfig{}, &vault.TestClusterOptions{
NumCores: 2,
HandlerFunc: Handler,
})
cluster.Start()
defer cluster.Cleanup()
client := cluster.Cores[1].Client
client.SetToken(cluster.RootToken)
_, err := client.Logical().Write("sys/storage/raft/snapshot-auto/snapshot-load/cfg1", nil)
// the request will fail, but all that we care about is that the error
// doesn't indicate a redirect
require.Error(t, err)
require.NotContains(t, err.Error(), "redirects not allowed in these tests")
}

View file

@ -599,6 +599,9 @@ func (r *Router) routeCommon(ctx context.Context, req *logical.Request, existenc
req.Path = adjustedPath
if !existenceCheck {
metricName := []string{"route", string(req.Operation)}
if req.IsSnapshotReadOrList() {
metricName[1] = metricName[1] + "-snapshot"
}
if req.Operation != logical.RollbackOperation || r.rollbackMetricsMountName {
metricName = append(metricName, strings.ReplaceAll(mount, "/", "-"))
}