Skip to content

Commit a6d4fe2

Browse files
committed
imp: code review feedback.
1 parent d294ad2 commit a6d4fe2

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

gateway/src/proxy.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ fn parse_destination(sni: &str, dotted_base_domain: &str) -> Result<DstInfo> {
7373
.strip_suffix(dotted_base_domain)
7474
.context("invalid sni format")?;
7575
if subdomain.contains('.') {
76-
bail!(
77-
"only one level of subdomain is supported: {}, {}",
78-
sni,
79-
subdomain
80-
);
76+
bail!("only one level of subdomain is supported, got sni={sni}, subdomain={subdomain}");
8177
}
8278
let mut parts = subdomain.split('-');
8379
let app_id = parts.next().context("no app id found")?.to_owned();

vmm/rpc/proto/vmm_rpc.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ message Id {
3838
string id = 1;
3939
}
4040

41+
message ComposeHash {
42+
string hash = 1;
43+
}
44+
4145
// Message for creating a VM request
4246
message VmConfiguration {
4347
// Name of the VM
@@ -232,7 +236,7 @@ service Vmm {
232236
// RPC to resize a VM
233237
rpc ResizeVm(ResizeVmRequest) returns (google.protobuf.Empty);
234238
// RPC to compute the compose hash, it's helpful for debugging & developing SDK.
235-
rpc GetComposeHash(VmConfiguration) returns (AppId);
239+
rpc GetComposeHash(VmConfiguration) returns (ComposeHash);
236240

237241
// RPC to list all VMs
238242
rpc Status(StatusRequest) returns (StatusResponse);

vmm/src/main_service.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use dstack_types::AppCompose;
66
use dstack_vmm_rpc as rpc;
77
use dstack_vmm_rpc::vmm_server::{VmmRpc, VmmServer};
88
use dstack_vmm_rpc::{
9-
AppId, GatewaySettings, GetInfoResponse, GetMetaResponse, Id, ImageInfo as RpcImageInfo,
10-
ImageListResponse, KmsSettings, ListGpusResponse, PublicKeyResponse, ResizeVmRequest,
11-
ResourcesSettings, StatusRequest, StatusResponse, UpgradeAppRequest, VersionResponse,
12-
VmConfiguration,
9+
AppId, ComposeHash as RpcComposeHash, GatewaySettings, GetInfoResponse, GetMetaResponse, Id,
10+
ImageInfo as RpcImageInfo, ImageListResponse, KmsSettings, ListGpusResponse,
11+
PublicKeyResponse, ResizeVmRequest, ResourcesSettings, StatusRequest, StatusResponse,
12+
UpgradeAppRequest, VersionResponse, VmConfiguration,
1313
};
1414
use fs_err as fs;
1515
use ra_rpc::{CallContext, RpcCall};
@@ -434,15 +434,13 @@ impl VmmRpc for RpcHandler {
434434
Ok(ListGpusResponse { gpus })
435435
}
436436

437-
async fn get_compose_hash(self, request: VmConfiguration) -> Result<AppId> {
437+
async fn get_compose_hash(self, request: VmConfiguration) -> Result<RpcComposeHash> {
438438
validate_label(&request.name)?;
439439
// check the compose file is valid
440440
let _app_compose: AppCompose =
441441
serde_json::from_str(&request.compose_file).context("Invalid compose file")?;
442-
let app_id = app_id_of(&request.compose_file);
443-
Ok(AppId {
444-
app_id: app_id.into(),
445-
})
442+
let hash = hex_sha256(&request.compose_file);
443+
Ok(RpcComposeHash { hash })
446444
}
447445
}
448446

0 commit comments

Comments
 (0)