fix(patch): gate phases on the window deadline, queue undelivered results, retry startup inventory
The window deadline no longer kills a running package manager: it only gates the start of each phase, and a started upgrade runs under a 2 hour backstop that sends SIGTERM on Linux. A PatchResult whose send fails is queued and flushed on the next command stream, retaking the reboot decision. deb822 folded Suites continuation lines are filtered with the field. The startup static inventory report is retried until it succeeds.
This commit is contained in:
@@ -26,8 +26,11 @@ type ApplyOptions struct {
|
||||
// metadata reports Unsupported and installs nothing: it never falls back
|
||||
// to installing everything.
|
||||
SecurityOnly bool
|
||||
// Deadline is when the upgrade must be finished, normally the end of the
|
||||
// maintenance window. Zero means defaultApplyCap from now.
|
||||
// Deadline is the end of the maintenance window. It only gates the start
|
||||
// of each phase (index refresh, upgrade, Windows install): a phase that
|
||||
// has not started by then is not started, and one already running is
|
||||
// allowed to finish, bounded by defaultApplyCap from its own start. Zero
|
||||
// means a manual run with no window.
|
||||
Deadline time.Time
|
||||
}
|
||||
|
||||
@@ -42,6 +45,9 @@ type Result struct {
|
||||
// ErrBusy means another Apply is already running on this host.
|
||||
var ErrBusy = errors.New("an update run is already in progress on this host")
|
||||
|
||||
// defaultApplyCap is the backstop for one started upgrade command, counted
|
||||
// from that command's own start. It exists for a package manager that hangs,
|
||||
// not to enforce the window.
|
||||
const defaultApplyCap = 2 * time.Hour
|
||||
|
||||
var applyMu sync.Mutex
|
||||
@@ -53,11 +59,7 @@ func Apply(opts ApplyOptions) (Result, error) {
|
||||
return Result{}, ErrBusy
|
||||
}
|
||||
defer applyMu.Unlock()
|
||||
deadline := opts.Deadline
|
||||
if deadline.IsZero() {
|
||||
deadline = time.Now().Add(defaultApplyCap)
|
||||
}
|
||||
return apply(opts.SecurityOnly, deadline)
|
||||
return apply(opts.SecurityOnly, opts.Deadline)
|
||||
}
|
||||
|
||||
// ScheduleReboot restarts the host after a short grace period, so a result
|
||||
|
||||
Reference in New Issue
Block a user