Update lox distributor to use most recent rdsys_backend
The structure of the ResourceDiff has been changed, so the lox distributor has to modify how it parses the diff.
This commit is contained in:
parent
aa785419d8
commit
7a24fdfa06
|
@ -1397,7 +1397,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rdsys_backend"
|
name = "rdsys_backend"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -26,7 +26,7 @@ zkp = "0.8.0"
|
||||||
|
|
||||||
lox-library = { path = "../lox-library", version = "0.1.0"}
|
lox-library = { path = "../lox-library", version = "0.1.0"}
|
||||||
lox_utils = { path = "../lox-utils", version = "0.1.0"}
|
lox_utils = { path = "../lox-utils", version = "0.1.0"}
|
||||||
rdsys_backend = { path = "../rdsys-backend-api", version = "0.1.0"}
|
rdsys_backend = { path = "../rdsys-backend-api", version = "0.2"}
|
||||||
|
|
||||||
[dependencies.chrono]
|
[dependencies.chrono]
|
||||||
version = "0.4.19"
|
version = "0.4.19"
|
||||||
|
|
|
@ -129,7 +129,8 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
let mut bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
|
let mut bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
|
||||||
for pt in new_resources {
|
for pt in new_resources {
|
||||||
println!("A NEW RESOURCE: {:?}", pt);
|
println!("A NEW RESOURCE: {:?}", pt);
|
||||||
for resource in pt.1 {
|
if let Some(resources) = pt.1 {
|
||||||
|
for resource in resources {
|
||||||
let bridgeline = parse_resource(resource);
|
let bridgeline = parse_resource(resource);
|
||||||
println!("Now it's a bridgeline: {:?}", bridgeline);
|
println!("Now it's a bridgeline: {:?}", bridgeline);
|
||||||
if context.unreplaced_bridges.lock().unwrap().len() > 0 {
|
if context.unreplaced_bridges.lock().unwrap().len() > 0 {
|
||||||
|
@ -141,9 +142,15 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
bridgeline
|
bridgeline
|
||||||
);
|
);
|
||||||
} else if res == lox_library::ReplaceSuccess::Replaced {
|
} else if res == lox_library::ReplaceSuccess::Replaced {
|
||||||
println!("BridgeLine successfully replaced: {:?}", bridgeline);
|
println!(
|
||||||
|
"BridgeLine successfully replaced: {:?}",
|
||||||
|
bridgeline
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
assert!(res == lox_library::ReplaceSuccess::NotReplaced, "ReplaceSuccess incorrectly set somehow");
|
assert!(
|
||||||
|
res == lox_library::ReplaceSuccess::NotReplaced,
|
||||||
|
"ReplaceSuccess incorrectly set somehow"
|
||||||
|
);
|
||||||
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
||||||
// again to replace at the next update (nothing changes in the Lox Authority)
|
// again to replace at the next update (nothing changes in the Lox Authority)
|
||||||
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
||||||
|
@ -161,6 +168,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Handle the extra buckets that were not allocated already
|
// Handle the extra buckets that were not allocated already
|
||||||
if count != 0 {
|
if count != 0 {
|
||||||
for val in 0..count {
|
for val in 0..count {
|
||||||
|
@ -178,7 +186,8 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
if let Some(changed_resources) = resourcediff.changed {
|
if let Some(changed_resources) = resourcediff.changed {
|
||||||
for pt in changed_resources {
|
for pt in changed_resources {
|
||||||
println!("A NEW CHANGED RESOURCE: {:?}", pt);
|
println!("A NEW CHANGED RESOURCE: {:?}", pt);
|
||||||
for resource in pt.1 {
|
if let Some(resources) = pt.1 {
|
||||||
|
for resource in resources {
|
||||||
let bridgeline = parse_resource(resource);
|
let bridgeline = parse_resource(resource);
|
||||||
println!("BridgeLine to be changed: {:?}", bridgeline);
|
println!("BridgeLine to be changed: {:?}", bridgeline);
|
||||||
let res = context.update_bridge(bridgeline);
|
let res = context.update_bridge(bridgeline);
|
||||||
|
@ -196,6 +205,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// gone resources are not the same as blocked resources.
|
// gone resources are not the same as blocked resources.
|
||||||
// Instead, these are bridges which have either failed to pass tests for some period
|
// Instead, these are bridges which have either failed to pass tests for some period
|
||||||
// or have expired bridge descriptors. In both cases, the bridge is unusable, but this
|
// or have expired bridge descriptors. In both cases, the bridge is unusable, but this
|
||||||
|
@ -205,19 +215,24 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
if let Some(gone_resources) = resourcediff.gone {
|
if let Some(gone_resources) = resourcediff.gone {
|
||||||
for pt in gone_resources {
|
for pt in gone_resources {
|
||||||
println!("A NEW GONE RESOURCE: {:?}", pt);
|
println!("A NEW GONE RESOURCE: {:?}", pt);
|
||||||
for resource in pt.1 {
|
if let Some(resources) = pt.1 {
|
||||||
|
for resource in resources {
|
||||||
// If resource last passed tests 3 hours ago, it should be replaced with a working
|
// If resource last passed tests 3 hours ago, it should be replaced with a working
|
||||||
// resource and be removed from the bridgetable. If it has been gone for more than 7 hours,
|
// resource and be removed from the bridgetable. If it has been gone for more than 7 hours,
|
||||||
// we should stop trying to remove it from the bridge table and assume it has successfully been
|
// we should stop trying to remove it from the bridge table and assume it has successfully been
|
||||||
// removed already
|
// removed already
|
||||||
if resource.last_passed < (Utc::now() - chrono::Duration::hours(3))
|
if resource.last_passed < (Utc::now() - chrono::Duration::hours(3))
|
||||||
|| resource.last_passed > (Utc::now() - chrono::Duration::hours(7))
|
|| resource.last_passed
|
||||||
|
> (Utc::now() - chrono::Duration::hours(7))
|
||||||
{
|
{
|
||||||
let bridgeline = parse_resource(resource);
|
let bridgeline = parse_resource(resource);
|
||||||
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
println!("BridgeLine to be replaced: {:?}", bridgeline);
|
||||||
let res = context.replace_with_new(bridgeline);
|
let res = context.replace_with_new(bridgeline);
|
||||||
if res == lox_library::ReplaceSuccess::Replaced {
|
if res == lox_library::ReplaceSuccess::Replaced {
|
||||||
println!("BridgeLine successfully replaced: {:?}", bridgeline);
|
println!(
|
||||||
|
"BridgeLine successfully replaced: {:?}",
|
||||||
|
bridgeline
|
||||||
|
);
|
||||||
} else if res == lox_library::ReplaceSuccess::NotReplaced {
|
} else if res == lox_library::ReplaceSuccess::NotReplaced {
|
||||||
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
// Add the bridge to the list of unreplaced bridges in the Lox context and try
|
||||||
// again to replace at the next update (nothing changes in the Lox Authority)
|
// again to replace at the next update (nothing changes in the Lox Authority)
|
||||||
|
@ -231,6 +246,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Functionality for marking bridges as unreachable/blocked is currently not enabled as there is not
|
/* Functionality for marking bridges as unreachable/blocked is currently not enabled as there is not
|
||||||
yet a reliable way to determine that a bridge is blocked. This means that migrations to unblocked bridges do not
|
yet a reliable way to determine that a bridge is blocked. This means that migrations to unblocked bridges do not
|
||||||
currently work but can be easily enabled with a list of `blocked resources` from rdsys or another source with something
|
currently work but can be easily enabled with a list of `blocked resources` from rdsys or another source with something
|
||||||
|
|
|
@ -252,7 +252,10 @@ mod tests {
|
||||||
self.context.advance_days_test(days)
|
self.context.advance_days_test(days)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simulate_blocking(&mut self, cred: lox_library::cred::Lox) -> (lox_library::cred::Lox, u32, [u8; 16]) {
|
fn simulate_blocking(
|
||||||
|
&mut self,
|
||||||
|
cred: lox_library::cred::Lox,
|
||||||
|
) -> (lox_library::cred::Lox, u32, [u8; 16]) {
|
||||||
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
|
||||||
let mut bdb = self.context.db.lock().unwrap();
|
let mut bdb = self.context.db.lock().unwrap();
|
||||||
let mut lox_auth = self.context.ba.lock().unwrap();
|
let mut lox_auth = self.context.ba.lock().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue