Skip to content

Commit

Permalink
Merge pull request #132 from IBM/pre-8.10.0
Browse files Browse the repository at this point in the history
Pre 8.10.0 Release
  • Loading branch information
No9 authored Jan 27, 2023
2 parents 1e43fef + 23a88d3 commit 5ef6c8e
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 97 deletions.
63 changes: 19 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

## How should I integrate my own uploader?

**This custom upload scenario is being replaced by the event pattern implemented in v8.9.0.**
**More documentation will follow as a client is implemented**

The core dump handler is designed to quickly move the cores *"off-box"* to an object storage environment with as much additional runtime information as possible.
In order to provide the following benefits:

Expand All @@ -27,7 +30,7 @@ In order to provide the following benefits:

- As Object Storage APIs have migrated to S3 as a defacto standard post processing services for scrubbers and indexing the data are easier to implement.

It's strongly recommened that you maintain the upload pattern of moving the cores off the machine but you may wish to move them to a none S3 compabible host.
It's strongly recommended that you maintain the upload pattern of moving the cores off the machine but you may wish to move them to a none S3 compabible host.

This scenario is possible but the following aspects need consideration:

Expand Down
23 changes: 14 additions & 9 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.9.0
version: v8.10.0

appVersion: "v8.9.0"
appVersion: "v8.10.0"

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

Expand All @@ -29,21 +29,26 @@ maintainers:

annotations:
artifacthub.io/changes: |
- kind: added
description: Experimental event file creation
- kind: fixed
description: Fix event sourcing setup in chart templates
links:
- name: GitHub PR
url: https://github.com/IBM/core-dump-handler/pull/122
url: https://github.com/IBM/core-dump-handler/pull/127
- kind: fixed
description: Scheduler crashing due to updated depenendency
description: Downgrade to 0.31.0
links:
- name: GitHub Issue
url: https://github.com/IBM/core-dump-handler/issues/120
url: https://github.com/IBM/core-dump-handler/issues/126
- name: GitHub PR
url: https://github.com/IBM/core-dump-handler/pull/128
- kind: fixed
description: Handle pullSecrets inside daemonset.yaml
links:
- name: GitHub PR
url: https://github.com/IBM/core-dump-handler/pull/121
url: https://github.com/IBM/core-dump-handler/pull/130
artifacthub.io/images: |
- name: core-dump-handler
image: quay.io/icdh/core-dump-handler:v8.9.0
image: quay.io/icdh/core-dump-handler:v8.10.0
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: agent-s3-down
tag: v8.10.0
pullPolicy: Always
pullSecrets: []
request_mem: "64Mi"
Expand Down
70 changes: 33 additions & 37 deletions core-dump-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,20 @@ async fn main() -> Result<(), anyhow::Error> {
copy_core_dump_composer_to_hostdir(host_location)?;
apply_sysctl(
"kernel.core_pattern",
format!("{}/core_pattern.bak", host_location).as_str(),
format!("{host_location}/core_pattern.bak").as_str(),
format!(
"|{}/{} -c=%c -e=%e -p=%p -s=%s -t=%t -d={} -h=%h -E=%E",
host_location, CDC_NAME, core_dir_command
)
"|{host_location}/{CDC_NAME} -c=%c -e=%e -p=%p -s=%s -t=%t -d={core_dir_command} -h=%h -E=%E")
.as_str(),
)?;
apply_sysctl(
"kernel.core_pipe_limit",
format!("{}/core_pipe_limit.bak", host_location).as_str(),
format!("{host_location}/core_pipe_limit.bak").as_str(),
"128",
)?;

apply_sysctl(
"fs.suid_dumpable",
format!("{}/suid_dumpable.bak", host_location).as_str(),
format!("{host_location}/suid_dumpable.bak").as_str(),
&suid,
)?;

