Skip to content

Commit

Permalink
Suppress event broker not started log warning (hashicorp#19593)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhjp committed Mar 20, 2023
1 parent 98f4d1f commit e6427b2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions changelog/19593.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
events: Suppress log warnings triggered when events are sent but the events system is not enabled.
```

4 changes: 4 additions & 0 deletions sdk/plugin/grpc_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions vault/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions vault/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e6427b2

Please sign in to comment.