Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Ziy1-Tan <[email protected]>
  • Loading branch information
Ziy1-Tan committed Sep 16, 2024
1 parent 08cfdc8 commit 7171a71
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 24 deletions.
2 changes: 2 additions & 0 deletions update_vmm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cp -f bin/vmm-task /usr/bin/vmm-task
cp -f bin/vmm-sandboxer /usr/bin/vmm-sandboxer
2 changes: 1 addition & 1 deletion vmm/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ opentelemetry-otlp = "0.13.0"

[build-dependencies]
ttrpc-codegen = { git = "https://github.com/kuasar-io/ttrpc-rust.git", branch = "v0.7.1-kuasar" }
tonic-build = "0.7.2"
tonic-build = "0.7.2"
3 changes: 1 addition & 2 deletions vmm/common/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use opentelemetry::sdk::trace::Tracer;
use opentelemetry::sdk::{trace, Resource};
use opentelemetry::sdk::{trace, trace::Tracer, Resource};
use tracing_subscriber::EnvFilter;

pub fn init_otlp_tracer(otlp_service_name: &str) -> anyhow::Result<Tracer> {
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/config_clh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ path = "/usr/local/bin/virtiofsd"
log_level = "info"
cache = "never"
thread_pool_size = 4
syslog = true
syslog = true
8 changes: 1 addition & 7 deletions vmm/sandbox/src/bin/cloud_hypervisor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
use clap::Parser;
use opentelemetry::global;
use tracing::{info, info_span};
use tracing_subscriber::Layer;
use tracing_subscriber::{layer::SubscriberExt, Registry};
use tracing_subscriber::{layer::SubscriberExt, Layer, Registry};
use vmm_common::tracer::{init_logger_filter, init_otlp_tracer};
use vmm_sandboxer::{
args,
Expand Down Expand Up @@ -46,7 +45,6 @@ async fn main() {
if config.sandbox.enable_tracing {
let tracer = init_otlp_tracer("kuasar-vmm-sandboxer-clh-tracing-service")
.expect("failed to init otlp tracer");

layers.push(tracing_opentelemetry::layer().with_tracer(tracer).boxed());
}

Expand All @@ -65,8 +63,6 @@ async fn main() {
// Do recovery job
sandboxer.recover(&args.dir).await;

info!("Kuasar vmm sandboxer clh is started");

// Run the sandboxer
containerd_sandbox::run(
"kuasar-vmm-sandboxer-clh",
Expand All @@ -77,8 +73,6 @@ async fn main() {
.await
.unwrap();

info!("Kuasar vmm sandboxer clh is exited");

root_span.exit();
global::shutdown_tracer_provider();
}
3 changes: 1 addition & 2 deletions vmm/sandbox/src/bin/qemu/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
use clap::Parser;
use opentelemetry::global;
use tracing::{info, info_span};
use tracing_subscriber::Layer;
use tracing_subscriber::{layer::SubscriberExt, Registry};
use tracing_subscriber::{layer::SubscriberExt, Layer, Registry};
use vmm_common::tracer::{init_logger_filter, init_otlp_tracer};
use vmm_sandboxer::{
args,
Expand Down
3 changes: 1 addition & 2 deletions vmm/sandbox/src/bin/stratovirt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
use clap::Parser;
use opentelemetry::global;
use tracing::{info, info_span};
use tracing_subscriber::{layer::SubscriberExt, Registry};
use tracing_subscriber::Layer;
use tracing_subscriber::{layer::SubscriberExt, Layer, Registry};
use vmm_common::tracer::{init_logger_filter, init_otlp_tracer};
use vmm_sandboxer::{
args,
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ use tokio::{
net::UnixStream,
time::timeout,
};
use tracing::{debug, error};
use ttrpc::{
context::with_timeout,
r#async::{Client, TtrpcContext},
};
use tracing::{debug, error};
use vmm_common::api::{
sandbox::{CheckRequest, SetupSandboxRequest, SyncClockPacket},
sandbox_ttrpc::SandboxServiceClient,
Expand Down
18 changes: 11 additions & 7 deletions vmm/task/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.

use std::{collections::HashMap, convert::TryFrom, path::Path, process::exit, sync::Arc};

use anyhow::anyhow;
use containerd_shim::{
asynchronous::{monitor::monitor_notify_by_pid, util::asyncify},
error::Error,
Expand Down Expand Up @@ -177,18 +178,22 @@ async fn initialize() -> anyhow::Result<()> {

fn init_logger(log_level: &str, enable_tracing: bool) -> anyhow::Result<()> {
let env_filter = EnvFilter::from_default_env()
.add_directive(format!("containerd_shim={:?}", log_level).parse()?)
.add_directive(format!("vmm_task={:?}", log_level).parse()?);
.add_directive(format!("containerd_shim={}", log_level).parse()?)
.add_directive(format!("vmm_task={}", log_level).parse()?);

let mut layers = vec![tracing_subscriber::fmt::layer().boxed()];
if enable_tracing {
let tracer = init_otlp_tracer("kuasar-vmm-task-otlp-service")?;
let tracer = init_otlp_tracer("kuasar-vmm-task-tracing-service")?;
layers.push(tracing_opentelemetry::layer().with_tracer(tracer).boxed());
}

let subscriber = Registry::default().with(env_filter).with(layers);
tracing::subscriber::set_global_default(subscriber).expect("unable to set global subscriber");

match tracing::subscriber::set_global_default(subscriber) {
Ok(_) => {}
Err(e) => {
return Err(anyhow!("failed to set global default subscriber: {}", e));
}
}
Ok(())
}

Expand All @@ -198,6 +203,7 @@ async fn main() {
error!("failed to do init call: {:?}", e);
exit(-1);
}
let root_span = info_span!("kuasar-vmm-task-root").entered();

// Keep server alive in main function
let mut server = match create_ttrpc_server().await {
Expand All @@ -212,8 +218,6 @@ async fn main() {
exit(-1);
}

let root_span = info_span!("kuasar-vmm-task-root").entered();

let signals = match Signals::new([libc::SIGTERM, libc::SIGINT, libc::SIGPIPE, libc::SIGCHLD]) {
Ok(s) => s,
Err(e) => {
Expand Down
1 change: 0 additions & 1 deletion vmm/task/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use nix::{
};
use tokio::fs::File;
use tracing::{debug, warn};

use vmm_common::{
mount::{mount, unmount},
storage::{Storage, DRIVERBLKTYPE, DRIVEREPHEMERALTYPE, DRIVERSCSITYPE},
Expand Down

0 comments on commit 7171a71

Please sign in to comment.