-
Notifications
You must be signed in to change notification settings - Fork 112
fix(jenkins): bound journal and coredump collection to the current build #15669
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,35 @@ | |
|
|
||
| def call(Map params){ | ||
| def test_config = groovy.json.JsonOutput.toJson(params.test_config) | ||
| // Bound the journal to this build. On an ephemeral builder the journal is minutes old so the | ||
| // bound changes nothing, but on a long-lived agent it is weeks of other jobs' history, and | ||
| // unbounded this used to tar and upload the entire host journal every build. | ||
| def sinceEpoch = (long) (currentBuild.startTimeInMillis / 1000) | ||
| sh """#!/bin/bash | ||
|
|
||
| set -xe | ||
|
|
||
| echo "${params.test_config}" | ||
| export SCT_CONFIG_FILES=${test_config} | ||
| SHORT_SCT_TEST_ID=\$(echo \$SCT_TEST_ID | cut -c1-8) | ||
| sudo journalctl --no-tail --no-pager -o short-precise > builder-\$SHORT_SCT_TEST_ID.log | ||
| tar -zcvf builder-\$SHORT_SCT_TEST_ID.log.tar.gz builder-\$SHORT_SCT_TEST_ID.log | ||
| # sudo -n so an agent without passwordless sudo fails fast instead of hanging on a password | ||
| # prompt. Then fall back to an unprivileged read before giving up: on a static agent that is | ||
| # still the journal this build can see (its own units, and everything else when the agent user | ||
| # is in systemd-journal), which beats no builder log at all. The if/else keeps a journal we | ||
| # cannot read from aborting the stage under set -e before anything got uploaded. | ||
| if sudo -n journalctl --since "@${sinceEpoch}" --no-tail --no-pager -o short-precise > builder-\$SHORT_SCT_TEST_ID.log ; then | ||
| journal_source="sudo journalctl" | ||
| elif journalctl --since "@${sinceEpoch}" --no-tail --no-pager -o short-precise > builder-\$SHORT_SCT_TEST_ID.log ; then | ||
| journal_source="unprivileged journalctl" | ||
| else | ||
| journal_source="" | ||
| echo "WARNING: neither sudo -n journalctl nor an unprivileged journalctl could read the journal on \$(hostname) - skipping builder journal upload" | ||
| fi | ||
|
|
||
| ./docker/env/hydra.sh upload --test-id \$SCT_TEST_ID builder-\$SHORT_SCT_TEST_ID.log.tar.gz | ||
| if [[ -n "\${journal_source}" ]] ; then | ||
| echo "collected builder journal via \${journal_source}" | ||
| tar -zcvf builder-\$SHORT_SCT_TEST_ID.log.tar.gz builder-\$SHORT_SCT_TEST_ID.log | ||
| ./docker/env/hydra.sh upload --test-id \$SCT_TEST_ID builder-\$SHORT_SCT_TEST_ID.log.tar.gz | ||
| fi | ||
|
Comment on lines
+21
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Implement the current-boot fallback. If 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented - see the reply on the sibling thread for detail: sudo -n first, unprivileged |
||
| """ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| #!groovy | ||
|
|
||
| def call(){ | ||
| // Bound the coredump sweep to this build: on a long-lived agent the coredump directory holds | ||
| // every dump the host ever produced (other jobs' included), and unbounded the script tars and | ||
| // uploads all of it. Epoch seconds, consumed by upload_sct_coredump.sh via -newermt. | ||
| def sinceEpoch = (long) (currentBuild.startTimeInMillis / 1000) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- vars/collectTestCoredumps.groovy ---'
cat -n vars/collectTestCoredumps.groovy
printf '%s\n' '--- vars/collectBuilderLogs.groovy ---'
cat -n vars/collectBuilderLogs.groovy
printf '%s\n' '--- references ---'
rg -n -F 'SCT_COREDUMPS_SINCE_EPOCH' . || true
rg -n -F 'collectTestCoredumps' . || true
rg -n -F 'collectBuilderLogs' . || trueRepository: scylladb/scylla-cluster-tests Length of output: 2931 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- utils/upload_sct_coredump.sh ---'
cat -n utils/upload_sct_coredump.sh
printf '%s\n' '--- vars/runCollectLogs.groovy ---'
cat -n vars/runCollectLogs.groovy
printf '%s\n' '--- timestamp consumers ---'
rg -n -C 4 'SINCE_EPOCH|journalctl|newermt|find .*core|coredump' utils varsRepository: scylladb/scylla-cluster-tests Length of output: 13823 🏁 Script executed: #!/bin/bash
set -e
python3 - <<'PY'
from decimal import Decimal
start_ms = 1_700_000_000_750
start_s = Decimal(start_ms) / Decimal(1000)
truncated_s = start_ms // 1000
samples = {
"prior_same_second": Decimal("1700000000.500"),
"build_start": start_s,
"after_start": Decimal("1700000000.900"),
}
print(f"build_start={start_s}")
print(f"truncated_lower_bound={truncated_s}")
for name, record_s in samples.items():
print(
f"{name}: record={record_s} "
f"included_with_truncated={record_s > truncated_s} "
f"included_with_fractional={record_s > start_s}"
)
PY
printf '%s\n' '--- GNU find fractional timestamp parsing ---'
find /dev/null -newermt '`@1700000000.750`' -print >/dev/null
echo "find_exit=$?"
printf '%s\n' '--- journalctl fractional timestamp parsing ---'
set +e
journalctl --since '`@1700000000.750`' --until '`@1700000000.751`' --no-pager --no-hostname -o cat >/dev/null 2>&1
status=$?
set -e
echo "journalctl_exit=$status"Repository: scylladb/scylla-cluster-tests Length of output: 641 🌐 Web query:
💡 Result: When using the --since or --until options in journalctl, you can specify a UNIX epoch timestamp by prefixing an integer or floating-point number with the "@" character [1]. The systemd time parsing logic, documented in systemd.time(7), supports fractional seconds for UNIX timestamps [1]. This allows you to achieve sub-second precision by including a decimal component after the integer portion of the timestamp (e.g., --since= Citations:
Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor Reachability: External · Exploitability: Moderate Preserve millisecond precision in both collection bounds. Use a fractional epoch value for 📍 Affects 2 files
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changing this one, deliberately - the truncation is in the safe direction and the sub-second overlap is harmless.
Fractional-epoch handling would also have to hold for both consumers ( |
||
| sh """#!/bin/bash | ||
|
|
||
| ./utils/upload_sct_coredump.sh | ||
| SCT_COREDUMPS_SINCE_EPOCH=${sinceEpoch} ./utils/upload_sct_coredump.sh | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SCT_* names are for the SCT config namespace. sct_config.py doesn't define |
||
| """ | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| truewould drop the exit code ofhydra.shexecution. Then on line 36 below the scipts returns/printsno coredumps ... nothing to upload, but the script states this as a fact and doesn't check exactly this is the result of hydra command execution and not some other error.