Skip to content

Commit

Permalink
Use new store for tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jun 14, 2023
1 parent 3d72ca1 commit 0a1059b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func runLauncher(ctx context.Context, cancel func(), opts *launcher.Options) err
}

// Set up our tracing instrumentation
ingestConsumer := tokenconsumer.NewIngestTokenConsumer(k.ConfigStore())
ingestConsumer := tokenconsumer.NewIngestTokenConsumer(k.TokenStore())
if err := controlService.RegisterConsumer(tokenconsumer.IngestSubsystem, ingestConsumer); err != nil {
return fmt.Errorf("failed to register ingest consumer: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (k *knapsack) ServerProvidedDataStore() types.KVStore {
return k.getKVStore(storage.ServerProvidedDataStore)
}

func (k *knapsack) TokenStore() types.KVStore {
return k.getKVStore(storage.TokenStore)
}

func (k *knapsack) getKVStore(storeType storage.Store) types.KVStore {
if k == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/agent/storage/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
SentNotificationsStore Store = "sent_notifications" // The store used for sent notifications.
StatusLogsStore Store = "status_logs" // The store used for buffered status logs.
ServerProvidedDataStore Store = "server_provided_data" // The store used for pushing values from server-backed tables.
TokenStore Store = "token_store" // The store used for holding bearer auth tokens, e.g. the ones used to authenticate with the observability ingest server.
)

func (storeType Store) String() string {
Expand Down
16 changes: 16 additions & 0 deletions pkg/agent/types/mocks/knapsack.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/agent/types/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ type Stores interface {
SentNotificationsStore() KVStore
StatusLogsStore() KVStore
ServerProvidedDataStore() KVStore
TokenStore() KVStore
}
4 changes: 2 additions & 2 deletions pkg/traces/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewTraceExporter(ctx context.Context, k types.Knapsack, client osquery.Quer
attrs = append(attrs, archAttr)
}

currentToken, _ := k.ConfigStore().Get(tokenconsumer.ObservabilityIngestTokenKey)
currentToken, _ := k.TokenStore().Get(tokenconsumer.ObservabilityIngestTokenKey)

t := &TraceExporter{
knapsack: k,
Expand Down Expand Up @@ -238,7 +238,7 @@ func (t *TraceExporter) Interrupt(_ error) {
// Update satisfies control.subscriber interface -- looks at changes to the `observability_ingest` subsystem,
// which amounts to a new bearer auth token being provided.
func (t *TraceExporter) Ping() {
newToken, err := t.knapsack.ConfigStore().Get(tokenconsumer.ObservabilityIngestTokenKey)
newToken, err := t.knapsack.TokenStore().Get(tokenconsumer.ObservabilityIngestTokenKey)
if err != nil {
level.Debug(t.logger).Log("msg", "could not get new token from token store", "err", err)
return
Expand Down

0 comments on commit 0a1059b

Please sign in to comment.