Skip to content

Commit

Permalink
backport of commit e6427b2 (hashicorp#19620)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Proctor <tomhjp@users.noreply.github.com>
  • Loading branch information
hc-github-team-secure-vault-core and tomhjp committed Mar 20, 2023
1 parent 4285eb5 commit 435824c
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 @@ -34,6 +34,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 @@ -10,6 +10,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 @@ -1001,12 +1002,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 @@ -15,6 +15,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 @@ -1660,12 +1661,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 435824c

Please sign in to comment.