Skip to content

Commit

Permalink
Merge pull request #68 from IBM/pre-8.0.3
Browse files Browse the repository at this point in the history
fix: Modify scheduler to align better with schedule lib update
  • Loading branch information
No9 authored Feb 10, 2022
2 parents ae73574 + fd5f694 commit 5791642
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 47 deletions.
10 changes: 6 additions & 4 deletions charts/core-dump-handler/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sources:

type: application

version: v8.0.2
version: v8.0.3

appVersion: "v8.0.2"
appVersion: "v8.0.3"

icon: https://raw.githubusercontent.com/No9/core-dump-handler/master/assets/handle-with-care-svgrepo-com.svg

Expand All @@ -33,10 +33,12 @@ annotations:
description: Fix template quote
links:
- name: Github PR
url: https://github.com/IBM/core-dump-handler/pull/67
url: https://github.com/IBM/core-dump-handler/pull/68
- name: Github Issue
url: https://github.com/IBM/core-dump-handler/issues/65
artifacthub.io/images: |
- name: core-dump-handler
image: quay.io/repository/icdh/core-dump-handler:v8.0.2
image: quay.io/repository/icdh/core-dump-handler:v8.0.3
artifacthub.io/license: MIT
artifacthub.io/signKey: |
fingerprint: BED079E67FD431E45301B1C9949E671B46AC8A34
Expand Down
2 changes: 1 addition & 1 deletion charts/core-dump-handler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ replicaCount: 1
image:
registry: quay.io
repository: icdh/core-dump-handler
tag: v8.0.2
tag: v8.0.3
pullPolicy: Always
pullSecrets: []
request_mem: "64Mi"
Expand Down
2 changes: 1 addition & 1 deletion core-dump-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-dump-agent"
version = "8.0.0"
version = "8.0.3"
authors = ["Anthony Whalley <anton@venshare.com>"]
edition = "2021"

Expand Down
72 changes: 31 additions & 41 deletions core-dump-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate s3;
use advisory_lock::{AdvisoryFileLock, FileLockMode};
use env_logger::Env;
use inotify::{EventMask, Inotify, WatchMask};
use log::{debug, error, info, warn};
use log::{error, info, warn};
use s3::bucket::Bucket;
use s3::creds::Credentials;
use s3::region::Region;
Expand Down Expand Up @@ -164,7 +164,7 @@ async fn main() -> Result<(), anyhow::Error> {
interval, schedule, interval
);
}
// Overwriting the schedule string if interval present

if !interval.is_empty() {
let mut i_interval = match interval.parse::<u64>() {
Ok(v) => v,
Expand All @@ -179,49 +179,39 @@ async fn main() -> Result<(), anyhow::Error> {
warn!("Both schedule and INotify set. Running schedule")
}
}
//Need to clone here before it gets borrowed

let notify_location = core_location.clone();
let schedule_task;
if !schedule.is_empty() {
info!("Schedule is Starting...");
schedule_task = tokio::spawn(async move {
info!("Schedule Initialising with: {}", schedule);
let mut sched = JobScheduler::new();
let s_job = match Job::new(schedule.as_str(), move |_uuid, _l| {
let handle = Handle::current();
let core_str = core_location.clone();
handle.spawn(async move {
run_polling_agent(&core_str).await;
});
}) {
Ok(v) => v,
Err(e) => {
error!("Schedule Job Creation with {} failed, {}", schedule, e);
panic!("Schedule Job Creation with {} failed, {}", schedule, e)
}
};
info!("Created Schedule job: {:?}", s_job.guid());
match sched.add(s_job) {
Ok(v) => v,
Err(e) => {
error!("Job Add failed {:#?}", e);
panic!("Job Scheduing failed, {:#?}", e)
}
info!("Schedule Initialising with: {}", schedule);
let mut sched = JobScheduler::new();
let s_job = match Job::new(schedule.as_str(), move |_uuid, _l| {
let handle = Handle::current();
let core_str = core_location.clone();
handle.spawn(async move {
run_polling_agent(&core_str).await;
});
}) {
Ok(v) => v,
Err(e) => {
error!("Schedule Job Creation with {} failed, {}", schedule, e);
panic!("Schedule Job Creation with {} failed, {}", schedule, e)
}
info!("Added Job to Schedule");
loop {
match sched.tick() {
Ok(_) => {
debug!("Executed tick");
}
Err(e) => {
error!("Job Tick failed {:#?}", e);
}
};
std::thread::sleep(Duration::from_millis(500));
};
info!("Created Schedule job: {:?}", s_job.guid());
match sched.add(s_job) {
Ok(v) => v,
Err(e) => {
error!("Job Add failed {:#?}", e);
panic!("Job Scheduing failed, {:#?}", e)
}
});
schedule_task.await?;
}
match sched.start().await {
Ok(v) => v,
Err(e) => {
error!("Schedule Start failed {:#?}", e);
panic!("Schedule Start failed, {:#?}", e)
}
};
}

if use_inotify == "true" {
Expand Down

0 comments on commit 5791642

Please sign in to comment.