Suppress event broker not started log warning (#19593)

This commit is contained in:
Tom Proctor 2023-03-20 11:14:14 +00:00 committed by GitHub
parent 6fbf3da148
commit f1f5c8444a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 12 deletions

4
changelog/19593.txt Normal file
View File

@ -0,0 +1,4 @@
```release-note:improvement
events: Suppress log warnings triggered when events are sent but the events system is not enabled.
```

View File

@ -37,6 +37,10 @@ type GRPCEventsServer struct {
} }
func (s *GRPCEventsServer) SendEvent(ctx context.Context, req *pb.SendEventRequest) (*pb.Empty, error) { 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) err := s.impl.Send(ctx, logical.EventType(req.EventType), req.Event)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/hashicorp/go-uuid" "github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/builtin/plugin" "github.com/hashicorp/vault/builtin/plugin"
"github.com/hashicorp/vault/helper/experiments"
"github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/helper/namespace"
"github.com/hashicorp/vault/helper/versions" "github.com/hashicorp/vault/helper/versions"
"github.com/hashicorp/vault/sdk/helper/consts" "github.com/hashicorp/vault/sdk/helper/consts"
@ -1009,7 +1010,9 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV
Config: conf, Config: conf,
System: sysView, System: sysView,
BackendUUID: entry.BackendAwareUUID, BackendUUID: entry.BackendAwareUUID,
EventsSender: pluginEventSender, }
if c.IsExperimentEnabled(experiments.VaultExperimentEventsAlpha1) {
config.EventsSender = pluginEventSender
} }
b, err := f(ctx, config) b, err := f(ctx, config)

View File

@ -18,6 +18,7 @@ import (
"github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/hashicorp/go-uuid" "github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/builtin/plugin" "github.com/hashicorp/vault/builtin/plugin"
"github.com/hashicorp/vault/helper/experiments"
"github.com/hashicorp/vault/helper/metricsutil" "github.com/hashicorp/vault/helper/metricsutil"
"github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/helper/namespace"
"github.com/hashicorp/vault/helper/versions" "github.com/hashicorp/vault/helper/versions"
@ -1668,7 +1669,9 @@ func (c *Core) newLogicalBackend(ctx context.Context, entry *MountEntry, sysView
Config: conf, Config: conf,
System: sysView, System: sysView,
BackendUUID: entry.BackendAwareUUID, BackendUUID: entry.BackendAwareUUID,
EventsSender: pluginEventSender, }
if c.IsExperimentEnabled(experiments.VaultExperimentEventsAlpha1) {
config.EventsSender = pluginEventSender
} }
ctx = context.WithValue(ctx, "core_number", c.coreNumber) ctx = context.WithValue(ctx, "core_number", c.coreNumber)