Skip to content

Commit a71c4fe

Browse files
authored
Preserve logs, telemetry from all race configs after every nightly run (elastic#184)
Since /var/lib/jenkins/.rally/benchmarks/races gets fscked before every night-rally invocation, by default, for our Jenkins triggered nightlies, we still want to preserve important logs and telemetry output under each race directory. This commit copies the subdirectories telemetry, logs under each race id to `$HOME/race_archive/<date_part_from_effective_time_stamp>` Closes elastic#168
1 parent 97aded5 commit a71c4fe

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ For more details, please issue `night-rally-admin delete annotation --help`.
7070

7171
**Note:** The admin tool also supports a dry-run mode for all commands that would change the data store. Just append `--dry-run`.
7272

73+
#### Find logs, telemetry or heapdumps from older nightly runs
74+
75+
Each nightly execution wipes the data disk on target machines (`~/.var/lib/jenkins/rally/benchmarks/races`) as part of the initial [setup fixture](https://github.com/elastic/night-rally/tree/master/night_rally/fixtures/ansible/roles/initialize-data-disk).
76+
Important information from earlier nightly executions, specifically the `heapdump`, `logs` and `telemetry` subdirectories from each race id are copied under `/var/lib/jenkins/race_archive/<YYYYMMDD>` on each target machine, for future reference.
77+
This is done as the last step before the nightly run has finished.
78+
7379
#### Add a new track
7480

7581
Benchmarks get executed in two environments, group-1 / group-2 (see [infra repo](https://github.com/elastic/infra/blob/master/ansible/inventory/production/hetzner/benchmarks)).

night_rally.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SKIP_ANSIBLE=NO
4242
# Optionally, allow skipping Rally's auto-update mechanism. Applicable in Vagrant only.
4343
SKIP_RALLY_UPDATE=${SKIP_RALLY_UPDATE:-NO}
4444
# We invoke Rally with the current (UTC) timestamp. This determines the version to checkout.
45-
EFFECTIVE_START_DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
45+
EFFECTIVE_START_DATE=$(date -u "+%Y-%m-%d %H:%M:%S")
4646
# Deploy different Cloud credentials when running inside Vagrant
4747
IN_VAGRANT=${IN_VAGRANT:NO}
4848
MODE="nightly"
@@ -269,5 +269,14 @@ fi
269269
#****************************
270270
set -e
271271

272+
# Preserve logs in a directory that doesn't get wiped by the initialize-data-disk fixture between invocations
273+
if [[ $SKIP_ANSIBLE == NO ]]
274+
then
275+
pushd . >/dev/null 2>&1
276+
cd "${NIGHT_RALLY_HOME}/night_rally/fixtures/ansible"
277+
ansible-playbook -i inventory/production -u rally playbooks/copy-logs.yml --extra-vars "effective_start_date=${EFFECTIVE_START_DATE}"
278+
popd >/dev/null 2>&1
279+
fi
280+
272281
# Exit with the same exit code as night_rally.py
273282
exit ${exit_code}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
- name: archive logs to a persistent directory
3+
# ============================================
4+
# Copy subdirectories of `/var/lib/jenkins/.rally/benchmarks/races/` with important data (logs, telemetry)
5+
# to a directory that doesn't get wiped away between night-rally invocations
6+
hosts: target-hosts
7+
gather_facts: true
8+
become: true
9+
become_user: jenkins
10+
11+
vars:
12+
races_dir: '{{ ansible_env.HOME }}/.rally/benchmarks/races/'
13+
current_date: '{{ effective_start_date.split(" ")[0] | replace("-", "") }}'
14+
arch_dir: '{{ ansible_env.HOME }}/race_archive/{{ current_date }}'
15+
dirs_to_preserve:
16+
- 'heapdump'
17+
- 'logs'
18+
- 'telemetry'
19+
20+
tasks:
21+
- name: ensure race archive dir is present
22+
file:
23+
path: '{{ arch_dir }}'
24+
state: directory
25+
mode: '0755'
26+
27+
- name: build list of race paths to preserve
28+
find:
29+
path: '{{ races_dir }}'
30+
recurse: true
31+
excludes: 'lost+found'
32+
file_type: 'directory'
33+
patterns: '{{ dirs_to_preserve }}'
34+
register: race_paths
35+
36+
- name: ensure race archive dir is present
37+
file:
38+
path: '{{ arch_dir }}/{{ item["path"] | replace(races_dir, "") }}/'
39+
state: directory
40+
mode: '0755'
41+
loop: '{{ race_paths.files }}'
42+
no_log: true
43+
44+
- name: copy race paths to a persistent directory
45+
synchronize:
46+
src: '{{ item["path"] }}/'
47+
dest: '{{ arch_dir }}/{{ item["path"] | replace(races_dir, "") }}/'
48+
delegate_to: "{{ inventory_hostname }}"
49+
loop: '{{ race_paths.files }}'
50+
no_log: true
51+
52+
- debug:
53+
msg: 'All race sub-directories [{{ dirs_to_preserve | join(",") }}] under [{{ races_dir }}] have been successfully copied under [{{ arch_dir }}]'

0 commit comments

Comments
 (0)