Skip to content

Commit

Permalink
Update workspace dependencies
Browse files Browse the repository at this point in the history
* Do not bump foreign-types-shared crate due to incompatibility with openssl crate

Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
  • Loading branch information
FlorentinDUBOIS committed Jul 13, 2022
1 parent 7276e17 commit 1b3cd3c
Show file tree
Hide file tree
Showing 32 changed files with 686 additions and 617 deletions.
699 changes: 410 additions & 289 deletions Cargo.lock

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license = "AGPL-3.0"
authors = ["Geoffroy Couprie <geo.couprie@gmail.com>"]
categories = ["network-programming"]
edition="2018"

include = [
"README.md",
"Cargo.toml",
Expand All @@ -21,39 +20,37 @@ include = [
name = "sozu"

[dependencies]
anyhow = "1.0.42"
mio = { version = "^0.8", features = [ "os-poll", "net" ] }
serde = "~1.0.2"
serde_json = "~1.0.1"
serde_derive = "~1.0.2"
nom = "7.0.0"
nix = "^0.23"
time = "^0.3"
clap = "^2.19.0"
slab = "^0.4.0"
libc = "^0.2"
rand = "^0.8"
tempfile = "^3.0"
futures = "^0.3"
lazy_static = "^1.1"
regex = "1.0"
jemallocator = {version = "^0.3", optional = true }
smol = "^1"
async-io = "^1"
async-dup = "1.2"
futures-lite = "^1"
log = "^0.4"
hex = "^0.4"
structopt = "^0.3"
structopt-derive = "^0.4"
prettytable-rs = { version = "^0.8", default-features = false}
termion = "1.5"
anyhow = "^1.0.56"
async-dup = "^1.2.2"
async-io = "^1.6.0"
clap = "^2.34.0"
futures = "^0.3.21"
futures-lite = "^1.12.0"
hex = "^0.4.3"
jemallocator = { version = "^0.3.2", optional = true }
lazy_static = "^1.4.0"
libc = "^0.2.124"
log = "^0.4.16"
mio = { version = "^0.8.2", features = [ "os-poll", "net" ] }
nix = "^0.23.1"
nom = "^7.1.1"
prettytable-rs = { version = "^0.8.0", default-features = false }
serde = { version = "^1.0.136", features = ["derive"] }
serde_json = "^1.0.79"
structopt = "^0.3.26"
time = "^0.3.9"
rand = "^0.8.5"
regex = "^1.5.5"
slab = "^0.4.6"
smol = "^1.2.5"
tempfile = "^3.3.0"
termion = "^1.5.6"

sozu-lib = { version = "^0.13.0", path = "../lib" }
sozu-command-lib = { version = "^0.13.0", path = "../command" }
sozu-command-lib = { path = "../command" }
sozu-lib = { path = "../lib" }

[target.'cfg(target_os="linux")'.dependencies]
num_cpus = "^1.3.0"
num_cpus = "^1.13.1"

[features]
default = [ "jemallocator" ]
Expand Down
1 change: 1 addition & 0 deletions bin/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::net::SocketAddr;

use sozu_command_lib::proxy::{LoadBalancingAlgorithms, TlsVersion};
use structopt::StructOpt;

#[derive(StructOpt, PartialEq, Debug)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
Expand Down
1 change: 1 addition & 0 deletions bin/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use nix::{
sys::signal::{kill, Signal},
unistd::Pid,
};
use serde::{Deserialize, Serialize};
use serde_json;

use sozu_command_lib::{
Expand Down
2 changes: 1 addition & 1 deletion bin/src/command/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ impl CommandServer {

pub async fn upgrade_main(
&mut self,
request_identifier: RequestIdentifier,
_request_identifier: RequestIdentifier,
) -> anyhow::Result<Option<Success>> {
self.disable_cloexec_before_upgrade()?;

Expand Down
2 changes: 1 addition & 1 deletion bin/src/ctl/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
use anyhow::{self, bail, Context};
use prettytable::Table;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use serde::Serialize;

use sozu_command_lib::{
command::{
Expand All @@ -34,7 +35,6 @@ use crate::{
},
};


// Used to display the JSON response of the status command
#[derive(Serialize, Debug)]
struct WorkerStatus<'a> {
Expand Down
128 changes: 61 additions & 67 deletions bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
process::exit,
};

use anyhow::{self, bail, Context};
use anyhow::{self, Context};
use prettytable::{Row, Table};

use sozu_command_lib::{
Expand Down Expand Up @@ -270,27 +270,26 @@ pub fn print_query_response_data(
data: Option<CommandResponseData>,
json: bool,
) -> anyhow::Result<()> {
if let Some(needle) = application_id.or(domain) {
if let Some(CommandResponseData::Query(data)) = data {
if let Some(needle) = application_id.or_else(|| domain) {
if let Some(CommandResponseData::Query(data)) = &data {
if json {
return print_json_response(&data);
return print_json_response(data);
}

let application_headers = vec!["id", "sticky_session", "https_redirect"];
let mut application_table =
create_queried_application_table(application_headers, &data);
let mut application_table = create_queried_application_table(application_headers, data);

let http_headers = vec!["id", "hostname", "path"];
let mut frontend_table = create_queried_application_table(http_headers, &data);
let mut frontend_table = create_queried_application_table(http_headers, data);

let https_headers = vec!["id", "hostname", "path"];
let mut https_frontend_table = create_queried_application_table(https_headers, &data);
let mut https_frontend_table = create_queried_application_table(https_headers, data);

let tcp_headers = vec!["id", "address"];
let mut tcp_frontend_table = create_queried_application_table(tcp_headers, &data);
let mut tcp_frontend_table = create_queried_application_table(tcp_headers, data);

let backend_headers = vec!["backend id", "IP address", "Backup"];
let mut backend_table = create_queried_application_table(backend_headers, &data);
let mut backend_table = create_queried_application_table(backend_headers, data);

let keys: HashSet<&String> = data.keys().collect();

Expand All @@ -300,61 +299,61 @@ pub fn print_query_response_data(
let mut tcp_frontend_data = HashMap::new();
let mut backend_data = HashMap::new();

for (ref key, ref metrics) in data.iter() {
for (key, metrics) in data.iter() {
//let m: u8 = metrics;
if let &QueryAnswer::Applications(ref apps) = *metrics {
if let QueryAnswer::Applications(apps) = metrics {
for app in apps.iter() {
let entry = application_data.entry(app).or_insert(Vec::new());
entry.push((*key).clone());
entry.push(key.to_owned());

for frontend in app.http_frontends.iter() {
let entry = frontend_data.entry(frontend).or_insert(Vec::new());
entry.push((*key).clone());
entry.push(key.to_owned());
}

for frontend in app.https_frontends.iter() {
let entry = https_frontend_data.entry(frontend).or_insert(Vec::new());
entry.push((*key).clone());
entry.push(key.to_owned());
}

for frontend in app.tcp_frontends.iter() {
let entry = tcp_frontend_data.entry(frontend).or_insert(Vec::new());
entry.push((*key).clone());
entry.push(key.to_owned());
}

for backend in app.backends.iter() {
let entry = backend_data.entry(backend).or_insert(Vec::new());
entry.push((*key).clone());
entry.push(key.to_owned());
}
}
}
}

println!("Cluster level configuration for {}:\n", needle);

for (ref key, ref values) in application_data.iter() {
for (key, values) in application_data.iter() {
let mut row = Vec::new();
row.push(cell!(key
.configuration
.clone()
.map(|conf| conf.cluster_id)
.unwrap_or(String::from(""))));
.as_ref()
.map(|conf| conf.cluster_id.to_owned())
.unwrap_or_else(String::new)));
row.push(cell!(key
.configuration
.clone()
.as_ref()
.map(|conf| conf.sticky_session)
.unwrap_or(false)));
.unwrap_or_else(|| false)));
row.push(cell!(key
.configuration
.clone()
.as_ref()
.map(|conf| conf.https_redirect)
.unwrap_or(false)));
.unwrap_or_else(|| false)));

for val in values.iter() {
for val in values {
if keys.contains(val) {
row.push(cell!(String::from("X")));
row.push(cell!("X"));
} else {
row.push(cell!(String::from("")));
row.push(cell!(""));
}
}

Expand All @@ -365,7 +364,7 @@ pub fn print_query_response_data(

println!("\nHTTP frontends configuration for {}:\n", needle);

for (ref key, ref values) in frontend_data.iter() {
for (key, values) in frontend_data.iter() {
let mut row = Vec::new();
match &key.route {
Route::ClusterId(cluster_id) => row.push(cell!(cluster_id)),
Expand All @@ -376,9 +375,9 @@ pub fn print_query_response_data(

for val in values.iter() {
if keys.contains(val) {
row.push(cell!(String::from("X")));
row.push(cell!("X"));
} else {
row.push(cell!(String::from("")));
row.push(cell!(""));
}
}

Expand All @@ -389,7 +388,7 @@ pub fn print_query_response_data(

println!("\nHTTPS frontends configuration for {}:\n", needle);

for (ref key, ref values) in https_frontend_data.iter() {
for (key, values) in https_frontend_data.iter() {
let mut row = Vec::new();
match &key.route {
Route::ClusterId(cluster_id) => row.push(cell!(cluster_id)),
Expand All @@ -400,9 +399,9 @@ pub fn print_query_response_data(

for val in values.iter() {
if keys.contains(val) {
row.push(cell!(String::from("X")));
row.push(cell!("X"));
} else {
row.push(cell!(String::from("")));
row.push(cell!(""));
}
}

Expand All @@ -413,10 +412,8 @@ pub fn print_query_response_data(

println!("\nTCP frontends configuration for {}:\n", needle);

for (ref key, ref values) in tcp_frontend_data.iter() {
let mut row = Vec::new();
row.push(cell!(key.cluster_id));
row.push(cell!(format!("{}", key.address)));
for (key, values) in tcp_frontend_data.iter() {
let mut row = vec![cell!(key.cluster_id), cell!(format!("{}", key.address))];

for val in values.iter() {
if keys.contains(val) {
Expand All @@ -433,18 +430,21 @@ pub fn print_query_response_data(

println!("\nbackends configuration for {}:\n", needle);

for (ref key, ref values) in backend_data.iter() {
let mut row = Vec::new();
let backend_backup = key.backup.map(|b| if b { "X" } else { "" }).unwrap_or("");
row.push(cell!(key.backend_id));
row.push(cell!(format!("{}", key.address)));
row.push(cell!(backend_backup));

for val in values.iter() {
if keys.contains(val) {
row.push(cell!(String::from("X")));
for (key, values) in backend_data.iter() {
let mut row = vec![
cell!(key.backend_id),
cell!(format!("{}", key.address)),
cell!(key
.backup
.map(|b| if b { "X" } else { "" })
.unwrap_or_else(|| "")),
];

for val in values {
if keys.contains(&val) {
row.push(cell!("X"));
} else {
row.push(cell!(String::from("")));
row.push(cell!(""));
}
}

Expand All @@ -454,43 +454,37 @@ pub fn print_query_response_data(
backend_table.printstd();
}
} else {
if let Some(CommandResponseData::Query(data)) = data {
if let Some(CommandResponseData::Query(data)) = &data {
let mut table = Table::new();
let mut header = Vec::new();
header.push(cell!("key"));
for ref key in data.keys() {
let mut header = vec![cell!("key")];
for key in data.keys() {
header.push(cell!(&key));
}
header.push(cell!("desynchronized"));
table.add_row(Row::new(header));

let mut query_data = HashMap::new();

for ref metrics in data.values() {
for metrics in data.values() {
//let m: u8 = metrics;
if let &QueryAnswer::ApplicationsHashes(ref apps) = *metrics {
for (ref key, ref value) in apps.iter() {
(*(query_data.entry((*key).clone()).or_insert(Vec::new()))).push(*value);
if let QueryAnswer::ApplicationsHashes(apps) = metrics {
for (key, value) in apps.iter() {
query_data.entry(key).or_insert(Vec::new()).push(value);
}
}
}

for (ref key, ref values) in query_data.iter() {
let mut row = Vec::new();
row.push(cell!(key));

for (key, values) in query_data.iter() {
let mut row = vec![cell!(key)];
for val in values.iter() {
row.push(cell!(format!("{}", val)));
}

let hs: HashSet<&u64> = values.iter().cloned().collect();

let diff = hs.len() > 1;

if diff {
row.push(cell!(String::from("X")));
if hs.len() > 1 {
row.push(cell!("X"));
} else {
row.push(cell!(String::from("")));
row.push(cell!(""));
}

table.add_row(Row::new(row));
Expand Down

0 comments on commit 1b3cd3c

Please sign in to comment.