Hook Scripts

Hook scripts are scripts that are executed during the lifecycle of your croit cluster. Hook scripts can be created in Config -> Hook Scripts.

Server Hooks

Server hooks are executed on your croit cluster nodes:

  • PreNetworkConfig Called before the network configuration on a server is changed.
  • PostNetworkConfig Called after a network configuration change on a server was applied.
  • PreDaemonStart Called before the croit daemon on a server runs the initial configuration. This is a good place to install custom drivers or packages (e.g., via the /api/extra-files endpoint).
  • PostDaemonStart Called after the croit daemon finishes startup on a server.
  • PreFormatDisk Called before the croit daemon formats a disk.
  • PostFormatDisk Called after the croit daemon formats a disk.
  • PostCephDaemonStart Called after a Ceph daemon is started by the croit daemon. Does not trigger for automatic udev-based starts on startup or hot swap.
  • PostConfigChanged Called after any configuration on a server was changed.
  • OnPersistentAvailable Called after /persistent (a place to store server-specific data in CephFS) is mounted.
  • OnCephFsSnapshotComplete Called after CephFS snapshot completion. If multiple servers are selected, a server will be randomly chosen to run the hook.
  • OnRbdSnapshotComplete Called after RBD snapshot completion. If multiple servers are selected, a server will be randomly chosen to run the hook.

Management Node Hooks

Management Node hooks are executed on the croit management node:

  • OnHealthDegrade Called when a health warning appears, the count of a warning increases (ignored above 5) or the Ceph status worsens.
  • OnHealthImprove Called when a health warning disappears or the count of a warning decreases (ignored above 5).
  • OnHealthRecover Called when the Ceph status transitions back to HEALTH_OK.
  • PreCrushMapChange Called before the CRUSH map is changed by croit.
  • PostCrushMapChange Called after the CRUSH map is changed by croit.
  • OnDhcpLeaseUpdate Called when the DHCP server gives out a new lease or updates an existing lease.
  • OnAudit Called after new audit event is inserted.
  • OnCroitStartup Called after the croit app has finished starting. Some startup jobs may still be running in the background, see OnCroitAsyncStartup.
  • OnCroitAsyncStartup Called after the croit app has finished its asynchronous startup jobs. This usually happens some time after OnCroitStartup.
  • PreBackupCreate Called before a backup process begins (cloud backups, S3 backups and backups to a MON disk).
  • PostBackupSuccess Called after a backup completes successfully.
  • PostBackupFailed Called when a backup fails during creation or upload.
  • OnTaskAdvisorFindingAdded Called when a new Task Advisor finding is added.
  • OnTaskAdvisorFindingRemoved Called when an existing Task Advisor finding is removed.

Scheduled Hooks

Scheduled hooks run on a schedule instead of in response to an event:

  • CronSchedule Called on a UNIX cron schedule. Each hook chooses where it runs: on the management node, on the chosen servers, or both.

The schedule uses crontab(5) syntax (minute, hour, day of month, month, day of week) and is evaluated in the cluster's scheduling timezone, the same one snapshot schedules use. The schedule picker in Config -> Hook Scripts previews the next runs before you save.

Execution Order

When several scripts are attached to the same hook type, each hook's Priority sets the order they run in. Lower numbers run first, and a script only starts once every script with a lower number has finished, whether it succeeded or not. The default is 0, and negative numbers are allowed, so a script can run before those with the default.

The order applies within one occurrence of the event. Separate occurrences can overlap, so a script from a later occurrence may start while one from an earlier occurrence still runs. Scripts that run on servers are ordered on each server separately, so a script on one server does not wait for a lower number on another. OnRbdSnapshotComplete and OnCephFsSnapshotComplete scripts are the exception: they run one after another across the cluster, each on one server that may differ per script.

Scripts with the same priority run in no particular order and may run at the same time. If one script depends on another, give them different priorities.

A script that hangs holds back the scripts after it until it ends or reaches the one-hour limit for a hook script. OnRbdSnapshotComplete and OnCephFsSnapshotComplete scripts have no such limit, so a hung one holds back the scripts after it until it ends. Restarting croit or croitd while scripts run drops the ones that have not started yet.

CronSchedule hooks have no priority, since each schedule runs on its own.

Common Usecases