Add time check to gone resource handling
This commit is contained in:
parent
d1710d2f80
commit
2e4090e21c
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in New Issue