Skip to content
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 remote restart consumer to handle remote restart actions #1948

Merged
merged 9 commits into from
Nov 12, 2024

Conversation

RebeccaMahany
Copy link
Contributor

@RebeccaMahany RebeccaMahany commented Nov 8, 2024

This PR implements support for remote restart actions from the control server.

For this new action, it is important that we perform the action exactly once. This PR contains two features to ensure that the action will only be performed once:

  1. The remote restart consumer returns success, then waits for a short delay before actually performing the restart. This will give the actionqueue a chance to store the action as successfully performed before the restart occurs, so that the action will not be performed a second time.
  2. The remote restart action is tied to launcher's run ID, so the restart action will only be performed if the run ID matches. This will keep the remote restart consumer from accidentally applying the restart action multiple times if we fail to store the action as completed in the actionqueue's store.

@RebeccaMahany RebeccaMahany added the features-improvements Features and Improvements label Nov 11, 2024
level.Debug(logger).Log("msg", "run launcher", "stack", fmt.Sprintf("%+v", err))
return 1
}
level.Debug(logger).Log("msg", "runLauncher exited to run newer version of launcher", "err", err.Error())
level.Debug(logger).Log("msg", "runLauncher exited to reload launcher", "err", err.Error())
if err := runNewerLauncherIfAvailable(ctx, slogger.Logger); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works on macOS/Linux unless there is nothing to be found in the autoupdate library, in which case launcher will exit and we would have to rely on the init system (launchd/systemd) to restart launcher. (On Windows, we always exit completely and rely on the Service Manager to restart launcher.)

This seems like an okay tradeoff to me, since we will be doing this action only rarely as a troubleshooting step, but I wanted to flag it in case others disagree.

@RebeccaMahany RebeccaMahany marked this pull request as ready for review November 11, 2024 21:11
zackattack01
zackattack01 previously approved these changes Nov 11, 2024
Copy link
Contributor

@zackattack01 zackattack01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exciting! looks great

@RebeccaMahany RebeccaMahany added this pull request to the merge queue Nov 12, 2024
Merged via the queue into kolide:main with commit c6fe8b7 Nov 12, 2024
29 checks passed
@RebeccaMahany RebeccaMahany deleted the becca/remote-restart branch November 12, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features-improvements Features and Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants