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

adds control server acceleartion on menu open event, adds more failsafes for shutting down desktop when parent gone #1159

Merged

Conversation

James-Pickett
Copy link
Contributor

@James-Pickett James-Pickett commented Apr 25, 2023

This PR repurposes the "monitor_server" that was used only for the desktop user process to check on the root processes' health. The new runner server has an additional endpoint for "menuopened" that the desktop user process can call when it gets a notification from systray that the menu has been opened.

It introduces RunnerServer and renames DesktopServer to UserServer. Both servers are related to the desktop but one is run by the DesktopRunner and one is run by the Desktop User Process.

After this PR merges, I will do some reshuffling of the desktop package structure and put packages into either a user or runner folder based on their role.

It also:

  • Updates DesktopRunner to DeRegister desktop user clients form the RunnerServer when they are assumed to be dead. This way if the assumption was false and a new desktop user process was spun up, the old one should terminate it self since the RunnerServer will stop responding to it.
  • Updates the Desktop User Process to self terminate if it's ppid is less than 2. We've seen some funny cases where a user has 2 desktop processes running and one has a parent of 1 or 0.

closes: #1155
closes: #1141

cmd/launcher/desktop.go Outdated Show resolved Hide resolved
ee/desktop/runner/server/server.go Show resolved Hide resolved
r.Body.Close()
}

ms.knapsack.SetControlRequestIntervalOverride(5*time.Second, 1*time.Minute)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hooray for Knaspsack, it made this part so easy

@James-Pickett James-Pickett marked this pull request as ready for review April 25, 2023 21:31
cmd/launcher/desktop.go Outdated Show resolved Hide resolved
cmd/launcher/desktop.go Outdated Show resolved Hide resolved
cmd/launcher/desktop.go Outdated Show resolved Hide resolved
ee/desktop/runner/server/server.go Outdated Show resolved Hide resolved
RebeccaMahany
RebeccaMahany previously approved these changes Apr 26, 2023
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

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

Just a couple small comments, LGTM overall!

cmd/launcher/desktop.go Outdated Show resolved Hide resolved
ee/desktop/runner/server/server.go Show resolved Hide resolved
ee/desktop/runner/server/server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

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

🔥

controlRequestAcclerationDuration = 1 * time.Minute
)

type controlRequestIntervalOverrider interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay, cool to see the knapsack sub-interface in action. This feels clean too

}

func New(logger log.Logger, controlRequestIntervalOverrider controlRequestIntervalOverrider) (*RunnerServer, error) {
listener, err := net.Listen("tcp", "localhost:0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does using port zero mean it will choose a dynamically generated unused port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, it just picks a random port, it's what the current "monitor server" that is doing now on stable

@James-Pickett James-Pickett merged commit 29ee998 into kolide:main Apr 27, 2023
@James-Pickett James-Pickett deleted the james/accelearte-menu-interaction branch April 27, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple desktops appearing occasionally Can we accelerate the agent on menu interaction?
4 participants