Skip to content

Commit

Permalink
Rename to run id
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Nov 4, 2024
1 parent 13b8e02 commit 34cd1ae
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions ee/tables/osquery_instance_history/osquery_instance_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TablePlugin() *table.Plugin {
columns := []table.ColumnDefinition{
table.TextColumn("internal_id"),
table.TextColumn("instance_run_id"),
table.TextColumn("start_time"),
table.TextColumn("connect_time"),
table.TextColumn("exit_time"),
Expand All @@ -33,14 +33,14 @@ func generate() table.GenerateFunc {
for _, instance := range history {

results = append(results, map[string]string{
"internal_id": instance.InternalId,
"start_time": instance.StartTime,
"connect_time": instance.ConnectTime,
"exit_time": instance.ExitTime,
"instance_id": instance.InstanceId,
"version": instance.Version,
"hostname": instance.Hostname,
"errors": instance.Error,
"instance_run_id": instance.RunId,
"start_time": instance.StartTime,
"connect_time": instance.ConnectTime,
"exit_time": instance.ExitTime,
"instance_id": instance.InstanceId,
"version": instance.Version,
"hostname": instance.Hostname,
"errors": instance.Error,
})
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/osquery/runtime/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func LatestInstanceUptimeMinutes() (int64, error) {
}

// NewInstance adds a new instance to the osquery instance history and returns it
func NewInstance(internalId string) (*Instance, error) {
func NewInstance(runId string) (*Instance, error) {
currentHistory.Lock()
defer currentHistory.Unlock()

Expand All @@ -98,9 +98,9 @@ func NewInstance(internalId string) (*Instance, error) {
}

newInstance := &Instance{
InternalId: internalId,
StartTime: timeNow(),
Hostname: hostname,
RunId: runId,
StartTime: timeNow(),
Hostname: hostname,
}

currentHistory.addInstanceToHistory(newInstance)
Expand Down
2 changes: 1 addition & 1 deletion pkg/osquery/runtime/history/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Instance struct {
InternalId string // ID assigned by launcher
RunId string // ID for instance, assigned by launcher
StartTime string
ConnectTime string
ExitTime string
Expand Down
18 changes: 9 additions & 9 deletions pkg/osquery/runtime/osqueryinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type OsqueryInstance struct {
serviceClient service.KolideService
// the following are instance artifacts that are created and held as a result
// of launching an osqueryd process
id string // string identifier for this instance
runId string // string identifier for this instance
errgroup *errgroup.Group
saasExtension *launcherosq.Extension
doneCtx context.Context // nolint:containedctx
Expand Down Expand Up @@ -189,12 +189,12 @@ type osqueryOptions struct {
}

func newInstance(knapsack types.Knapsack, serviceClient service.KolideService, opts ...OsqueryInstanceOption) *OsqueryInstance {
id := ulid.New()
runId := ulid.New()
i := &OsqueryInstance{
knapsack: knapsack,
slogger: knapsack.Slogger().With("component", "osquery_instance", "internal_id", id),
slogger: knapsack.Slogger().With("component", "osquery_instance", "instance_run_id", runId),
serviceClient: serviceClient,
id: id,
runId: runId,
}

for _, opt := range opts {
Expand Down Expand Up @@ -260,7 +260,7 @@ func (i *OsqueryInstance) Launch() error {

// Based on the root directory, calculate the file names of all of the
// required osquery artifact files.
paths, err := calculateOsqueryPaths(i.knapsack.RootDirectory(), i.id, i.opts)
paths, err := calculateOsqueryPaths(i.knapsack.RootDirectory(), i.runId, i.opts)
if err != nil {
traces.SetError(span, fmt.Errorf("could not calculate osquery file paths: %w", err))
return fmt.Errorf("could not calculate osquery file paths: %w", err)
Expand Down Expand Up @@ -360,7 +360,7 @@ func (i *OsqueryInstance) Launch() error {
"osquery socket created",
)

stats, err := history.NewInstance(i.id)
stats, err := history.NewInstance(i.runId)
if err != nil {
i.slogger.Log(ctx, slog.LevelWarn,
"could not create new osquery instance history",
Expand Down Expand Up @@ -665,20 +665,20 @@ type osqueryFilePaths struct {
// In return, a structure of paths is returned that can be used to launch an
// osqueryd instance. An error may be returned if the supplied parameters are
// unacceptable.
func calculateOsqueryPaths(rootDirectory string, id string, opts osqueryOptions) (*osqueryFilePaths, error) {
func calculateOsqueryPaths(rootDirectory string, runId string, opts osqueryOptions) (*osqueryFilePaths, error) {

// Determine the path to the extension socket
extensionSocketPath := opts.extensionSocketPath
if extensionSocketPath == "" {
extensionSocketPath = SocketPath(rootDirectory, id)
extensionSocketPath = SocketPath(rootDirectory, runId)
}

extensionAutoloadPath := filepath.Join(rootDirectory, "osquery.autoload")

// We want to use a unique pidfile per launcher run to avoid file locking issues.
// See: https://github.com/kolide/launcher/issues/1599
osqueryFilePaths := &osqueryFilePaths{
pidfilePath: filepath.Join(rootDirectory, fmt.Sprintf("osquery-%s.pid", id)),
pidfilePath: filepath.Join(rootDirectory, fmt.Sprintf("osquery-%s.pid", runId)),
databasePath: filepath.Join(rootDirectory, "osquery.db"),
augeasPath: filepath.Join(rootDirectory, "augeas-lenses"),
extensionSocketPath: extensionSocketPath,
Expand Down

0 comments on commit 34cd1ae

Please sign in to comment.