Add time check to gone resource handling

This commit is contained in:
onyinyang 2023-06-14 16:59:50 -04:00
parent d1710d2f80
commit 2e4090e21c
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
2 changed files with 20 additions and 11 deletions

View File

@ -1,3 +1,4 @@
use chrono::Utc;
use futures::future;
use futures::StreamExt;
use hyper::{
@ -199,6 +200,13 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
for pt in gone_resources {
println!("A NEW GONE RESOURCE: {:?}", pt);
for resource in pt.1 {
// 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,
// we should stop trying to remove it from the bridge table and assume it has successfully been
// removed already
if resource.last_passed < (Utc::now() - chrono::Duration::hours(3))
|| resource.last_passed > (Utc::now() - chrono::Duration::hours(7))
{
let bridgeline = parse_resource(resource);
println!("BridgeLine to be replaced: {:?}", bridgeline);
let res = context.replace_with_new(bridgeline);
@ -216,6 +224,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
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

View File

@ -1,7 +1,7 @@
use chrono::{offset::Utc, DateTime};
use serde::{Deserialize, Serialize};
use sha1::{Digest, Sha1};
use std::collections::HashMap;
use chrono::{DateTime, offset::Utc};
/// The body of the request for resources made to the rdsys backend
#[derive(Serialize)]