-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slurm collector crashes after switch to winter/standard time #518
Comments
This happens because a timestamp with a negative TZ is stored in the DB:
The crash is caused when reading the AUDITOR/collectors/slurm/src/database.rs Lines 83 to 104 in 4115613
Minimal working example to reproduce the crash: use chrono::{offset::Local, offset::TimeZone, NaiveDateTime};
fn main() {
let lastcheck =
NaiveDateTime::parse_from_str("2023-10-29T02:22:07-01:00", "%Y-%m-%dT%H:%M:%S%:z").unwrap();
let datetime = Local.from_local_datetime(&lastcheck).unwrap();
println!("{}", datetime);
}
Something like this: use chrono::{offset::Local, offset::TimeZone, NaiveDateTime};
fn main() {
let lastcheck =
NaiveDateTime::parse_from_str("2023-10-29T02:22:07-01:00", "%Y-%m-%dT%H:%M:%S%:z").unwrap();
let datetime = match Local.from_local_datetime(&lastcheck) {
chrono::LocalResult::None => todo!(), // probably return an error here
chrono::LocalResult::Single(datetime) => datetime,
chrono::LocalResult::Ambiguous(datetime1, datetime2) => {
println!("datetime1: {}", datetime1);
println!("datetime2: {}", datetime2);
datetime1 // not yet sure whether to pick datetime1 or datetime2
}
};
} This returns
For me, it's unclear yet whether to return the first or second timestamp in the |
Not sure if related to #249
The text was updated successfully, but these errors were encountered: