From 7b5d2649cdcf45a0002e2988008037556cd1f194 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Thu, 8 Feb 2024 11:33:33 -0300 Subject: [PATCH] Fix format --- node/tools/src/bin/deployer.rs | 7 ++- node/tools/src/k8s.rs | 84 +++++++++++++++++----------------- node/tools/src/main.rs | 13 ++---- 3 files changed, 53 insertions(+), 51 deletions(-) diff --git a/node/tools/src/bin/deployer.rs b/node/tools/src/bin/deployer.rs index 4a28fbb7..5d5056fe 100644 --- a/node/tools/src/bin/deployer.rs +++ b/node/tools/src/bin/deployer.rs @@ -106,7 +106,12 @@ async fn deploy(nodes: usize) -> anyhow::Result<()> { NAMESPACE, ) .await?; - k8s::create_or_reuse_service(&client, &format!("consensus-node-{i:0>2}"), &format!("consensus-node-{i:0>2}")).await?; + k8s::create_or_reuse_service( + &client, + &format!("consensus-node-{i:0>2}"), + &format!("consensus-node-{i:0>2}"), + ) + .await?; } // // Waiting 15 secs to allow the pods to start diff --git a/node/tools/src/k8s.rs b/node/tools/src/k8s.rs index af789fd6..92e810f5 100644 --- a/node/tools/src/k8s.rs +++ b/node/tools/src/k8s.rs @@ -11,10 +11,6 @@ use serde_json::json; use std::collections::HashMap; use tracing::log::info; use zksync_protobuf::serde::Serde; -use kube::{ - api::{DeleteParams}, - runtime::wait::{await_condition, conditions::is_pod_running}, -}; /// Get a kube client pub async fn get_client() -> anyhow::Result { @@ -53,48 +49,52 @@ pub async fn create_or_reuse_namespace(client: &Client, name: &str) -> anyhow::R } /// Creates a namespace in k8s cluster -pub async fn create_or_reuse_service(client: &Client, name: &str, node_name: &str) -> anyhow::Result<()> { - let services: Api = Api::namespaced(client.clone(), "consensus"); - let example_service = services.get_opt(name).await?; - if example_service.is_none() { - let service: Service = serde_json::from_value(json!({ - "apiVersion": "v1", - "kind": "Service", - "metadata": { - "name": name, - "namespace": "consensus", - "labels": { - "app": node_name - } - }, - "spec": { - "type": "NodePort", - "ports": [ - { - "port": 80, - "targetPort": 3154, - "protocol": "TCP", +pub async fn create_or_reuse_service( + client: &Client, + name: &str, + node_name: &str, +) -> anyhow::Result<()> { + let services: Api = Api::namespaced(client.clone(), "consensus"); + let example_service = services.get_opt(name).await?; + if example_service.is_none() { + let service: Service = serde_json::from_value(json!({ + "apiVersion": "v1", + "kind": "Service", + "metadata": { + "name": name, + "namespace": "consensus", + "labels": { + "app": node_name } - ], - "selector": { - "app": node_name }, - } - }))?; + "spec": { + "type": "NodePort", + "ports": [ + { + "port": 80, + "targetPort": 3154, + "protocol": "TCP", + } + ], + "selector": { + "app": node_name + }, + } + }))?; - let services: Api = Api::namespaced(client.clone(), "consensus"); - let post_params = PostParams::default(); - let result = services.create(&post_params, &service).await?; + let services: Api = Api::namespaced(client.clone(), "consensus"); + let post_params = PostParams::default(); + let result = services.create(&post_params, &service).await?; - info!("Service: {} ,created", result.metadata.name.unwrap()); - Ok(()) - } else { - info!( - "Service: {} ,already exists", - example_service.unwrap().metadata.name.unwrap() - ); - Ok(()) - } + info!("Service: {} ,created", result.metadata.name.unwrap()); + Ok(()) + } else { + info!( + "Service: {} ,already exists", + example_service.unwrap().metadata.name.unwrap() + ); + Ok(()) + } } pub async fn create_deployment( diff --git a/node/tools/src/main.rs b/node/tools/src/main.rs index f6efb5f9..ff71e855 100644 --- a/node/tools/src/main.rs +++ b/node/tools/src/main.rs @@ -103,15 +103,12 @@ async fn main() -> anyhow::Result<()> { .context("config_paths().load()")?; // Add gossipStaticOutbound pairs from cli to config - if let Some(go) = args.add_gossip_static_outbound { - configs.app.gossip_static_outbound.extend( - go - .0 - .into_iter() - .map(|e| (e.0.key, e.0.addr)), - ); + if let Some(outbound) = args.add_gossip_static_outbound { + configs + .app + .gossip_static_outbound + .extend(outbound.0.into_iter().map(|e| (e.0.key, e.0.addr))); } - let (executor, runner) = configs .make_executor(ctx)