Skip to content
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

Add support for gathering proc files necessary to convert coredump to minidump #157

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions charts/core-dump-handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ The agent pod has the following environment variables and these are all set by t
false (Default): The composer will generate the additional JSON files.

true: The composer will only collect the core dump and save the core parameters as an additional JSON
* COMP_INCLUDE_PROC_INFO - Defines if the composer should get additional proc files from the container process. *Warning:* These files can contain sensitive information regarding the process, use with caution

false (Default): The composer will not collect any pid related files

true: The composer will copy 'auxv', 'cmdline', 'environ', 'maps' and 'status' for every container into the zip
* COMP_CRIO_IMAGE_CMD - The command to use to get image information for the core dump.

"img" (Default): This is the value most crictls expect.
Expand Down Expand Up @@ -272,6 +277,7 @@ Image
Composer
* logLevel: The log level for the composer (Default "Warn")
* ignoreCrio: Maps to the COMP_IGNORE_CRIO enviroment variable (Default false)
* includeProcInfo: Maps to the COMP_INCLUDE_PROC_INFO enviroment variable (Default false)
* crioImageCmd: Maps to the COMP_CRIO_IMAGE_CMD enviroment variable (Default "img")
* timeout: Maps to the COMP_TIMEOUT environment variable ("Default 600)
* compression: Maps to the COMP_COMPRESSION environment variable (Default "true")
Expand Down
1 change: 1 addition & 0 deletions charts/core-dump-handler/ci/inotify-manage-store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ storageClass: hostclass

composer:
ignoreCrio: false
includeProcInfo: false
crioImageCmd: "img"
logLevel: "Warn"
# Double curlies are required otherwise helm trys to parse the string
Expand Down
1 change: 1 addition & 0 deletions charts/core-dump-handler/ci/interval-manage-store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ storageClass: hostclass

composer:
ignoreCrio: false
includeProcInfo: false
crioImageCmd: "img"
logLevel: "Warn"
# Double curlies are required otherwise helm trys to parse the string
Expand Down
1 change: 1 addition & 0 deletions charts/core-dump-handler/ci/schedule-no-manage-store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ storageClass: hostclass

composer:
ignoreCrio: false
includeProcInfo: false
crioImageCmd: "img"
logLevel: "Warn"
# Double curlies are required otherwise helm trys to parse the string
Expand Down
2 changes: 2 additions & 0 deletions charts/core-dump-handler/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ spec:
value: {{ .Values.composer.logLevel }}
- name: COMP_IGNORE_CRIO
value: {{ .Values.composer.ignoreCrio | quote }}
- name: COMP_INCLUDE_PROC_INFO
value: {{ .Values.composer.includeProcInfo | quote }}
- name: COMP_CRIO_IMAGE_CMD
value: {{ .Values.composer.crioImageCmd }}
- name: COMP_POD_SELECTOR_LABEL
Expand Down
4 changes: 4 additions & 0 deletions charts/core-dump-handler/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
"ignoreCrio": {
"type": "boolean"
},
"includeProcInfo": {
"type": "boolean"
},
"crioImageCmd": {
"type": "string"
},
Expand All @@ -130,6 +133,7 @@
"required": [
"crioImageCmd",
"ignoreCrio",
"includeProcInfo",
"logLevel",
"logLength",
"filenameTemplate",
Expand Down
1 change: 1 addition & 0 deletions charts/core-dump-handler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ storageClass: hostclass

composer:
ignoreCrio: false
includeProcInfo: false
crioImageCmd: "img"
logLevel: "Warn"
filenameTemplate: "{uuid}-dump-{timestamp}-{hostname}-{exe_name}-{pid}-{signal}"
Expand Down
3 changes: 3 additions & 0 deletions core-dump-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ features = ["tokio-rustls-tls"]
[target.x86_64-unknown-linux-gnu.dependencies.rust-s3]
version = "0.31.0"

[target.aarch64-unknown-linux-gnu.dependencies.rust-s3]
version = "0.31.0"

[dev-dependencies]
fs_extra = "1.2"
5 changes: 4 additions & 1 deletion core-dump-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ fn create_env_file(host_location: &str) -> Result<(), std::io::Error> {
let ignore_crio = env::var("COMP_IGNORE_CRIO")
.unwrap_or_else(|_| "false".to_string())
.to_lowercase();
let include_proc_info = env::var("COMP_INCLUDE_PROC_INFO")
.unwrap_or_else(|_| "false".to_string())
.to_lowercase();
let crio_image = env::var("COMP_CRIO_IMAGE_CMD").unwrap_or_else(|_| "img".to_string());
let destination = format!("{}/{}", host_location, ".env");
let use_crio_config = env::var("DEPLOY_CRIO_CONFIG")
Expand All @@ -492,7 +495,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={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");
"LOG_LEVEL={loglevel}\nIGNORE_CRIO={ignore_crio}\nINCLUDE_PROC_INFO={include_proc_info}\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
3 changes: 2 additions & 1 deletion core-dump-agent/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn basic() -> Result<(), std::io::Error> {
let env_content = fs::read_to_string(&env_file).unwrap();
assert!(env_content.contains("LOG_LEVEL=debug"));
assert!(env_content.contains("IGNORE_CRIO=false"));
assert!(env_content.contains("INCLUDE_PROC_INFO=false"));
assert!(env_content.contains("CRIO_IMAGE_CMD=img"));
assert!(env_content.contains("USE_CRIO_CONF=false"));
assert!(env_content.contains(
Expand All @@ -97,7 +98,7 @@ fn basic() -> Result<(), std::io::Error> {
assert!(env_content.contains("LOG_LENGTH=500"));
assert!(env_content.contains("EVENTS=false"));
assert!(env_content.contains("EVENT_DIRECTORY=/"));
assert_eq!(env_content.lines().count(), 11);
assert_eq!(env_content.lines().count(), 12);
//TODO: [No9] Test uploading of a corefile
//TODO: [No9] Test remove option
//TODO: [No9] Test sweep option
Expand Down
2 changes: 1 addition & 1 deletion core-dump-composer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ anyhow = "1.0.53"
serde_json = "1.0.76"
serde = { version = "1.0.134", features = ["derive"] }
hostname = "0.3.1"
libcrio = "2.0.0"
libcrio = "2.1.0"
tinytemplate = "1.2.1"

[dev-dependencies]
Expand Down
Loading
Loading