fleet/orbit/pkg/update
Dante Catalfamo 643fc8314b
Orbit config receiver (#18518)
New interface for adding periodic jobs that rely on notifications/config
changes in Orbit.

Previously if we wanted to have recurring checks in Orbit, we would add
them into a chain of `GetConfig` calls. This call chain would be run
periodically by one of the runners registered with the cli application
framework.

The new method to register `OrbitConfigReceivers` with the
`OrbitClient`, and then register the orbit client itself with the
application framework.

Instead of having giving each fetcher an internal reference to the
previous fetcher that it must call, the receiver is registered with the
client and the new config is passed to the receiver.

This is the old `GetConfig()` interface:

```go
type OrbitConfigFetcher interface {
	GetConfig() (*fleet.OrbitConfig, error)
}
```

This is the new `OrbitConfigReceiver` interface:

```go
type OrbitConfigReceiver interface {
	Run(*OrbitConfig) error
}
```

To register a new receiver, you call the `RegisterConfigReceiver` method
on the client.

```go
orbitClient.RegisterConfigReceiver(extRunner)
```

Downsides of the old method:
- Spaghetti call chain setup
- Cascading failure, of one fails, all after it fail
- Run in series,  one long function call holds up the rest
- Anything that wants to restart orbit is added as a Runner to the
application, meaning there could be several timers calling `GetConfig`
and running the chain

Benefits of the new method:
- Clean `RegisterConfigReceiver` api, no call chaining required
- Config receivers can be added at runtime
- Isolated receivers, one failing call don't effect others
- All calls are run in parallel in goroutines, no calls can hold up the
rest
- No more need for multiple runners, using a context cancel, any
receiver can queue a call to restart orbit
- Single point to handle errors and logging for all receivers
- Panic recovery to stop orbit from crashing
- Easier to test, configs are passed in and do not require a call chain

This branch contains a little bit of code from the installer method I
was working on because I branched it off of that. (oops)

Not all code comments surrounding old `GetConfig()` methods have been
fully updated yet

Possible changes:
- Update the interface to take a context, so we can let receivers know
to exit early. I can imagine two cases for this:
  - The application is about to restart
  - We can set a timeout for how long receivers are allowed to take

Closes #12662

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-05-09 15:22:56 -04:00
..
badgerstore Update go-tuf dependency (#3837) 2022-02-10 08:16:36 -08:00
filestore test: use T.TempDir to create temporary test directory (#6080) 2022-06-13 10:20:38 -03:00
config_fetcher.go Enable installation and auto-updates of Nudge via Orbit (#9605) 2023-02-10 17:03:43 -03:00
disk_encryption.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
execcmd.go Kickstart sofwareupdated periodically from fleetd/orbit to work around a macOS bug (#9465) 2023-01-24 10:14:17 -05:00
execcmd_darwin.go don't automatically kickstart softwareupdated in Orbit (#12072) 2023-06-02 12:33:40 -03:00
execcmd_stub.go don't automatically kickstart softwareupdated in Orbit (#12072) 2023-06-02 12:33:40 -03:00
execwinapi.go use OrbitNodeKey for windows mdm enrollment authentication instead of HostUUID (#13503) 2023-08-29 14:50:13 +01:00
execwinapi_stub.go Merging Bitlocker feature branch (#14350) 2023-10-06 19:04:33 -03:00
execwinapi_windows.go Merging Bitlocker feature branch (#14350) 2023-10-06 19:04:33 -03:00
file.go Add 'orbit/' from commit 'ab3047bb39f1e2be331d1ff18b4eb768619033c4' 2021-08-04 16:58:25 -03:00
flag_runner.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
flag_runner_test.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
hash.go Fix update checks for orbit at startup (#3835) 2022-02-23 14:58:07 -03:00
hash_test.go chore: remove refs to deprecated io/ioutil (#14485) 2023-10-27 15:28:54 -03:00
notifications.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
notifications_test.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
nudge.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
nudge_test.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
options.go add migration support to FD and orbit (#11741) 2023-05-18 14:21:54 -03:00
options_darwin.go fix SELinux issue (#5335) 2022-05-02 12:18:59 -06:00
options_linux.go fix SELinux issue (#5335) 2022-05-02 12:18:59 -06:00
options_windows.go Fleetctl to package .app bundles for osquery (and changes for orbit to support them) (#4393) 2022-03-15 16:04:12 -03:00
runner.go Fixing tests due to known exec after write Linux issue. (#16243) 2024-01-21 10:40:41 -06:00
runner_test.go Added orbit_version, fleet_desktop_version, and scripts_enabled to host details. (#18123) 2024-04-09 16:33:44 -05:00
swift_dialog.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
swift_dialog_test.go Orbit config receiver (#18518) 2024-05-09 15:22:56 -04:00
testing_utils.go Enable installation and auto-updates of Nudge via Orbit (#9605) 2023-02-10 17:03:43 -03:00
update.go Add backoff functionality for fleetd updates (#15489) 2023-12-08 19:43:56 -03:00
update_test.go add migration support to FD and orbit (#11741) 2023-05-18 14:21:54 -03:00