Expand Down Expand Up @@ -165,12 +163,12 @@ async fn main() -> Result<(), anyhow::Error> {
let mut i_interval = match interval.parse::<u64>() {
Ok(v) => v,
Err(e) => {
error!("Error parsing interval : {} Error: {}", interval, e);
panic!("Error parsing interval {}", e);
error!("Error parsing interval : {interval} Error: {e}");
panic!("Error parsing interval {e}");
}
};
i_interval /= 1000;
schedule = format!("1/{} * * * * *", i_interval);
schedule = format!("1/{i_interval} * * * * *");
if use_inotify == "true" {
warn!("Both schedule and INotify set. Running schedule")
}
Expand All @@ -181,8 +179,8 @@ async fn main() -> Result<(), anyhow::Error> {
let sched = match JobScheduler::new().await {
Ok(v) => v,
Err(e) => {
error!("Schedule Creation Failed with {}", e);
panic!("Schedule Creation Failed with {}", e)
error!("Schedule Creation Failed with {e}");
panic!("Schedule Creation Failed with {e}")
}
};

Expand All @@ -200,23 +198,23 @@ async fn main() -> Result<(), anyhow::Error> {
}) {
Ok(v) => v,
Err(e) => {
error!("Schedule Job Creation with {} failed, {}", schedule, e);
panic!("Schedule Job Creation with {} failed, {}", schedule, e)
error!("Schedule Job Creation with {schedule} failed, {e}");
panic!("Schedule Job Creation with {schedule} failed, {e}")
}
};
info!("Created Schedule job: {:?}", s_job.guid());
match sched.add(s_job).await {
Ok(v) => v,
Err(e) => {
error!("Job Add failed {:#?}", e);
panic!("Job Scheduing failed, {:#?}", e);
error!("Job Add failed {e:#?}");
panic!("Job Scheduing failed, {e:#?}");
}
};
match sched.start().await {
Ok(v) => v,
Err(e) => {
error!("Schedule Start failed {:#?}", e);
panic!("Schedule Start failed, {:#?}", e);
error!("Schedule Start failed {e:#?}");
panic!("Schedule Start failed, {e:#?}");
}
};
loop {
Expand All @@ -230,16 +228,16 @@ async fn main() -> Result<(), anyhow::Error> {
let mut inotify = match Inotify::init() {
Ok(v) => v,
Err(e) => {
error!("Inotify init failed: {}", e);
panic!("Inotify init failed: {}", e)
error!("Inotify init failed: {e}");
panic!("Inotify init failed: {e}")
}
};
info!("INotify Initialised...");
match inotify.add_watch(&core_dir_command, WatchMask::CLOSE) {
Ok(_) => {}
Err(e) => {
error!("Add watch failed: {}", e);
panic!("Add watch failed: {}", e)
error!("Add watch failed: {e}");
panic!("Add watch failed: {e}")
}
};
info!("INotify watching : {}", core_dir_command);
Expand Down Expand Up @@ -426,7 +424,7 @@ fn generate_crio_config(host_location: &str) -> Result<(), std::io::Error> {
.unwrap_or_else(|_| "unix:///run/containerd/containerd.sock".to_string());
let destination = format!("{}/{}", host_location, "crictl.yaml");
let mut crictl_file = File::create(destination)?;
let text = format!("runtime-endpoint: {}\nimage-endpoint: {}\ntimeout: 2\ndebug: false\npull-image-on-create: false", endpoint, endpoint);
let text = format!("runtime-endpoint: {endpoint}\nimage-endpoint: {endpoint}\ntimeout: 2\ndebug: false\npull-image-on-create: false");
crictl_file.write_all(text.as_bytes())?;
crictl_file.flush()?;
Ok(())
Expand All @@ -444,14 +442,14 @@ fn copy_core_dump_composer_to_hostdir(host_location: &str) -> Result<(), std::io
let version = env::var("VENDOR").unwrap_or_else(|_| "default".to_string());
match version.to_lowercase().as_str() {
"default" => {
let location = format!("./vendor/default/{}", CDC_NAME);
let destination = format!("{}/{}", host_location, CDC_NAME);
let location = format!("./vendor/default/{CDC_NAME}");
let destination = format!("{host_location}/{CDC_NAME}");
info!("Copying the composer from {} to {}", location, destination);
fs::copy(location, destination)?;
}
"rhel7" => {
let location = format!("./vendor/rhel7/{}", CDC_NAME);
let destination = format!("{}/{}", host_location, CDC_NAME);
let location = format!("./vendor/rhel7/{CDC_NAME}");
let destination = format!("{host_location}/{CDC_NAME}");
info!("Copying the composer from {} to {}", location, destination);
fs::copy(location, destination)?;
}
Expand Down Expand Up @@ -494,9 +492,7 @@ fn create_env_file(host_location: &str) -> Result<(), std::io::Error> {
info!("Creating {} file with LOG_LEVEL={}", destination, loglevel);
let mut env_file = File::create(destination)?;
let text = format!(
"LOG_LEVEL={}\nIGNORE_CRIO={}\nCRIO_IMAGE_CMD={}\nUSE_CRIO_CONF={}\nFILENAME_TEMPLATE={}\nLOG_LENGTH={}\nPOD_SELECTOR_LABEL={}\nTIMEOUT={}\nCOMPRESSION={}\nCORE_EVENTS={}\nEVENT_DIRECTORY={}\n",
loglevel, ignore_crio, crio_image, use_crio_config, filename_template, log_length, pod_selector_label, timeout, compression, core_events, event_directory
);
"LOG_LEVEL={loglevel}\nIGNORE_CRIO={ignore_crio}\nCRIO_IMAGE_CMD={crio_image}\nUSE_CRIO_CONF={use_crio_config}\nFILENAME_TEMPLATE={filename_template}\nLOG_LENGTH={log_length}\nPOD_SELECTOR_LABEL={pod_selector_label}\nTIMEOUT={timeout}\nCOMPRESSION={compression}\nCORE_EVENTS={core_events}\nEVENT_DIRECTORY={event_directory}\n");
info!("Writing composer .env \n{}", text);
env_file.write_all(text.as_bytes())?;
env_file.flush()?;
Expand Down Expand Up @@ -537,7 +533,7 @@ fn apply_sysctl(name: &str, location: &str, value: &str) -> Result<(), anyhow::E
}

fn overwrite_sysctl(name: &str, value: &str) -> Result<(), anyhow::Error> {
let s = format!("{}={}", name, value);
let s = format!("{name}={value}");
let output = Command::new("sysctl")
.env("PATH", get_path())
.args(["-w", s.as_str()])
Expand All @@ -557,11 +553,11 @@ fn remove() -> Result<(), anyhow::Error> {
restore_sysctl("kernel", "core_pipe_limit")?;
restore_sysctl("fs", "suid_dumpable")?;
let host_dir = env::var("HOST_DIR").unwrap_or_else(|_| DEFAULT_BASE_DIR.to_string());
let exe = format!("{}/{}", host_dir, CDC_NAME);
let env_file = format!("{}/{}", host_dir, ".env");
let crictl_file = format!("{}/{}", host_dir, "crictl.yaml");
let composer_file = format!("{}/{}", host_dir, "composer.log");
let crictl_exe = format!("{}/{}", host_dir, "crictl");
let exe = format!("{host_dir}/{CDC_NAME}");
let env_file = format!("{host_dir}/.env");
let crictl_file = format!("{host_dir}/crictl.yaml");
let composer_file = format!("{host_dir}/composer.log");
let crictl_exe = format!("{host_dir}/crictl");

fs::remove_file(exe)?;
fs::remove_file(env_file)?;
Expand All @@ -581,8 +577,8 @@ fn remove() -> Result<(), anyhow::Error> {
fn restore_sysctl(prefix: &str, name: &str) -> Result<(), anyhow::Error> {
info!("Restoring Backup of {}", name);
let host_dir = env::var("HOST_DIR").unwrap_or_else(|_| DEFAULT_BASE_DIR.to_string());
let file_name = format!("{}/{}.bak", host_dir, name);
let sysctl_name = format!("{}.{}", prefix, name);
let file_name = format!("{host_dir}/{name}.bak");
let sysctl_name = format!("{prefix}.{name}");
let line = fs::read_to_string(&file_name)?;
overwrite_sysctl(sysctl_name.as_str(), line.as_str())?;
fs::remove_file(file_name)?;
Expand Down
Loading

0 comments on commit 5ef6c8e

Please sign in to comment.