-
Notifications
You must be signed in to change notification settings - Fork 1
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 plugins support #4
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -35,7 +35,7 @@ func shouldUpdate(response gusapi.UpdateResponse, sbomHash string) bool { | |
return true | ||
} | ||
|
||
func selfupdate(ctx context.Context, gusCli *gusapi.APIClient, gusServer, machineID, destinationDir string, response gusapi.UpdateResponse, httpPassword, httpPort string) error { | ||
func selfupdate(ctx context.Context, gusCli *gusapi.APIClient, plugins map[string]plugin, gusServer, machineID, destinationDir string, response gusapi.UpdateResponse, httpPassword, httpPort string) error { | ||
log.Print("starting self-update procedure") | ||
|
||
if _, _, err := gusCli.UpdateApi.Attempt(ctx, &gusapi.UpdateApiAttemptOpts{ | ||
|
@@ -52,12 +52,19 @@ func selfupdate(ctx context.Context, gusCli *gusapi.APIClient, gusServer, machin | |
|
||
switch response.RegistryType { | ||
case "http", "localdisk": | ||
readClosers, err = httpFetcher(response, gusServer, destinationDir) | ||
readClosers, err = httpUpdateFetch(response, gusServer, destinationDir) | ||
if err != nil { | ||
return fmt.Errorf("error fetching %q update from link %q: %w", response.RegistryType, response.DownloadLink, err) | ||
} | ||
default: | ||
return fmt.Errorf("unrecognized registry type %q", response.RegistryType) | ||
if _, ok := plugins[response.RegistryType]; !ok { | ||
return fmt.Errorf("error %q is not a loaded plugin", response.RegistryType) | ||
} | ||
|
||
readClosers, err = pluginFetchUpdate(ctx, plugins[response.RegistryType], destinationDir, response.DownloadLink) | ||
if err != nil { | ||
return fmt.Errorf("error fetching %q update from link %q: %w", response.RegistryType, response.DownloadLink, err) | ||
} | ||
} | ||
|
||
uri := fmt.Sprintf("http://gokrazy:%s@localhost:%s/", httpPassword, httpPort) | ||
|
@@ -98,7 +105,13 @@ func selfupdate(ctx context.Context, gusCli *gusapi.APIClient, gusServer, machin | |
return fmt.Errorf("switching to non-active partition: %v", err) | ||
} | ||
|
||
log.Print("reboot") | ||
log.Print("requesting reboot") | ||
// TODO: change call from target.Reboot to something like target.ScheduleReboot | ||
// which can asyncronouly perform the task instead of waiting | ||
// for all the services to shutdown and then ack the reboot, | ||
// othewise this causes a deadlock as the selfupdate service won't SIGTERM cleanly | ||
// until the reboot ack is received, but won't receive the ack until all services shut down, | ||
// causing a delayed reboot until SIGKILL kicks in. | ||
if err := target.Reboot(); err != nil { | ||
return fmt.Errorf("reboot: %v", err) | ||
} | ||
Comment on lines
+108
to
117
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. This one will need some thought 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. Hmm, why will selfupdate not SIGTERM cleanly in this state? I would have expected it to. SIGINT and SIGTERM are hooked up to context cancellation in selfupdate’s main function. |
||
|
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.
Changing this so then we get an immediate first check without waiting an extra
frequency
interval.Also changing the skipWaiting to only skip the Jitter once, the first time.
These two changes combined still achieve the same initially defined behaviour for skipWaiting, but improve the first check also in cases where skipWaiting is set to
false