Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Add pre/post lease hooks#606

Open
kirkbrauer wants to merge 24 commits intomainfrom
add-hooks
Open

Add pre/post lease hooks#606
kirkbrauer wants to merge 24 commits intomainfrom
add-hooks

Conversation

@kirkbrauer
Copy link
Copy Markdown
Member

@kirkbrauer kirkbrauer commented Sep 5, 2025

Implement new hook scripts that can be configured in the exporter config to run j commands within a temporary lease environment.

The following environment variables are exposed to hook scripts:

  • JUMPSTARTER_HOST - Path to the Unix socket for j CLI access
  • JMP_DRIVERS_ALLOW=UNSAFE - Allows all drivers for local access
  • LEASE_NAME - The name of the current lease
  • CLIENT_NAME - Name of the client that acquired the lease

Example YAML config:

apiVersion: jumpstarter.dev/v1alpha1
kind: ExporterConfig
metadata:
  namespace: default
  name: test-exporter
endpoint: grpc.jumpstarter.100.123.60.47.nip.io:8082
hooks:
  beforeLease:
    script: |
      echo "Starting lease setup for ${CLIENT_NAME}"
      echo "Setting up power management..."
      j power on
      echo "Initializing device connections..."
      echo "Running pre-lease diagnostics..."
      sleep 5
      echo "Pre-lease setup completed successfully!"
    timeout: 120
    onFailure: exit
  afterLease:
    script: |
      echo "Starting lease cleanup for ${CLIENT_NAME}"
      echo "Shutting down power..."
      j power off
      echo "Cleaning up device connections..."
      echo "Running post-lease diagnostics..."
      sleep 5
      echo "Post-lease cleanup completed successfully!"
    timeout: 60
    onFailure: warn
tls:
  ca: ''
  insecure: true
token: abc123
grpcOptions: {}
export:
  power:
    type: "jumpstarter_driver_power.driver.MockPower"
    config: {}

Summary by CodeRabbit

  • New Features
    • Exporter status now exposed (STATUS column, CLI "status" option), status streaming, EndSession support, and before/after lease hook lifecycle with timeouts and failure modes; exporter exit codes influence run outcomes.
  • Tests
    • Added/updated tests covering hooks, status reporting, rendering, readiness gating, and logging.
  • Chores
    • Added typed protobuf/grpc stubs and new public enums/type aliases for exporter status and log sources.

✏️ Tip: You can customize this high-level summary in your review settings.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants