From 1bc7950402208d93bd9dfec8bef791f51696386c Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 16 Mar 2023 20:54:27 +0000 Subject: [PATCH 1/3] Suppress event broker not started log warning --- sdk/plugin/grpc_events.go | 4 ++++ vault/auth.go | 15 +++++++++------ vault/mount.go | 15 +++++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sdk/plugin/grpc_events.go b/sdk/plugin/grpc_events.go index 8f08e230d5f0..05d788c66cd0 100644 --- a/sdk/plugin/grpc_events.go +++ b/sdk/plugin/grpc_events.go @@ -37,6 +37,10 @@ type GRPCEventsServer struct { } func (s *GRPCEventsServer) SendEvent(ctx context.Context, req *pb.SendEventRequest) (*pb.Empty, error) { + if s.impl == nil { + return &pb.Empty{}, nil + } + err := s.impl.Send(ctx, logical.EventType(req.EventType), req.Event) if err != nil { return nil, err diff --git a/vault/auth.go b/vault/auth.go index e3fc75d5d82d..ee590bc22684 100644 --- a/vault/auth.go +++ b/vault/auth.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/builtin/plugin" + "github.com/hashicorp/vault/helper/experiments" "github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/helper/versions" "github.com/hashicorp/vault/sdk/helper/consts" @@ -1004,12 +1005,14 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV } config := &logical.BackendConfig{ - StorageView: view, - Logger: authLogger, - Config: conf, - System: sysView, - BackendUUID: entry.BackendAwareUUID, - EventsSender: pluginEventSender, + StorageView: view, + Logger: authLogger, + Config: conf, + System: sysView, + BackendUUID: entry.BackendAwareUUID, + } + if c.IsExperimentEnabled(experiments.VaultExperimentEventsAlpha1) { + config.EventsSender = pluginEventSender } b, err := f(ctx, config) diff --git a/vault/mount.go b/vault/mount.go index baf41c9f1584..9936e6bdae38 100644 --- a/vault/mount.go +++ b/vault/mount.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/builtin/plugin" + "github.com/hashicorp/vault/helper/experiments" "github.com/hashicorp/vault/helper/metricsutil" "github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/helper/versions" @@ -1663,12 +1664,14 @@ func (c *Core) newLogicalBackend(ctx context.Context, entry *MountEntry, sysView return nil, "", err } config := &logical.BackendConfig{ - StorageView: view, - Logger: backendLogger, - Config: conf, - System: sysView, - BackendUUID: entry.BackendAwareUUID, - EventsSender: pluginEventSender, + StorageView: view, + Logger: backendLogger, + Config: conf, + System: sysView, + BackendUUID: entry.BackendAwareUUID, + } + if c.IsExperimentEnabled(experiments.VaultExperimentEventsAlpha1) { + config.EventsSender = pluginEventSender } ctx = context.WithValue(ctx, "core_number", c.coreNumber) From 176cb577641ae0cbf2461dd639f4369a114f79f7 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 16 Mar 2023 20:57:43 +0000 Subject: [PATCH 2/3] Add changelog --- changelog/19592.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/19592.txt diff --git a/changelog/19592.txt b/changelog/19592.txt new file mode 100644 index 000000000000..8f170578ec07 --- /dev/null +++ b/changelog/19592.txt @@ -0,0 +1,4 @@ +```release-note:improvement +events: Suppress log warnings triggered when events are sent but the events system is not enabled. +``` + From ec66a77003b2106aa3a822a5fe49e4323b1e2440 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 16 Mar 2023 20:58:41 +0000 Subject: [PATCH 3/3] Fix changelog PR number --- changelog/{19592.txt => 19593.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{19592.txt => 19593.txt} (100%) diff --git a/changelog/19592.txt b/changelog/19593.txt similarity index 100% rename from changelog/19592.txt rename to changelog/19593.txt