Skip to content

Commit

Permalink
Add new store for ZTA info
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Feb 7, 2025
1 parent 774a6d3 commit 0288928
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 74 deletions.
11 changes: 9 additions & 2 deletions cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
desktopMenuSubsystemName = "kolide_desktop_menu"
authTokensSubsystemName = "auth_tokens"
katcSubsystemName = "katc_config" // Kolide ATC
ztaInfoSubsystemName = "zta_info"
)

// runLauncher is the entry point into running launcher. It creates a
Expand Down Expand Up @@ -482,8 +483,8 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
return fmt.Errorf("failed to register auth token consumer: %w", err)
}

// begin log shipping and subsribe to token updates
// nil check incase it failed to create for some reason
// begin log shipping and subscribe to token updates
// nil check in case it failed to create for some reason
if logShipper != nil {
controlService.RegisterSubscriber(authTokensSubsystemName, logShipper)
}
Expand All @@ -504,6 +505,12 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
// information is made available from server_data (e.g. on a fresh install)
metadataWriter.Ping()
}

// Set up consumer to receive ZTA info from the control server
ztaInfoConsumer := keyvalueconsumer.New(k.ZtaInfoStore())
if err := controlService.RegisterConsumer(ztaInfoSubsystemName, ztaInfoConsumer); err != nil {
return fmt.Errorf("failed to register ZTA info consumer: %w", err)
}
}

runEECode := k.ControlServerURL() != "" || k.IAmBreakingEELicense()
Expand Down
4 changes: 4 additions & 0 deletions ee/agent/knapsack/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (k *knapsack) LauncherHistoryStore() types.KVStore {
return k.getKVStore(storage.LauncherHistoryStore)
}

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

func (k *knapsack) SetLauncherWatchdogEnabled(enabled bool) error {
return k.flags.SetLauncherWatchdogEnabled(enabled)
}
Expand Down
1 change: 1 addition & 0 deletions ee/agent/storage/bbolt/stores_bbolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func MakeStores(ctx context.Context, slogger *slog.Logger, db *bbolt.DB) (map[st
storage.TokenStore,
storage.ControlServerActionsStore,
storage.LauncherHistoryStore,
storage.ZtaInfoStore,
}

for _, storeName := range storeNames {
Expand Down
1 change: 1 addition & 0 deletions ee/agent/storage/ci/stores_ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func MakeStores(t *testing.T, slogger *slog.Logger, db *bbolt.DB) (map[storage.S
storage.ServerProvidedDataStore,
storage.TokenStore,
storage.LauncherHistoryStore,
storage.ZtaInfoStore,
}

if os.Getenv("CI") == "true" {
Expand Down
1 change: 1 addition & 0 deletions ee/agent/storage/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
TokenStore Store = "token_store" // The store used for holding bearer auth tokens, e.g. the ones used to authenticate with the observability ingest server.
ControlServerActionsStore Store = "action_store" // The store used for storing actions sent by control server.
LauncherHistoryStore Store = "launcher_history" // The store used for storing launcher start time history currently.
ZtaInfoStore Store = "zta_info" // The store used for storing ZTA info about this device
)

func (storeType Store) String() string {
Expand Down
72 changes: 36 additions & 36 deletions ee/agent/types/mocks/flags.go

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

92 changes: 56 additions & 36 deletions ee/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 ee/agent/types/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ type Stores interface {
ServerProvidedDataStore() KVStore
TokenStore() KVStore
LauncherHistoryStore() KVStore
ZtaInfoStore() KVStore
}

0 comments on commit 0288928

Please sign in to comment.