Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions packages/jumpstarter-cli-client/jumpstarter_cli_client/lease.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncclick as click
from jumpstarter.common import MetadataFilter
from jumpstarter.config import (
ClientConfigV1Alpha1,
UserConfigV1Alpha1,
Expand Down Expand Up @@ -45,3 +46,42 @@ def lease_release(name, lease, all_leases):
if not lease:
raise ValueError("no lease specified")
config.release_lease(lease)

@lease.command("request")
@click.option("-l", "--label", "labels", type=(str, str), multiple=True)
@click.argument("name", type=str, default="")
def lease_request(name, labels):
"""Request an exporter lease from the jumpstarter controller.

The result of this command will be a lease ID that can be used to
connect to the remote exporter.

This is useful for multi-step workflows where you want to hold a lease
for a specific exporter while performing multiple operations, or for
CI environments where one step will request the lease and other steps
will perform operations on the leased exporter.

Example:

.. code-block:: bash

$ JMP_LEASE=$(jmp lease request -l label match)
$ jmp shell
$$ j --help
$$ exit
$ jmp lease release -l "${JMP_LEASE}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect flag in example.

The example uses -l flag for release command but the actual flag is --lease.

-    $ jmp lease release -l "${JMP_LEASE}"
+    $ jmp lease release --lease "${JMP_LEASE}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$ jmp lease release -l "${JMP_LEASE}"
$ jmp lease release --lease "${JMP_LEASE}"


"""
try:
if name:
config = ClientConfigV1Alpha1.load(name)
else:
config = UserConfigV1Alpha1.load_or_create().config.current_client
if not config:
raise ValueError("No client specified")
lease = config.request_lease(metadata_filter=MetadataFilter(labels=dict(labels)))
print(lease.name)
except ValueError as e:
raise click.ClickException(str(e)) from e
except Exception as e:
raise e
Comment on lines +86 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve exception handling.

The bare raise e is not a good practice as it loses the traceback information. Consider either letting the exception propagate naturally by removing the general exception handler or wrapping it in a click exception for consistent error handling.

-    except Exception as e:
-        raise e
+    except Exception as e:
+        raise click.ClickException(f"Unexpected error: {str(e)}") from e
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
except Exception as e:
raise e
except Exception as e:
raise click.ClickException(f"Unexpected error: {str(e)}") from e