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.
24 lines
773 B
Go
24 lines
773 B
Go
package updates
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// canStart is the whole "may this phase begin" decision. The maintenance
|
|
// window deadline only gates the start of a phase: a package manager that is
|
|
// already running is never interrupted by it, because killing apt, dnf or
|
|
// Windows Update partway through a transaction is worse than letting it
|
|
// finish late. A zero deadline is a manual run, which always may start.
|
|
func canStart(now, deadline time.Time) bool {
|
|
return deadline.IsZero() || now.Before(deadline)
|
|
}
|
|
|
|
// startGate returns the error reported when a phase is refused.
|
|
func startGate(deadline time.Time, phase string) error {
|
|
if canStart(time.Now(), deadline) {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("the maintenance window ended before %s could start", phase)
|
|
}
|