Skip to content

Commit

Permalink
bug: associate deployment id with logs
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Nov 7, 2022
1 parent eded53c commit 70815d6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions deployer/src/deployment/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,15 @@ async fn run(
info!("failed to load service: {}", e);
}

let start_request = tonic::Request::new(StartRequest { service_name });
let start_request = tonic::Request::new(StartRequest {
deployment_id: id.as_bytes().to_vec(),
service_name,
});

info!("starting service");
let response = runtime_client.start(start_request).await.unwrap();

info!(response = ?response, "client response: ");
info!(response = ?response.into_inner(), "client response: ");
}

#[cfg(test)]
Expand Down
4 changes: 3 additions & 1 deletion proto/runtime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ message LoadResponse {
}

message StartRequest {
// Id to associate with the deployment being started
bytes deployment_id = 1;
// Name of service to start
string service_name = 1;
string service_name = 2;
}

message StartResponse {
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tokio-stream = "0.1.11"
tonic = "0.8.2"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
uuid = { version = "1.1.2", features = ["v4"] }
wasi-common = "2.0.0"
wasmtime = "2.0.0"
wasmtime-wasi = "2.0.0"
Expand Down
7 changes: 5 additions & 2 deletions runtime/src/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
use tokio_stream::wrappers::ReceiverStream;
use tonic::{transport::Endpoint, Request, Response, Status};
use tracing::{info, instrument, trace};
use uuid::Uuid;

use crate::provisioner_factory::{AbstractFactory, AbstractProvisionerFactory};

Expand Down Expand Up @@ -72,18 +73,20 @@ impl Runtime for Legacy {
let service_port = 7001;
let service_address = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), service_port);

let request = request.into_inner();

let provisioner_client = ProvisionerClient::connect(self.provisioner_address.clone())
.await
.expect("failed to connect to provisioner");
let abstract_factory = AbstractProvisionerFactory::new(provisioner_client);

let service_name = ServiceName::from_str(request.into_inner().service_name.as_str())
let service_name = ServiceName::from_str(request.service_name.as_str())
.map_err(|err| Status::from_error(Box::new(err)))?;

let mut factory = abstract_factory.get_factory(service_name);

let logs_tx = self.logs_tx.lock().unwrap().clone();
let logger = Logger::new(logs_tx, Default::default());
let logger = Logger::new(logs_tx, Uuid::from_slice(&request.deployment_id).unwrap());

let so_path = self
.so_path
Expand Down

0 comments on commit 70815d6

Please sign in to comment.