mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Ent only ADP Metrics (#21681)
* Ent only ADP Metrics * Added change log * Changed changelog name * Restored previous impl * Moved to mount_util * Change impl * Add same file * Moved to registry_util * Edited corehelpers mock registry * Edited chagnelog * Edited changelog * Edited build tag * Added back function * Delete core.go.rej * Edited mount * Changed spacing
This commit is contained in:
3
changelog/21681.txt
Normal file
3
changelog/21681.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
sys/metrics (enterprise): Adds a gauge metric that tracks whether enterprise builtin secret plugins are enabled.
|
||||||
|
```
|
||||||
10
helper/builtinplugins/registry_util.go
Normal file
10
helper/builtinplugins/registry_util.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
//go:build !enterprise
|
||||||
|
|
||||||
|
package builtinplugins
|
||||||
|
|
||||||
|
import "github.com/hashicorp/vault/sdk/helper/consts"
|
||||||
|
|
||||||
|
// IsBuiltinEntPlugin checks whether the plugin is an enterprise only builtin plugin
|
||||||
|
func (r *registry) IsBuiltinEntPlugin(name string, pluginType consts.PluginType) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ import (
|
|||||||
"github.com/mitchellh/go-testing-interface"
|
"github.com/mitchellh/go-testing-interface"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var externalPlugins = []string{"transform", "kmip", "keymgmt"}
|
||||||
|
|
||||||
// RetryUntil runs f until it returns a nil result or the timeout is reached.
|
// RetryUntil runs f until it returns a nil result or the timeout is reached.
|
||||||
// If a nil result hasn't been obtained by timeout, calls t.Fatal.
|
// If a nil result hasn't been obtained by timeout, calls t.Fatal.
|
||||||
func RetryUntil(t testing.T, timeout time.Duration, f func() error) {
|
func RetryUntil(t testing.T, timeout time.Duration, f func() error) {
|
||||||
@@ -180,10 +182,23 @@ func (m *mockBuiltinRegistry) Keys(pluginType consts.PluginType) []string {
|
|||||||
"pending-removal-test-plugin",
|
"pending-removal-test-plugin",
|
||||||
"approle",
|
"approle",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case consts.PluginTypeSecrets:
|
||||||
|
return append(externalPlugins, "kv")
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *mockBuiltinRegistry) IsBuiltinEntPlugin(name string, pluginType consts.PluginType) bool {
|
||||||
|
for _, i := range externalPlugins {
|
||||||
|
if i == name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mockBuiltinRegistry) Contains(name string, pluginType consts.PluginType) bool {
|
func (m *mockBuiltinRegistry) Contains(name string, pluginType consts.PluginType) bool {
|
||||||
for _, key := range m.Keys(pluginType) {
|
for _, key := range m.Keys(pluginType) {
|
||||||
if key == name {
|
if key == name {
|
||||||
|
|||||||
@@ -3181,6 +3181,7 @@ type BuiltinRegistry interface {
|
|||||||
Get(name string, pluginType consts.PluginType) (func() (interface{}, error), bool)
|
Get(name string, pluginType consts.PluginType) (func() (interface{}, error), bool)
|
||||||
Keys(pluginType consts.PluginType) []string
|
Keys(pluginType consts.PluginType) []string
|
||||||
DeprecationStatus(name string, pluginType consts.PluginType) (consts.DeprecationStatus, bool)
|
DeprecationStatus(name string, pluginType consts.PluginType) (consts.DeprecationStatus, bool)
|
||||||
|
IsBuiltinEntPlugin(name string, pluginType consts.PluginType) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) AuditLogger() AuditLogger {
|
func (c *Core) AuditLogger() AuditLogger {
|
||||||
|
|||||||
@@ -728,6 +728,10 @@ func (c *Core) mountInternal(ctx context.Context, entry *MountEntry, updateStora
|
|||||||
if err := c.router.Mount(backend, entry.Path, entry, view); err != nil {
|
if err := c.router.Mount(backend, entry.Path, entry, view); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err = c.entBuiltinPluginMetrics(ctx, entry, 1); err != nil {
|
||||||
|
c.logger.Error("failed to emit enabled ent builtin plugin metrics", "error", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Re-evaluate filtered paths
|
// Re-evaluate filtered paths
|
||||||
if err := runFilteredPathsEvaluation(ctx, c, false); err != nil {
|
if err := runFilteredPathsEvaluation(ctx, c, false); err != nil {
|
||||||
@@ -915,6 +919,10 @@ func (c *Core) unmountInternal(ctx context.Context, path string, updateStorage b
|
|||||||
if err := c.router.Unmount(ctx, path); err != nil {
|
if err := c.router.Unmount(ctx, path); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err = c.entBuiltinPluginMetrics(ctx, entry, -1); err != nil {
|
||||||
|
c.logger.Error("failed to emit disabled ent builtin plugin metrics", "error", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
removePathCheckers(c, entry, viewPath)
|
removePathCheckers(c, entry, viewPath)
|
||||||
|
|
||||||
|
|||||||
@@ -72,3 +72,7 @@ func (c *Core) mountEntrySysView(entry *MountEntry) extendedSystemView {
|
|||||||
}
|
}
|
||||||
return c.NewAcmeBillingSystemView(esi)
|
return c.NewAcmeBillingSystemView(esi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Core) entBuiltinPluginMetrics(ctx context.Context, entry *MountEntry, val float32) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user