Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions gateway/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ fn parse_destination(sni: &str, dotted_base_domain: &str) -> Result<DstInfo> {
.strip_suffix(dotted_base_domain)
.context("invalid sni format")?;
if subdomain.contains('.') {
bail!(
"only one level of subdomain is supported: {}, {}",
sni,
subdomain
);
bail!("only one level of subdomain is supported, got sni={sni}, subdomain={subdomain}");
}
let mut parts = subdomain.split('-');
let app_id = parts.next().context("no app id found")?.to_owned();
Expand Down
6 changes: 5 additions & 1 deletion vmm/rpc/proto/vmm_rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ message Id {
string id = 1;
}

message ComposeHash {
string hash = 1;
}

// Message for creating a VM request
message VmConfiguration {
// Name of the VM
Expand Down Expand Up @@ -232,7 +236,7 @@ service Vmm {
// RPC to resize a VM
rpc ResizeVm(ResizeVmRequest) returns (google.protobuf.Empty);
// RPC to compute the compose hash, it's helpful for debugging & developing SDK.
rpc GetComposeHash(VmConfiguration) returns (AppId);
rpc GetComposeHash(VmConfiguration) returns (ComposeHash);

// RPC to list all VMs
rpc Status(StatusRequest) returns (StatusResponse);
Expand Down
16 changes: 7 additions & 9 deletions vmm/src/main_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use dstack_types::AppCompose;
use dstack_vmm_rpc as rpc;
use dstack_vmm_rpc::vmm_server::{VmmRpc, VmmServer};
use dstack_vmm_rpc::{
AppId, GatewaySettings, GetInfoResponse, GetMetaResponse, Id, ImageInfo as RpcImageInfo,
ImageListResponse, KmsSettings, ListGpusResponse, PublicKeyResponse, ResizeVmRequest,
ResourcesSettings, StatusRequest, StatusResponse, UpgradeAppRequest, VersionResponse,
VmConfiguration,
AppId, ComposeHash as RpcComposeHash, GatewaySettings, GetInfoResponse, GetMetaResponse, Id,
ImageInfo as RpcImageInfo, ImageListResponse, KmsSettings, ListGpusResponse,
PublicKeyResponse, ResizeVmRequest, ResourcesSettings, StatusRequest, StatusResponse,
UpgradeAppRequest, VersionResponse, VmConfiguration,
};
use fs_err as fs;
use ra_rpc::{CallContext, RpcCall};
Expand Down Expand Up @@ -434,15 +434,13 @@ impl VmmRpc for RpcHandler {
Ok(ListGpusResponse { gpus })
}

async fn get_compose_hash(self, request: VmConfiguration) -> Result<AppId> {
async fn get_compose_hash(self, request: VmConfiguration) -> Result<RpcComposeHash> {
validate_label(&request.name)?;
// check the compose file is valid
let _app_compose: AppCompose =
serde_json::from_str(&request.compose_file).context("Invalid compose file")?;
let app_id = app_id_of(&request.compose_file);
Ok(AppId {
app_id: app_id.into(),
})
let hash = hex_sha256(&request.compose_file);
Ok(RpcComposeHash { hash })
}
}

Expand Down