Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed

- `product_logging::framework::capture_shell_output` no longer loses the output of short-lived
containers such as init containers. When stdout or stderr go to the console and to a file, the
generated command now sets an EXIT trap that waits up to five seconds for its `tee` processes.
Callers must not set their own EXIT trap ([#1336]).

[#1336]: https://github.com/stackabletech/operator-rs/pull/1336

## [0.122.0] - 2026-11-03

### Added
Expand Down
1 change: 1 addition & 0 deletions crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ xml.workspace = true
[dev-dependencies]
indoc.workspace = true
rstest.workspace = true
tempfile.workspace = true

[lints]
workspace = true
84 changes: 78 additions & 6 deletions crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,19 @@ mod tests {
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-0 && exec > >(tee /stackable/log/git-sync-0/container.stdout.log) 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -556,7 +568,19 @@ volumeMounts:
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-1 && exec > >(tee /stackable/log/git-sync-1/container.stdout.log) 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-1 &&
exec > >(tee /stackable/log/git-sync-1/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -630,7 +654,19 @@ volumeMounts:
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-2 && exec > >(tee /stackable/log/git-sync-2/container.stdout.log) 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-2 &&
exec > >(tee /stackable/log/git-sync-2/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -701,7 +737,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-0-init && exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=1 --git-config='safe.directory:/tmp/git' --link=current --one-time=true --period=20s --ref=main --repo=https://github.com/stackabletech/repo1 --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -738,7 +786,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-1-init && exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-1-init &&
exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=3 --git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt' --link=current --one-time=true --period=60s --ref=trunk --repo=https://github.com/stackabletech/repo2 --rev=HEAD --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -780,7 +840,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-2-init && exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-2-init &&
exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=1 --git-config='safe.directory:/tmp/git,key:value,safe.directory:/safe-dir' --link=current --one-time=true --period=20s --ref=feat/git-sync --repo=https://github.com/stackabletech/repo3 --root=/tmp/git
command:
- /bin/bash
Expand Down
140 changes: 130 additions & 10 deletions crates/stackable-operator/src/crd/git_sync/v1alpha2_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,19 @@ mod tests {
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-0 && exec > >(tee /stackable/log/git-sync-0/container.stdout.log) 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -687,7 +699,19 @@ volumeMounts:
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-1 && exec > >(tee /stackable/log/git-sync-1/container.stdout.log) 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-1 &&
exec > >(tee /stackable/log/git-sync-1/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -761,7 +785,19 @@ volumeMounts:
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-2 && exec > >(tee /stackable/log/git-sync-2/container.stdout.log) 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-2 &&
exec > >(tee /stackable/log/git-sync-2/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -832,7 +868,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-0-init && exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=1 --git-config='safe.directory:/tmp/git' --link=current --one-time=true --period=20s --ref=main --repo=https://github.com/stackabletech/repo1 --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -869,7 +917,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-1-init && exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-1-init &&
exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=3 --git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt' --link=current --one-time=true --period=60s --ref=trunk --repo=https://github.com/stackabletech/repo2 --rev=HEAD --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -911,7 +971,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-2-init && exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-2-init &&
exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=1 --git-config='safe.directory:/tmp/git,key:value,safe.directory:/safe-dir' --link=current --one-time=true --period=20s --ref=feat/git-sync --repo=https://github.com/stackabletech/repo3 --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -1073,7 +1145,19 @@ name: content-from-git-2
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-0 && exec > >(tee /stackable/log/git-sync-0/container.stdout.log) 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -1148,7 +1232,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-0-init && exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=3 --git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt' --link=current --one-time=true --period=60s --ref=trunk --repo=ssh://git@github.com/stackabletech/repo.git --rev=HEAD --root=/tmp/git
command:
- /bin/bash
Expand Down Expand Up @@ -1283,7 +1379,19 @@ secret:
assert_eq!(
r#"args:
- |-
mkdir --parents /stackable/log/git-sync-0 && exec > >(tee /stackable/log/git-sync-0/container.stdout.log) 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -1354,7 +1462,19 @@ volumeMounts:
assert_eq!(
r"args:
- |-
mkdir --parents /stackable/log/git-sync-0-init && exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2)
stackable_wait_for_tee() {
exec > /dev/null 2>&1
set +e
{ sleep 5; kill ${stackable_tee_pids[*]}; } &
wait ${stackable_tee_pids[*]}
kill $!
}
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids+=($!) &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids+=($!) &&
trap stackable_wait_for_tee EXIT
/stackable/git-sync --depth=3 --git-config='http.sslCAInfo:/stackable/gitca-0/ca.crt,safe.directory:/tmp/git' --link=current --one-time=true --period=60s --ref=trunk --repo=ssh://git@github.com/stackabletech/repo.git --rev=HEAD --root=/tmp/git
command:
- /bin/bash
Expand Down
Loading
Loading