-
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
Generate the enrollment details on launcher startup #2045
Conversation
… and update related methods
…rollmentDetails struct to types
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
@@ -528,6 +541,15 @@ func (ta *TufAutoupdater) checkForUpdate(binariesToCheck []autoupdatableBinary) | |||
if updatedVersion, ok := updatesDownloaded[binaryLauncher]; ok { | |||
// Only reload if we're not using a localdev path | |||
if ta.knapsack.LocalDevelopmentPath() == "" { | |||
ctx := context.Background() |
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'll defer to becca, but I'm not sure this is the right place
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.
Thinking...we have both LauncherVersion
and OsqueryVersion
inside the enrollment details, so that's why I'd wanted it updated after autoupdate. If we want to keep it here for that reason, then it probably makes more sense to only update EnrollmentDetails.LauncherVersion
and EnrollmentDetails.OsqueryVersion
-- we don't need to regenerate the rest of the enrollment details at this time. What do you think?
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 work! Left a couple comments, will continue to keep an eye on the discussion about where we want to update launcher/osquery version 🙂
cmd/launcher/launcher.go
Outdated
) | ||
} | ||
return err | ||
}, 30*time.Second, 5*time.Second); err != nil { |
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.
This can delay launcher startup for up to 30 seconds -- I think we probably don't want to do that. Maybe we should call getEnrollmentDetails
in a goroutine so that it doesn't halt startup? (We would probably want to make knapsack.enrollmentDetails
nullable -- var enrollmentDetails *types.EnrollmentDetails
-- and then have extension.Enroll
wait for those details to be available.)
@@ -528,6 +541,15 @@ func (ta *TufAutoupdater) checkForUpdate(binariesToCheck []autoupdatableBinary) | |||
if updatedVersion, ok := updatesDownloaded[binaryLauncher]; ok { | |||
// Only reload if we're not using a localdev path | |||
if ta.knapsack.LocalDevelopmentPath() == "" { | |||
ctx := context.Background() |
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.
Thinking...we have both LauncherVersion
and OsqueryVersion
inside the enrollment details, so that's why I'd wanted it updated after autoupdate. If we want to keep it here for that reason, then it probably makes more sense to only update EnrollmentDetails.LauncherVersion
and EnrollmentDetails.OsqueryVersion
-- we don't need to regenerate the rest of the enrollment details at this time. What do you think?
I'm starting over to make the changes simpler. I'll also add a requirement of not caching the quick look up part of the call and focus the caching only on the osquery details |
This pull request introduces new functionality for managing enrollment details and updates several mocks in the
knapsack
package. The key changes include adding methods for setting and getting enrollment details, movingEnrollmentDetails
to a new location, and updating the mocks accordingly.Open Questions:
New Functionality for Enrollment Details:
cmd/launcher/launcher.go
: Added logic to retrieve and set runtime enrollment details, including a retry mechanism with backoff for fetching osquery enrollment details.ee/agent/knapsack/knapsack.go
: IntroducedSetEnrollmentDetails
andGetEnrollmentDetails
methods to manage enrollment details.ee/agent/types/enrollment.go
: MovedEnrollmentDetails
struct from the service package to the types package, and definedEnrollmentStatus
constants.ee/agent/types/knapsack.go
: Updated theKnapsack
interface to include methods for managing enrollment details.Updates to Mocks:
ee/agent/types/mocks/knapsack.go
: Added mock implementations for the newGetEnrollmentDetails
andSetEnrollmentDetails
methods. [1] [2]ee/agent/types/mocks/flags.go
: Removed several unused mock methods related to osquery endpoints.These changes enhance the functionality and maintainability of the
knapsack
package by providing a standardized way to handle enrollment details and updating the mocks to reflect the new methods.Updates to Autoupdate:
New Functionality
collectAndSetEnrollmentDetails
method to preserve system state during updatesCode Structure
ee/tuf/autoupdate.go
:Test Improvements
ee/tuf/autoupdate_test.go
:Configuration Options
WithOsquerierBackoff
for flexible timing control