fleet/orbit/pkg/packaging
Dan Fuhry 6e227b6eb5
[orbit/packaging] delay restart for in-band pkg upgrade on Linux (#31286)
Admins _should_ be upgrading orbit/osqueryd/fleet-desktop using TUF, but
there's no official path for pushing updates to the orbit environment
file (`/etc/default/orbit`).

Knowing that this file is installed by fleet-osquery, I naively pushed a
new fleet-osquery package to a user's machine, thinking that would be
fine installing over the existing package. Instead it actually broke
orbit entirely on the host, rendering it unreachable until the user
manually reinstalled the package. This is because the pre-removal script
unconditionally stops orbit even if it's being upgraded, and when orbit
is stopped it terminates any processes underneath it, including the
ongoing package installation.

To workaround this, we replace the simple
`systemctl restart orbit.service` with a check for the `INSTALLER_PATH`
environment variable that orbit sets during software installations. If
the variable is present, `systemd-run` is used to schedule the service
restart 60 seconds in the future, which is assumed to be more than
enough time for the package manager to finish and exit. Unfortunately,
this bugfix cannot be made retroactive, because the broken version of
the prerm script is called before the new package starts to be
unpacked/installed.

Although there are other ways of doing anything an administrator might
be trying to accomplish by pushing a new fleet-osquery package, bricking
an endpoint simply by pushing this package through the Software page
seems like a pretty massive footgun that is easy to protect against.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added support for safe in-band upgrades of DEB and RPM packages
generated by the `fleetctl package` command via the Software page, after
an initial manual update.

* **Documentation**
* Added a note clarifying the new upgrade process and the need for a
one-time manual update before using in-band upgrades.

* **Bug Fixes**
* Improved upgrade scripts to prevent the Orbit service from stopping
unexpectedly during package upgrades, ensuring smoother and safer
updates.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Dan Fuhry <dan@fuhry.com>
2025-07-28 15:55:44 +02:00
..
wix Orbit for Windows ARM64 (#27882) 2025-04-11 10:18:28 -04:00
certs.pem Update Orbit CA certs [automated] (#20148) 2024-07-02 15:22:52 -03:00
deb.go update documentation of orbit/pkg/packaging (#6819) 2022-07-25 20:14:20 -03:00
linux_shared.go [orbit/packaging] delay restart for in-band pkg upgrade on Linux (#31286) 2025-07-28 15:55:44 +02:00
macos.go Adding optional parameter outfile to fleetctl package (#29579) 2025-06-12 10:25:40 -05:00
macos_notarize.go Update to latest gon with notarytool until we find a better solution (#14918) 2023-11-03 18:56:30 -05:00
macos_rcodesign.go device_token endpoint improvements (#15849) 2023-12-28 14:20:36 -06:00
macos_templates.go Enable launch daemon before trying to bootstrap it (#22764) 2024-10-23 13:54:41 -03:00
mk-ca-bundle.pl Update mk-ca-bundle.pl tool in repository (#8184) 2022-10-12 12:01:18 -03:00
packaging.go Rename flags and types for TPM work (#31176) 2025-07-23 14:30:44 -03:00
rpm.go update documentation of orbit/pkg/packaging (#6819) 2022-07-25 20:14:20 -03:00
windows.go Adding optional parameter outfile to fleetctl package (#29579) 2025-06-12 10:25:40 -05:00
windows_templates.go Orbit for Windows ARM64 (#27882) 2025-04-11 10:18:28 -04:00
windows_test.go Orbit for Windows ARM64 (#27882) 2025-04-11 10:18:28 -04:00