Skip to content

Commit 8724e85

Browse files
authored
Merge pull request #308 from one-covenant/remove-no-ssh-flag
refactor(rental): remove no-ssh flag
2 parents fbcdecb + da9ecfb commit 8724e85

File tree

12 files changed

+42
-86
lines changed

12 files changed

+42
-86
lines changed

crates/basilica-api/src/api/routes/rentals.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,22 @@ pub async fn start_rental(
7676
// Get user ID from auth context (already extracted via Extension)
7777
let user_id = &auth_context.user_id;
7878

79-
// Look up user's registered SSH key from database (only if SSH is enabled)
80-
let ssh_public_key: String = if request.no_ssh {
81-
String::new() // Empty string for no-SSH rentals
82-
} else {
83-
let ssh_key_row = sqlx::query("SELECT public_key FROM ssh_keys WHERE user_id = $1")
84-
.bind(user_id)
85-
.fetch_optional(&state.db)
86-
.await
87-
.map_err(|e| crate::error::ApiError::Internal {
88-
message: format!("Failed to lookup SSH key: {}", e),
89-
})?;
79+
// Look up user's registered SSH key from database
80+
let ssh_key_row = sqlx::query("SELECT public_key FROM ssh_keys WHERE user_id = $1")
81+
.bind(user_id)
82+
.fetch_optional(&state.db)
83+
.await
84+
.map_err(|e| crate::error::ApiError::Internal {
85+
message: format!("Failed to lookup SSH key: {}", e),
86+
})?;
9087

91-
match ssh_key_row {
92-
Some(row) => row.get("public_key"),
93-
None => {
94-
error!("User {} has no SSH key registered", user_id);
95-
return Err(crate::error::ApiError::BadRequest {
96-
message: "No SSH key registered. Please register an SSH key first using 'basilica ssh-keys add' or by starting a rental through the CLI.".into(),
97-
});
98-
}
88+
let ssh_public_key: String = match ssh_key_row {
89+
Some(row) => row.get("public_key"),
90+
None => {
91+
error!("User {} has no SSH key registered", user_id);
92+
return Err(crate::error::ApiError::BadRequest {
93+
message: "No SSH key registered. Please register an SSH key first using 'basilica ssh-keys add' or by starting a rental through the CLI.".into(),
94+
});
9995
}
10096
};
10197

@@ -242,7 +238,6 @@ pub async fn start_rental(
242238
resources: request.resources,
243239
command: request.command,
244240
volumes: request.volumes,
245-
no_ssh: request.no_ssh,
246241
};
247242
debug!("Starting rental with request: {:?}", validator_request);
248243

crates/basilica-cli/src/cli/commands.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,6 @@ pub struct UpOptions {
365365
#[arg(long)]
366366
pub country: Option<String>,
367367

368-
/// Disable SSH access (faster startup)
369-
#[arg(long)]
370-
pub no_ssh: bool,
371-
372368
/// Create rental in detached mode (don't auto-connect via SSH)
373369
#[arg(short = 'd', long)]
374370
pub detach: bool,

crates/basilica-cli/src/cli/handlers/gpu_rental.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,6 @@ async fn handle_secure_cloud_rental_with_offering(
469469
response.rental_id
470470
));
471471

472-
// Handle SSH based on options
473-
if options.no_ssh {
474-
return Ok(());
475-
}
476-
477472
if options.detach {
478473
if let Some(ssh_cmd) = &response.ssh_command {
479474
// Look up the private key for display
@@ -627,7 +622,6 @@ async fn handle_community_cloud_rental_with_selection(
627622
},
628623
command,
629624
volumes: vec![],
630-
no_ssh: options.no_ssh,
631625
};
632626

633627
spinner.set_message("Creating rental...");
@@ -647,11 +641,6 @@ async fn handle_community_cloud_rental_with_selection(
647641
response.rental_id
648642
));
649643

650-
// Handle SSH based on options
651-
if options.no_ssh {
652-
return Ok(());
653-
}
654-
655644
let ssh_creds = match response.ssh_credentials {
656645
Some(ref creds) => creds,
657646
None => {
@@ -1757,7 +1746,7 @@ pub async fn handle_exec(
17571746
let public_key = ssh_public_key.ok_or_else(|| {
17581747
CliError::Internal(
17591748
eyre!("No SSH public key available for this rental")
1760-
.suggestion("The rental may have been created without SSH, or the required SSH key is not on this machine")
1749+
.suggestion("The required SSH key may not be on this machine")
17611750
.note("SSH access requires the original key used during rental creation"),
17621751
)
17631752
})?;
@@ -1819,7 +1808,7 @@ pub async fn handle_ssh(
18191808
let public_key = ssh_public_key.ok_or_else(|| {
18201809
CliError::Internal(
18211810
eyre!("No SSH public key available for this rental")
1822-
.suggestion("The rental may have been created without SSH, or the required SSH key is not on this machine")
1811+
.suggestion("The required SSH key may not be on this machine")
18231812
.note("SSH access requires the original key used during rental creation"),
18241813
)
18251814
})?;
@@ -1903,7 +1892,7 @@ pub async fn handle_cp(
19031892
let public_key = ssh_public_key.ok_or_else(|| {
19041893
CliError::Internal(
19051894
eyre!("No SSH public key available for this rental")
1906-
.suggestion("The rental may have been created without SSH, or the required SSH key is not on this machine")
1895+
.suggestion("The required SSH key may not be on this machine")
19071896
.note("SSH access requires the original key used during rental creation"),
19081897
)
19091898
})?;

crates/basilica-cli/src/cli/handlers/gpu_rental_helpers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,10 @@ async fn fetch_community_ssh_info(
717717
CliError::Internal(
718718
eyre!("SSH credentials not available")
719719
.wrap_err(format!(
720-
"The rental '{}' was created without SSH access",
720+
"The rental '{}' does not have SSH access",
721721
rental_id
722722
))
723-
.note("Rentals created with --no-ssh flag cannot be accessed via SSH")
724-
.note("Create a new rental without --no-ssh to enable SSH access"),
723+
.suggestion("Create a new rental to enable SSH access"),
725724
)
726725
})?;
727726

crates/basilica-sdk-python/examples/quickstart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ssh_command = format_ssh_command(rental.ssh_credentials)
2424
print(f"\nConnect with: {ssh_command}")
2525
else:
26-
print("No SSH access (no_ssh=True or not provisioned)")
26+
print("No SSH access (not yet provisioned)")
2727

2828
# When done, stop the rental
2929
# client.stop_rental(rental.rental_id)

crates/basilica-sdk-python/examples/ssh_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def print_ssh_instructions(
9595
"""
9696
if not credentials:
9797
print(f"No SSH access available for rental {rental_id}")
98-
print("(SSH was disabled with no_ssh=True or not yet provisioned)")
98+
print("(SSH not yet provisioned)")
9999
return
100100

101101
try:

crates/basilica-sdk-python/python/basilica/__init__.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@ def start_rental(
844844
environment: Optional[Dict[str, str]] = None,
845845
ports: Optional[List[Dict[str, Any]]] = None,
846846
command: Optional[List[str]] = None,
847-
no_ssh: bool = False,
848847
) -> RentalResponse:
849848
"""
850849
Start a new GPU rental.
@@ -859,7 +858,6 @@ def start_rental(
859858
environment: Environment variables
860859
ports: Port mappings
861860
command: Command to run
862-
no_ssh: Disable SSH access
863861
864862
Returns:
865863
RentalResponse with rental details
@@ -871,19 +869,18 @@ def start_rental(
871869
gpu_type = DEFAULT_GPU_TYPE
872870

873871
ssh_public_key = None
874-
if not no_ssh:
875-
if ssh_pubkey_path is not None:
876-
ssh_key_path = os.path.expanduser(ssh_pubkey_path)
877-
else:
878-
ssh_key_path = os.path.expanduser("~/.ssh/basilica_ed25519.pub")
879-
880-
if os.path.exists(ssh_key_path):
881-
with open(ssh_key_path) as f:
882-
ssh_public_key = f.read().strip()
883-
elif ssh_pubkey_path is not None:
884-
raise FileNotFoundError(
885-
f"SSH public key file not found: {ssh_key_path}"
886-
)
872+
if ssh_pubkey_path is not None:
873+
ssh_key_path = os.path.expanduser(ssh_pubkey_path)
874+
else:
875+
ssh_key_path = os.path.expanduser("~/.ssh/basilica_ed25519.pub")
876+
877+
if os.path.exists(ssh_key_path):
878+
with open(ssh_key_path) as f:
879+
ssh_public_key = f.read().strip()
880+
elif ssh_pubkey_path is not None:
881+
raise FileNotFoundError(
882+
f"SSH public key file not found: {ssh_key_path}"
883+
)
887884

888885
resources = {
889886
"gpu_count": DEFAULT_GPU_COUNT,
@@ -931,7 +928,6 @@ def start_rental(
931928
resources=resource_req,
932929
command=command if command is not None else DEFAULT_COMMAND,
933930
volumes=[],
934-
no_ssh=no_ssh,
935931
)
936932

937933
return self._client.start_rental(request)

crates/basilica-sdk-python/python/basilica/_basilica.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ class StartRentalApiRequest:
255255
def command(self) -> builtins.list[builtins.str]: ...
256256
@property
257257
def volumes(self) -> builtins.list[VolumeMountRequest]: ...
258-
@property
259-
def no_ssh(self) -> builtins.bool: ...
260258
@node_selection.setter
261259
def node_selection(self, value: NodeSelection) -> None: ...
262260
@container_image.setter
@@ -273,9 +271,7 @@ class StartRentalApiRequest:
273271
def command(self, value: builtins.list[builtins.str]) -> None: ...
274272
@volumes.setter
275273
def volumes(self, value: builtins.list[VolumeMountRequest]) -> None: ...
276-
@no_ssh.setter
277-
def no_ssh(self, value: builtins.bool) -> None: ...
278-
def __new__(cls, node_selection:NodeSelection, container_image:builtins.str, ssh_public_key:builtins.str, environment:typing.Optional[typing.Mapping[builtins.str, builtins.str]]=None, ports:typing.Optional[typing.Sequence[PortMappingRequest]]=None, resources:typing.Optional[ResourceRequirementsRequest]=None, command:typing.Optional[typing.Sequence[builtins.str]]=None, volumes:typing.Optional[typing.Sequence[VolumeMountRequest]]=None, no_ssh:builtins.bool=False) -> StartRentalApiRequest: ...
274+
def __new__(cls, node_selection:NodeSelection, container_image:builtins.str, ssh_public_key:builtins.str, environment:typing.Optional[typing.Mapping[builtins.str, builtins.str]]=None, ports:typing.Optional[typing.Sequence[PortMappingRequest]]=None, resources:typing.Optional[ResourceRequirementsRequest]=None, command:typing.Optional[typing.Sequence[builtins.str]]=None, volumes:typing.Optional[typing.Sequence[VolumeMountRequest]]=None) -> StartRentalApiRequest: ...
279275

280276
class VolumeMountRequest:
281277
r"""

crates/basilica-sdk-python/src/types.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,13 @@ pub struct StartRentalApiRequest {
494494
pub command: Vec<String>,
495495
#[pyo3(get, set)]
496496
pub volumes: Vec<VolumeMountRequest>,
497-
#[pyo3(get, set)]
498-
pub no_ssh: bool,
499497
}
500498

501499
#[cfg_attr(feature = "stub-gen", gen_stub_pymethods)]
502500
#[pymethods]
503501
impl StartRentalApiRequest {
504502
#[new]
505-
#[pyo3(signature = (node_selection, container_image, environment=None, ports=None, resources=None, command=None, volumes=None, no_ssh=false))]
503+
#[pyo3(signature = (node_selection, container_image, environment=None, ports=None, resources=None, command=None, volumes=None))]
506504
#[allow(clippy::too_many_arguments)]
507505
fn new(
508506
node_selection: NodeSelection,
@@ -512,7 +510,6 @@ impl StartRentalApiRequest {
512510
resources: Option<ResourceRequirementsRequest>,
513511
command: Option<Vec<String>>,
514512
volumes: Option<Vec<VolumeMountRequest>>,
515-
no_ssh: bool,
516513
) -> Self {
517514
Self {
518515
node_selection,
@@ -522,7 +519,6 @@ impl StartRentalApiRequest {
522519
resources: resources.unwrap_or_default(),
523520
command: command.unwrap_or_default(),
524521
volumes: volumes.unwrap_or_default(),
525-
no_ssh,
526522
}
527523
}
528524
}
@@ -537,7 +533,6 @@ impl From<StartRentalApiRequest> for SdkStartRentalApiRequest {
537533
resources: req.resources.into(),
538534
command: req.command,
539535
volumes: req.volumes.into_iter().map(Into::into).collect(),
540-
no_ssh: req.no_ssh,
541536
}
542537
}
543538
}

crates/basilica-sdk/src/types.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ pub struct StartRentalApiRequest {
184184
/// Volume mounts
185185
#[serde(default)]
186186
pub volumes: Vec<VolumeMountRequest>,
187-
188-
/// Disable SSH
189-
#[serde(default)]
190-
pub no_ssh: bool,
191187
}
192188

193189
/// Extended rental status response that includes SSH credentials from the database

0 commit comments

Comments
 (0)