-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moved run ID management to knapsack #1929
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ import ( | |
"go.etcd.io/bbolt" | ||
) | ||
|
||
// Package-level runID variable | ||
var runID string | ||
|
||
// type alias Flags, so that we can embed it inside knapsack, as `flags` and not `Flags` | ||
type flags types.Flags | ||
|
||
|
@@ -59,6 +62,18 @@ func New(stores map[storage.Store]types.KVStore, flags types.Flags, db *bbolt.DB | |
return k | ||
} | ||
|
||
// SetRunID sets the run ID in the knapsack | ||
func (k *knapsack) SetRunID(id string) { | ||
runID = id | ||
k.slogger.With("run_id", id) | ||
k.systemSlogger.With("run_id", id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need e.g. -- k.slogger = k.slogger.With("run_id", id)
k.systemSlogger = k.systemSlogger.With("run_id", id) ? I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I did that in launcher but missed in Knapsack. I have pushed out another commit to fix this with the assignment. |
||
} | ||
|
||
// GetRunID retrieves the run ID from the knapsack | ||
func (k *knapsack) GetRunID() string { | ||
return runID | ||
} | ||
|
||
// Logging interface methods | ||
func (k *knapsack) Slogger() *slog.Logger { | ||
return k.slogger.Logger | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this method?
I'd probably do something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that wouldn't cover the scenario where we want every time runLauncher is called to have a newID, I assume we could run into a situation where the ID is persisted if runLauncher is called after an update. Let me know if that's not the case and I can change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chatted on slack -- I think this is worth testing. I'm not sure if the restart/exec would have access to the same memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we did need to create a specific create method, my inclination would be to make
k.NewRunID()
and call it on startup. I think passing in the string feels wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to test the scenario and after the update we do get a new ID when we generate the ID in the GET method. I refactored the code to not have a set.