-
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
Add sqlite database for storing shared agent data; store and monitor startup data #1515
Conversation
416e2d1
to
618000c
Compare
aa73c87
to
d1d9867
Compare
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.
Nice
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.
Mostly nits. (and our future selves, we're having a slack discussion about the call semantics of startup)
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.
LGTM!
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 this is okay. I like the underlying functions, but I feel a little nervous about error handling
conn, err := sql.Open("sqlite", dbLocation(rootDirectory)) | ||
if err != nil { | ||
return nil, fmt.Errorf("opening startup db in %s: %w", rootDirectory, err) | ||
} |
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.
What should happen if the file doesn't exist? (I'm honestly not sure)
Should OpenRO
return something with nils? Return an error and let the caller handle it? I guess letting the caller handle it is correct
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.
Related -- we might want validateDb
in here?
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.
You'd asked for the RO option to be more lightweight and to skip the validation when we'd discussed on slack, since we need to use the RO option early on in launcher startup.
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 thinking about skipping migration -- I'm less sure what should happen if the DB file isn't present. Or doesn't match expected schema. Bailing early and getting nothing isn't 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 guess that's probably the right way to look at it -- If the DB is wrong, we should bail out and get nothing. Maybe it doesn't exist yet, maybe it hasn't been udpated to the current schema. So whatever we need to catch that and move on
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 will handle that in the next PR that starts to use the RO connection
238fd17
The new
startup
package monitors the flags that it's registered to observe, and updates them in a shared sqlite database on change. It also allows for querying for these flags outside of the launcher root context. This will be useful on launcher startup, when we need to pull autoupdate-related settings before we haveknapsack
available.The new
agentsqlite
database is a partial implementation of a KVStore -- I only added Get/Set/Update, since that was what was required for the newstartup
package.