-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Jumpstarter PR #606 adds new before/after lease hooks, but the client experience is poor due to lack of visibility into hook execution.
Current Issues
-
Poor User Experience: When a client connects to an exporter running beforeLease hooks, the exporter appears to "freeze" - clients can connect but all driver calls are blocked by the
_before_lease_readyEvent until the before lease hook is complete. -
No Progress Indication: Users have no way to know that hooks are running, how long they might take, or what's happening during execution.
-
Confusing Availability: During after lease hook execution, the exporter appears unavailable for new leases, which can confuse users.
-
No Monitoring: Users cannot monitor after lease hook execution after releasing a lease from the CLI.
Current Implementation
- Exporters use an async Event to block all driver calls until the hook is complete
- Hook execution happens silently with only internal logging to the exporter console
- Clients have no indication that hooks are running or their progress
- The
jCLI provides no feedback during hook execution
Proposed Solution
1. Protocol Changes
Add Exporter Status Enum to client.proto
message Exporter {
// ... existing fields ...
optional ExporterStatus status = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}
enum ExporterStatus {
EXPORTER_STATUS_UNSPECIFIED = 0;
EXPORTER_STATUS_AVAILABLE = 1; // No lease, ready for connections
EXPORTER_STATUS_BEFORE_LEASE_HOOK = 2; // Running beforeLease hooks
EXPORTER_STATUS_LEASED = 3; // Leased and ready for commands
EXPORTER_STATUS_AFTER_LEASE_HOOK = 4; // Running afterLease hooks
}Add Log Source to jumpstarter.proto
message LogStreamResponse {
string uuid = 1;
string severity = 2;
string message = 3;
optional LogSource source = 4; // New optional field
}
enum LogSource {
LOG_SOURCE_UNSPECIFIED = 0;
LOG_SOURCE_EXPORTER = 1; // System/exporter logs
LOG_SOURCE_DRIVER = 2; // Driver/device logs
LOG_SOURCE_HOOK = 3; // Hook execution logs
LOG_SOURCE_MESSAGE = 4; // Message (reserved for future MOTD use)
}2. Implementation Changes
Exporter Updates
- Track current status using
ExporterStatusenum - Report status through existing
GetReportandStatusRPCs - Stream hook logs through
LogStreamwith appropriateLogSource - Continue blocking driver calls for existing clients, new clients can see status
Hook Executor Updates
- Send hook output to
LogStreamwith correctLogSourcefield - Maintain existing execution logic
- Add progress indication in log messages
Client Updates
- Check exporter status when connecting
- Display appropriate waiting messages based on status
- Subscribe to
LogStreamand filter by source for hook progress - Allow optional monitoring of after lease hooks (
Ctrl+Cends lease, but waits)
3. User Experience Improvements
Before
$ j shell -l device=rpi4
Connecting to exporter...
[Connection appears to hang with no feedback]
After
$ j shell -l device=rpi4
Connecting to exporter...
Waiting for beforeLease hooks to complete...
[Hook INFO] Powering on device...
[Hook INFO] Initializing network interface...
[Hook INFO] Configuring storage...
beforeLease hooks completed successfully!
Connected to device.
[User works with device...]
Releasing lease...
afterLease hooks running (press Ctrl+C to disconnect):
[Hook Output] Saving logs to archive...
[Hook Output] Cleaning up workspace...
afterLease hooks completed.
Hooks Example
Hooks will be able to log messages by adding the JMP_INFO, JMP_WARN, or JMP_ERROR prefix to log messages.
Example hook shell script:
echo "JMP_INFO: This is informational"
echo "JMP_ERROR: This is an error message"
echo "JMP_WARN: This is a warning"
echo "If the type is not specified, it will be an info-level message"Example client CLI output:
$ j shell -l device=rpi4
Connecting to exporter...
Waiting for beforeLease hooks to complete...
[Hook INFO] This is informational
[Hook ERROR] This is an error message
[Hook WARN] This is a warning
[Hook INFO] If the type is not specified, it will be an info-level message'
beforeLease hooks completed successfully!
Connected to device.
4. Backward Compatibility
- All new protocol fields are
optional - Existing clients continue to work without changes (calls are blocked)
- Graceful degradation for clients that don't understand new status
- No breaking changes to existing APIs
Implementation Plan
Phase 1: Protocol Updates
- Add enums to
client.protoandjumpstarter.protoin thejumpstarter-protocol. - Regenerate protobuf code and migrate existing client/exporter
- Update exporter to track and report status
Phase 2: Hook Integration (#606)
- Modify hook executor to use LogStream
- Update exporter status transitions
- Test status reporting
Phase 3: Client Updates
- Update
jCLI to check and display status - Add LogStream filtering by source
- Implement progress indication
Phase 4: Documentation
- Update user documentation
- Add examples of hook status handling
- Update API documentation
Metadata
Metadata
Assignees
Labels
Type
Projects
Status