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
12 changes: 6 additions & 6 deletions k8s-sysreport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ if [[ -n "$NS" && -n "$POD" ]]; then
fi

# Build dovecot-sysreport command
DS_CMD="dovecot-sysreport"
DS_CMD="dovecot-sysreport -D /tmp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kinda requires -D support from sysreport, which might not be present until next version.

if [[ -n "$CORE_IN_POD_PATH" ]]; then
DS_CMD="$DS_CMD --core $CORE_IN_POD_PATH"
fi

log "Running dovecot-sysreport in $NS/$POD${CONTAINER:+ (container=$CONTAINER)}"
if [[ -n "$CONTAINER" ]]; then
kubectl -n "$NS" exec "$POD" -c "$CONTAINER" -- sh -lc "$DS_CMD" || true
DS_ARCHIVE_PATH="$(kubectl -n "$NS" exec "$POD" -c "$CONTAINER" -- sh -lc "$find_ds_archive_cmd" | tr -d '\r')"
kubectl -n "$NS" exec "$POD" -c "$CONTAINER" -- $DS_CMD || true
DS_ARCHIVE_PATH="$(kubectl -n "$NS" exec "$POD" -c "$CONTAINER" -- env sh -lc "$find_ds_archive_cmd" | tr -d '\r')"
else
kubectl -n "$NS" exec "$POD" -- sh -lc "$DS_CMD" || true
DS_ARCHIVE_PATH="$(kubectl -n "$NS" exec "$POD" -- sh -lc "$find_ds_archive_cmd" | tr -d '\r')"
kubectl -n "$NS" exec "$POD" -- $DS_CMD || true
DS_ARCHIVE_PATH="$(kubectl -n "$NS" exec "$POD" -- env sh -lc "$find_ds_archive_cmd" | tr -d '\r')"
fi

[[ -n "${DS_ARCHIVE_PATH:-}" ]] || { echo "dovecot-sysreport archive not found in pod" >&2; exit 1; }
Expand Down Expand Up @@ -131,7 +131,7 @@ if ! command -v dovecot-sysreport >/dev/null 2>&1; then
fi

# Run dovecot-sysreport (no --core by default)
DS_CMD="dovecot-sysreport"
DS_CMD="dovecot-sysreport -D /tmp"
if [[ -n "$CORE_IN_POD" ]]; then
DS_CMD="$DS_CMD --core $CORE_IN_POD"
log "Running dovecot-sysreport with --core $CORE_IN_POD"
Expand Down
9 changes: 8 additions & 1 deletion test-k8s-sysreport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ export PATH="$MOCKROOT/bin:$PATH"
cat > "$MOCKROOT/bin/dovecot-sysreport" <<'EOF'
#!/usr/bin/env bash
# Creates a tarball under /tmp to simulate real dovecot-sysreport output
set -eu
destdir="./"
case "$1" in
-D)
destdir=$2
;;
esac
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
OUT="/tmp/dovecot-sysreport-${STAMP}.tar.gz"
OUT="$destdir/dovecot-sysreport-${STAMP}.tar.gz"
TMPD="$(mktemp -d)"
echo "mock dovecot report" > "$TMPD/report.txt"
tar -czf "$OUT" -C "$TMPD" report.txt
Expand Down