Skip to content

Conversation

norio-nomura
Copy link
Contributor

  • Avoid restarting in the boot script if the executable and config have no changes.
  • lima-guestagent: Handle SIGTERM, support save/restore eventState on stop/start

Fixes #4216

@norio-nomura norio-nomura changed the title Minimize affects by restarting guestagent Minimize effects by restarting guestagent Oct 17, 2025
@norio-nomura norio-nomura changed the title Minimize effects by restarting guestagent Minimize effects caused by restarting guestagent Oct 17, 2025
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Oct 17, 2025
Short: "Install a systemd unit (user)",
RunE: installSystemdAction,
}
installSystemdCommand.Flags().Bool("guestagent-updated", false, "Indicate that the guest agent has been updated")
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively you can just compare mtime of os.Executable to detect whether it was updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to use the judgment result of "update guestagent" made in the boot script.
I don't want to increase the judgment logic of the update.


[Service]
ExecStart={{.Binary}} daemon {{.Args}}
ExecStart={{.Binary}} daemon {{.Args}} --runtime-dir="%t/%N"
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"%t/%N" will be expanded to "/run/lima-guestagent" by systemd.

Short: "Run the daemon",
RunE: daemonAction,
}
daemonCommand.Flags().String("runtime-dir", "/run/lima-guestagent", "Directory to store runtime state")
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to be customizable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for environment that does not want to use "/run/lima-guestagent"?
I don't know if there is such an environment. However, I can't think of a reason why it's better to hardcode this.

@norio-nomura norio-nomura force-pushed the minimize-affects-by-restarting-guestagent branch from d621e82 to 683bf84 Compare October 17, 2025 08:25
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Does this work with Alpine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works with both "template:alpine" and "template:alpine-iso", and has already been used in other boot scripts.

return &ticker, nil
}

var _ Ticker = (*ebpfTicker)(nil)
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let Go check whether ebpfTicker fits the type Ticker interface.
By doing this, VSCode's Go extension recognizes the relationship between these types and makes it more convenient.

t1, t2 Ticker
}

var _ Ticker = (*compoundTicker)(nil)
Copy link
Member

Choose a reason for hiding this comment

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

?

…on stop/start

`eventState` is saved at `/run/lima-guestagent/event-state.json`.
The saved `eventState` is expected to be removed on OS restart.

Signed-off-by: Norio Nomura <[email protected]>
@norio-nomura norio-nomura force-pushed the minimize-affects-by-restarting-guestagent branch from 683bf84 to 5008118 Compare October 21, 2025 00:08
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.

"error":"rpc error: code = Unavailable desc = error reading from server: EOF","level":"warning","msg":"guest agent events closed unexpectedly"

2 participants