Skip to content

Conversation

@kirkbrauer
Copy link
Member

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
  • LEASE_DURATION - Duration of the lease
  • EXPORTER_NAME - Name of the exporter
  • EXPORTER_NAMESPACE - Namespace of the exporter

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:
  preLease: |
    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!"
  postLease: |
    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
tls:
  ca: ''
  insecure: true
token: abc123
grpcOptions: {}
export:
  power:
    type: "jumpstarter_driver_power.driver.MockPower"
    config: {}

@netlify
Copy link

netlify bot commented Sep 5, 2025

Deploy Preview for jumpstarter-docs failed. Why did it fail? →

Name Link
🔨 Latest commit c85e583
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/69165d20956f210008c58d11

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 5, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-hooks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mangelajo
Copy link
Member

Nice!! this will be really really useful

"jumpstarter.dev/lease": context.lease_name,
},
) as session:
async with session.serve_unix_async() as unix_path:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reuse the existing session to make sure that the hooks calls on the driver altering states should persist.

@mangelajo
Copy link
Member

https://github.com/jumpstarter-dev/jumpstarter/pull/681/files#diff-33252c222f4635c1d7362569aeb3f7355a001cb7f4851ffa18313dc9088bfc56R194

This would be a hook point when the connection is ready and you can start talking to the exporter.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants