From 722322bb3716685ab95c02656cb4f9b90b4a4458 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 20 Oct 2023 13:38:25 +0200 Subject: [PATCH 01/13] WIP --- src/product_logging/framework.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index d7ae6db0c..b98c0d70b 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1085,6 +1085,15 @@ pub fn vector_container( .command(vec!["bash".into(), "-c".into()]) .args(vec![format!( "\ +# The vector process will not run as PID 1, so the Kubernetes SIGINT will have no effect. +# Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, +# e.g.{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. +# This way logs from the products will always be shipped, the vector container will be the last one to terminate. +# A specific container must be chosen, which has the responsibility to create a file after it has +# properly shut down. It should be the one taking the longest to shut down. +# E.g. the lifetime of vector will be bound to the datanode container and not to the zkfc container. +# We *could* have different shutdown trigger files for all application containers and wait for all containers +# to terminate, but that seems rather complicated and will be added once needed. vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} & vector_pid=$! && \ if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then \ mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && \ From 91e07606f116cd004d47fa73a20f26d8cb2e2d4c Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 20 Oct 2023 15:19:08 +0200 Subject: [PATCH 02/13] WIP --- src/product_logging/framework.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index b98c0d70b..75e3c5d52 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1085,7 +1085,7 @@ pub fn vector_container( .command(vec!["bash".into(), "-c".into()]) .args(vec![format!( "\ -# The vector process will not run as PID 1, so the Kubernetes SIGINT will have no effect. +# The vector process wil not run as PID 1, so a Kubernetes SIGINT will be have no effect. # Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, # e.g.{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. # This way logs from the products will always be shipped, the vector container will be the last one to terminate. @@ -1140,6 +1140,10 @@ touch {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}" ) } +pub fn remove_vector_shutdown_file_command(stackable_log_dir: &str) -> String { + format!("rm -f {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}") +} + #[cfg(test)] mod tests { use super::*; From f3e340508ae9e11515a43d3edab265ccd82dca40 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 23 Oct 2023 13:49:12 +0200 Subject: [PATCH 03/13] WIP --- src/product_logging/framework.rs | 42 +++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index d7ae6db0c..9ad98d45f 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1082,15 +1082,32 @@ pub fn vector_container( ContainerBuilder::new("vector") .unwrap() .image_from_product_image(image) - .command(vec!["bash".into(), "-c".into()]) + .command(vec![ + "/bin/bash".to_string(), + "-x".to_string(), + "-euo".to_string(), + "pipefail".to_string(), + "-c".to_string(), + ]) .args(vec![format!( "\ -vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} & vector_pid=$! && \ -if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then \ -mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && \ -inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; \ -fi && \ -kill $vector_pid" +# The vector process wil not run as PID 1, so a Kubernetes SIGINT will be have no effect. +# Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, +# e.g.{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. +# This way logs from the products will always be shipped, the vector container will be the last one to terminate. +# A specific container must be chosen, which has the responsibility to create a file after it has +# properly shut down. It should be the one taking the longest to shut down. +# E.g. the lifetime of vector will be bound to the datanode container and not to the zkfc container. +# We *could* have different shutdown trigger files for all application containers and wait for all containers +# to terminate, but that seems rather complicated and will be added once needed. +# Additionally, you should remove the shutdown marker file on startup of the application, as the application +# container can crash for any reason and get restarted. If you don't remove the shutdown file on startup, +# the vector container will crashloop forever! + +bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & + +exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} +" )]) .add_env_var("VECTOR_LOG", log_level.to_vector_literal()) .add_volume_mount(config_volume_name, STACKABLE_CONFIG_DIR) @@ -1099,7 +1116,8 @@ kill $vector_pid" .build() } -/// Command to shut down the Vector instance +/// Command to create a shutdown file for the vector container. +/// Please delete it before starting your application using [`remove_vector_shutdown_file_command`]. /// /// # Example /// @@ -1124,13 +1142,19 @@ kill $vector_pid" /// .add_volume_mount("log", STACKABLE_LOG_DIR) /// .build(); /// ``` -pub fn shutdown_vector_command(stackable_log_dir: &str) -> String { +pub fn create_vector_shutdown_file_command(stackable_log_dir: &str) -> String { format!( "mkdir -p {stackable_log_dir}/{VECTOR_LOG_DIR} && \ touch {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}" ) } +/// Use this command to remove the shutdown file (if it exists) created by [`create_vector_shutdown_file_command`]. +/// You should execute this command before starting your application. +pub fn remove_vector_shutdown_file_command(stackable_log_dir: &str) -> String { + format!("rm -f {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}") +} + #[cfg(test)] mod tests { use super::*; From bdfa4e90e9e9de7577c2553ef9e1495b0421b135 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 27 Oct 2023 14:29:53 +0200 Subject: [PATCH 04/13] fixup --- src/product_logging/framework.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index 36528e47e..641c314c0 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1100,23 +1100,13 @@ pub fn vector_container( # E.g. the lifetime of vector will be bound to the datanode container and not to the zkfc container. # We *could* have different shutdown trigger files for all application containers and wait for all containers # to terminate, but that seems rather complicated and will be added once needed. -<<<<<<< HEAD # Additionally, you should remove the shutdown marker file on startup of the application, as the application # container can crash for any reason and get restarted. If you don't remove the shutdown file on startup, # the vector container will crashloop forever! bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & -exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} -" -======= -vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} & vector_pid=$! && \ -if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then \ -mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && \ -inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; \ -fi && \ -kill $vector_pid" ->>>>>>> refs/remotes/origin/docs/vector-process +exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE}" )]) .add_env_var("VECTOR_LOG", log_level.to_vector_literal()) .add_volume_mount(config_volume_name, STACKABLE_CONFIG_DIR) @@ -1158,11 +1148,8 @@ touch {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}" ) } -<<<<<<< HEAD /// Use this command to remove the shutdown file (if it exists) created by [`create_vector_shutdown_file_command`]. /// You should execute this command before starting your application. -======= ->>>>>>> refs/remotes/origin/docs/vector-process pub fn remove_vector_shutdown_file_command(stackable_log_dir: &str) -> String { format!("rm -f {stackable_log_dir}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}") } From 9c01cbf88e15719641456c46d82e9ff59ea27a44 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 27 Oct 2023 14:46:37 +0200 Subject: [PATCH 05/13] switch back to ignoring sigterm --- src/product_logging/framework.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index 641c314c0..5681c6cce 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1091,22 +1091,31 @@ pub fn vector_container( ]) .args(vec![format!( "\ -# The vector process wil not run as PID 1, so a Kubernetes SIGINT will be have no effect. +# The vector process is not running as PID 1, so a Kubernetes SIGTERM will be have no effect. # Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, -# e.g.{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. -# This way logs from the products will always be shipped, the vector container will be the last one to terminate. +# e.g. {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. +# This way logs from the products will always be shipped, as the vector container will be the last one to terminate. # A specific container must be chosen, which has the responsibility to create a file after it has # properly shut down. It should be the one taking the longest to shut down. -# E.g. the lifetime of vector will be bound to the datanode container and not to the zkfc container. +# E.g. for hdfs the lifetime of vector will be bound to the datanode container and not to the zkfc container. # We *could* have different shutdown trigger files for all application containers and wait for all containers # to terminate, but that seems rather complicated and will be added once needed. # Additionally, you should remove the shutdown marker file on startup of the application, as the application # container can crash for any reason and get restarted. If you don't remove the shutdown file on startup, -# the vector container will crashloop forever! - -bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & - -exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE}" +# the vector container will crashloop forever as it will start and shut down immediately after! + +# ALTERNATIVE, which can get SIGTERM terminated as well as via writing a file (?) +# bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & +# exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} + +vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} & vector_pid=$! +if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then + mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && \ + inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; \ +fi +sleep 1 +kill $vector_pid +" )]) .add_env_var("VECTOR_LOG", log_level.to_vector_literal()) .add_volume_mount(config_volume_name, STACKABLE_CONFIG_DIR) From c0a32f15f2ad33b8fa7d9ccbddcba670d71277f9 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 27 Oct 2023 14:51:49 +0200 Subject: [PATCH 06/13] Add COMMON_BASH_TRAP_FUNCTIONS --- src/utils.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index a41a61f2b..c916a589d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,36 @@ use tracing::info; +pub const COMMON_BASH_TRAP_FUNCTIONS: &str = r#" +prepare_signal_handlers() +{ + unset term_child_pid + unset term_kill_needed + trap 'handle_term' TERM +} + +handle_term() +{ + if [ "${term_child_pid}" ]; then + kill -TERM "${term_child_pid}" 2>/dev/null + else + term_kill_needed="yes" + fi +} + +wait_for_termination() +{ + set +e + term_child_pid=$! + if [[ -v term_kill_needed ]]; then + kill -TERM "${term_child_pid}" 2>/dev/null + fi + wait ${term_child_pid} 2>/dev/null + trap - TERM + wait ${term_child_pid} 2>/dev/null + set -e +} +"#; + /// Prints helpful and standardized diagnostic messages. /// /// This method is meant to be called first thing in the `main` method of an Operator. From 23a4ac041085a43c17e7f18cc755928b64a91b4d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 27 Oct 2023 15:36:33 +0200 Subject: [PATCH 07/13] fix: test --- src/product_logging/framework.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index 5681c6cce..5fdc3d36d 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1138,8 +1138,9 @@ kill $vector_pid /// const STACKABLE_LOG_DIR: &str = "/stackable/log"; /// /// let args = vec![ -/// "echo Perform initialization tasks ...".into(), -/// product_logging::framework::shutdown_vector_command(STACKABLE_LOG_DIR), +/// product_logging::framework::remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), +/// "echo Perform some tasks ...".into(), +/// product_logging::framework::create_vector_shutdown_file_command(STACKABLE_LOG_DIR), /// ]; /// /// let container = ContainerBuilder::new("init") From 1d463ff810a48aa0e03692dc5e7aa719919c0d87 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 08:03:19 +0100 Subject: [PATCH 08/13] Move docs on vector shutdown to Rust comment instead of bash comment --- src/product_logging/framework.rs | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index 5fdc3d36d..7ca8db002 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1007,7 +1007,19 @@ sinks: ) } -/// Create the specification of the Vector log agent container +/// Create the specification of the Vector log agent container. +/// +/// The vector process is not running as PID 1, so a Kubernetes SIGTERM will be have no effect. +/// Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, +/// e.g. {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. This way logs from the products will always be shipped, +/// as the vector container will be the last one to terminate. A specific container must be chosen, which has the responsibility +/// to create a file after it has properly shut down. It should be the one taking the longest to shut down. +/// E.g. for hdfs the lifetime of vector will be bound to the datanode container and not to the zkfc container. +/// We *could* have different shutdown trigger files for all application containers and wait for all containers +/// to terminate, but that seems rather complicated and will be added once needed. Additionally, you should remove +/// the shutdown marker file on startup of the application, as the application container can crash for any reason +/// and get restarted. If you don't remove the shutdown file on startup, the vector container will crashloop forever, +/// as it will start and shut down immediately after! /// /// ``` /// use stackable_operator::{ @@ -1083,31 +1095,19 @@ pub fn vector_container( .unwrap() .image_from_product_image(image) .command(vec![ - "/bin/bash".to_string(), - "-x".to_string(), - "-euo".to_string(), - "pipefail".to_string(), - "-c".to_string(), - ]) + "/bin/bash".to_string(), + "-x".to_string(), + "-euo".to_string(), + "pipefail".to_string(), + "-c".to_string(), + ]) + // The following code is an alternative approach which can get SIGTERM terminated as well as via writing a file. + // It is left in here, as it needed some effort to get it right and can be helpful in the future. + // bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & + // exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} .args(vec![format!( "\ -# The vector process is not running as PID 1, so a Kubernetes SIGTERM will be have no effect. -# Instead, the vector process can be shut down by creating a file below {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}, -# e.g. {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}. -# This way logs from the products will always be shipped, as the vector container will be the last one to terminate. -# A specific container must be chosen, which has the responsibility to create a file after it has -# properly shut down. It should be the one taking the longest to shut down. -# E.g. for hdfs the lifetime of vector will be bound to the datanode container and not to the zkfc container. -# We *could* have different shutdown trigger files for all application containers and wait for all containers -# to terminate, but that seems rather complicated and will be added once needed. -# Additionally, you should remove the shutdown marker file on startup of the application, as the application -# container can crash for any reason and get restarted. If you don't remove the shutdown file on startup, -# the vector container will crashloop forever as it will start and shut down immediately after! - -# ALTERNATIVE, which can get SIGTERM terminated as well as via writing a file (?) -# bash -c 'sleep 1 && if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && inotifywait -qq --event create {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}; fi && kill 1' & -# exec vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} - +# Vector will ignore SIGTERM (as PID != 1) and must be shut down by writing a shutdown trigger file vector --config {STACKABLE_CONFIG_DIR}/{VECTOR_CONFIG_FILE} & vector_pid=$! if [ ! -f \"{STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR}/{SHUTDOWN_FILE}\" ]; then mkdir -p {STACKABLE_LOG_DIR}/{VECTOR_LOG_DIR} && \ From fbe4d0c2f666476aaf579e159f856171c2e03f8e Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 08:14:01 +0100 Subject: [PATCH 09/13] document COMMON_BASH_TRAP_FUNCTIONS --- src/utils.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index c916a589d..1a3edfaf4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,14 +1,28 @@ use tracing::info; +/// This is a bash snippet, which adds two functions out of interest: +/// +/// 1. `prepare_signal_handlers` call this first to set up the needed traps +/// 2. `wait_for_termination` waits for the PID you passed as the first argument to terminate +/// +/// An example use could be +/// ``` +/// {COMMON_BASH_TRAP_FUNCTIONS} +/// echo "Run before startup" +/// prepare_signal_handlers +/// {hadoop_home}/bin/hdfs {role} & +/// wait_for_termination $! +/// echo "Run after termination" +/// ``` pub const COMMON_BASH_TRAP_FUNCTIONS: &str = r#" prepare_signal_handlers() { unset term_child_pid unset term_kill_needed - trap 'handle_term' TERM + trap 'handle_term_signal' TERM } -handle_term() +handle_term_signal() { if [ "${term_child_pid}" ]; then kill -TERM "${term_child_pid}" 2>/dev/null @@ -20,7 +34,7 @@ handle_term() wait_for_termination() { set +e - term_child_pid=$! + term_child_pid=$1 if [[ -v term_kill_needed ]]; then kill -TERM "${term_child_pid}" 2>/dev/null fi From 78501a8491bd8d445dee7a660d5a6433012623b2 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 08:25:34 +0100 Subject: [PATCH 10/13] fix test --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 1a3edfaf4..9d041bcea 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -6,7 +6,7 @@ use tracing::info; /// 2. `wait_for_termination` waits for the PID you passed as the first argument to terminate /// /// An example use could be -/// ``` +/// ```text /// {COMMON_BASH_TRAP_FUNCTIONS} /// echo "Run before startup" /// prepare_signal_handlers From e1856706c6c61b70600565c6414bd67acbbe273a Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 08:40:54 +0100 Subject: [PATCH 11/13] Add main container to vector container rustdoc --- src/product_logging/framework.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/product_logging/framework.rs b/src/product_logging/framework.rs index 7ca8db002..b3ba66d7c 100644 --- a/src/product_logging/framework.rs +++ b/src/product_logging/framework.rs @@ -1024,11 +1024,13 @@ sinks: /// ``` /// use stackable_operator::{ /// builder::{ +/// ContainerBuilder, /// meta::ObjectMetaBuilder, /// PodBuilder, /// resources::ResourceRequirementsBuilder /// }, -/// product_logging, +/// product_logging::{self, framework:: {create_vector_shutdown_file_command, remove_vector_shutdown_file_command}}, +/// utils::COMMON_BASH_TRAP_FUNCTIONS, /// }; /// use k8s_openapi::apimachinery::pkg::api::resource::Quantity; /// # use stackable_operator::{ @@ -1038,6 +1040,8 @@ sinks: /// # }; /// # use strum::{Display, EnumIter}; /// # +/// # pub const STACKABLE_LOG_DIR: &str = "/stackable/log"; +/// # /// # #[derive(Clone, Display, Eq, EnumIter, Ord, PartialEq, PartialOrd)] /// # pub enum Container { /// # Vector, @@ -1063,6 +1067,27 @@ sinks: /// .with_memory_limit("1Gi") /// .build(); /// +/// pod_builder.add_container( +/// ContainerBuilder::new("application") +/// .unwrap() +/// .image_from_product_image(&resolved_product_image) +/// .args(vec![format!( +/// "\ +/// {COMMON_BASH_TRAP_FUNCTIONS} +/// {remove_vector_shutdown_file_command} +/// prepare_signal_handlers +/// my-application start & +/// wait_for_termination $! +/// {create_vector_shutdown_file_command} +/// ", +/// remove_vector_shutdown_file_command = +/// remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), +/// create_vector_shutdown_file_command = +/// create_vector_shutdown_file_command(STACKABLE_LOG_DIR), +/// )]) +/// .build(), +/// ); +/// /// if logging.enable_vector_agent { /// pod_builder.add_container(product_logging::framework::vector_container( /// &resolved_product_image, From 6d2515e5cde6e64656583b5d81804279d3901da9 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 11:23:13 +0100 Subject: [PATCH 12/13] changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 238ce2084..a3067228b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Added `COMMON_BASH_TRAP_FUNCTIONS`, which can be used to write Vector shutdown trigger file after the main application stopped ([#681]). + +### Changed + +- BREAKING: Rename `product_logging::framework::shutdown_vector_command` to `create_vector_shutdown_file_command` and added `remove_vector_shutdown_file_command` ([#681]). + +[#681]: https://github.com/stackabletech/operator-rs/pull/681 + ## [0.55.0] - 2023-10-16 ### Added From b3b33e2733965e97f367ecc547abaa22a9829aaf Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 31 Oct 2023 11:23:44 +0100 Subject: [PATCH 13/13] typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3067228b..b390b38af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ### Added -- Added `COMMON_BASH_TRAP_FUNCTIONS`, which can be used to write Vector shutdown trigger file after the main application stopped ([#681]). +- Added `COMMON_BASH_TRAP_FUNCTIONS`, which can be used to write a Vector shutdown trigger file after the main application stopped ([#681]). ### Changed