feat: answer ApplyUpdatesCmd with a PatchResult and reboot when the command asks

This commit is contained in:
2026-09-15 08:09:40 +00:00
parent db75d7dcbd
commit ecd703d502
4 changed files with 143 additions and 19 deletions
+1 -17
View File
@@ -341,7 +341,7 @@ func connectAndHandleStream(ctx context.Context, cfg *config.Config) error {
go handleUpdateAgent(cmd)
}
if cmd.ApplyUpdates != nil {
go handleApplyUpdates(cfg, cmd)
go handleApplyUpdates(send, cfg, cmd)
}
if cmd.CleanupWorkspace != nil {
go handleCleanupWorkspace(cmd)
@@ -480,22 +480,6 @@ func runInventory(ctx context.Context, cfg *config.Config) {
}
}
func handleApplyUpdates(cfg *config.Config, cmd *pb.ServerCommand) {
log.Printf("applying OS updates (cmd=%s)…", cmd.CommandId)
if _, err := updates.Apply(updates.ApplyOptions{}); err != nil {
log.Printf("OS upgrade failed (cmd=%s): %v", cmd.CommandId, err)
return
}
log.Printf("OS updates applied successfully (cmd=%s)", cmd.CommandId)
client, err := grpcclient.New(cfg.ServerURL, cfg.TLS)
if err != nil {
return
}
defer client.Close()
_ = client.ReportUpdates(cfg.ServerID, cfg.AgentToken, nil)
}
func handleCleanupWorkspace(cmd *pb.ServerCommand) {
id := cmd.CleanupWorkspace.WorkspaceId
dir := agentexec.WorkspacePath(id)