-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Problem
Currently, Exporters are entirely stateless with the process restarting every time the lease ends and new driver instances being created for each client that connects. While this provides a lot of advantages for configuration and testing, the hardware attached to the Exporter is not always stateless.
Therefore, setup and teardown jobs may be needed before and after the lease to ensure that the hardware is always in a "known" state prior to the next lease. Currently, cleanup jobs can be implemented using a custom implementation of the close() driver method. While this works well for custom drivers or common logic, different hardware setups demand different setup/teardown logic.
Feature Proposal
- Add a new
hookssection to the ExporterConfig object to enable pre and post lease lifecycle hooks to be registered. - Supported hooks:
beforeLease: Runs after the lease is acquired, but before the client can interact with the exporter.afterLease: Runs after the lease is released, but before the exporter becomes available to lease again.
- Hooks run in a transient shell session enabling scripts to use the
jCLI andenv()function in Python scripts. - Logs for hooks are written to the audit log (can potentially be returned to the client?)
Example configuration:
hooks:
beforeLease:
script: | # Supports multi-line scripts
j power on
echo "Powered on device"
timeout: 10s # Timeout for command to succeed/fail (default 60s)
exitCode: 0 # Only accept a 0 exit code (default: -1, all exit codes)
onFailure: deny # End lease if this command fails (allow/deny/warn) (default: allow)
afterLease:
script: j power offReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
In review