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.

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

- `ProductImage::resolve` no longer panics on long product versions or image tags containing
non-ASCII characters and returns an error instead ([#1339]).
- `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]).

### Removed

Expand All @@ -24,6 +28,7 @@ All notable changes to this project will be documented in this file.
is removed as well ([#1338]).

[#1326]: https://github.com/stackabletech/operator-rs/pull/1326
[#1336]: https://github.com/stackabletech/operator-rs/pull/1336
[#1338]: https://github.com/stackabletech/operator-rs/pull/1338
[#1339]: https://github.com/stackabletech/operator-rs/pull/1339
[#1340]: https://github.com/stackabletech/operator-rs/pull/1340
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
90 changes: 84 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,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -556,7 +569,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-1 &&
exec > >(tee /stackable/log/git-sync-1/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-1/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-1/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -630,7 +656,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-2 &&
exec > >(tee /stackable/log/git-sync-2/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-2/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-2/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -701,7 +740,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stderr.log]=$! &&
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 +790,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-1-init &&
exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-1-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-1-init/container.stderr.log]=$! &&
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 +845,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-2-init &&
exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-2-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-2-init/container.stderr.log]=$! &&
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
150 changes: 140 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,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -687,7 +700,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-1 &&
exec > >(tee /stackable/log/git-sync-1/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-1/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-1/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-1/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -761,7 +787,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-2 &&
exec > >(tee /stackable/log/git-sync-2/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-2/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-2/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-2/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -832,7 +871,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stderr.log]=$! &&
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 +921,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-1-init &&
exec > >(tee /stackable/log/git-sync-1-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-1-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-1-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-1-init/container.stderr.log]=$! &&
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 +976,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-2-init &&
exec > >(tee /stackable/log/git-sync-2-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-2-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-2-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-2-init/container.stderr.log]=$! &&
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 +1151,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -1148,7 +1239,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stderr.log]=$! &&
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 +1387,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0 &&
exec > >(tee /stackable/log/git-sync-0/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0/container.stderr.log]=$! &&
trap stackable_wait_for_tee EXIT

prepare_signal_handlers()
{
Expand Down Expand Up @@ -1354,7 +1471,20 @@ 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 $!
}
declare -gA stackable_tee_pids
mkdir --parents /stackable/log/git-sync-0-init &&
exec > >(tee /stackable/log/git-sync-0-init/container.stdout.log) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stdout.log]=$! &&
exec 2> >(tee /stackable/log/git-sync-0-init/container.stderr.log >&2) &&
stackable_tee_pids[/stackable/log/git-sync-0-init/container.stderr.log]=$! &&
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