Skip to content

Commit 2a24f46

Browse files
committed
DNM DEBUG DISK USAGE
1 parent b2028e5 commit 2a24f46

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

ansible/tasks/stage2-setup-postgres.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,18 @@
6262
when: stage2
6363
become: true
6464
block:
65+
- name: Check disk usage before nix based installs
66+
ansible.builtin.command: df -h /
67+
register: df_before_nix_install
68+
changed_when: false
69+
70+
- name: Show disk usage before nix based installs
71+
ansible.builtin.debug:
72+
var: df_before_nix_install.stdout_lines
73+
6574
- name: Install packages from nix binary cache
6675
ansible.builtin.shell: |
67-
sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#{{ nix_item }}"
76+
sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#{{ nix_item }}; rc=$?; df -h / >&2; exit $rc"
6877
loop:
6978
- "{{ psql_version }}/bin"
7079
- pg_prove
@@ -73,10 +82,24 @@
7382
- "{{ postgresql_version }}_src"
7483
loop_control:
7584
loop_var: 'nix_item'
85+
register: nix_install_result
86+
ignore_errors: true
87+
88+
- name: Show df output for each nix install attempt
89+
ansible.builtin.debug:
90+
msg: "{{ item.stderr_lines }}"
91+
loop: "{{ nix_install_result.results }}"
92+
loop_control:
93+
label: "{{ item.nix_item }}"
94+
95+
- name: Fail if any nix install failed
96+
ansible.builtin.fail:
97+
msg: "nix profile install failed for: {{ nix_install_result.results | selectattr('failed', 'defined') | selectattr('failed') | map(attribute='nix_item') | list }}"
98+
when: nix_install_result is failed
7699

77100
- name: Install supascan for baseline validation
78101
ansible.builtin.shell: |
79-
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#supascan"
102+
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#supascan && df -h / >&2"
80103
81104
- name: nix collect garbage after supascan install
82105
ansible.builtin.shell:

ebssurrogate/scripts/nix-provision.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,27 @@ function cleanup_packages {
7171
apt-get remove --purge --yes ansible
7272
}
7373

74+
function show_disk_usage {
75+
echo "disk usage post $1:"
76+
df /
77+
df -h /
78+
du -x -h --max-depth=2 / | sort -rh | head -30
79+
}
80+
81+
# Snapshot disk usage even when a step below fails; errexit would otherwise skip
82+
# the remaining show_disk_usage calls and we'd lose the state we want to debug.
83+
trap 'show_disk_usage EXIT' EXIT
84+
7485
setup_apt
7586
update_and_upgrade_apt
87+
show_disk_usage update_and_upgrade_apt
7688
install_packages
89+
show_disk_usage install_packages
7790
install_nix
91+
show_disk_usage install_nix
7892
execute_stage2_playbook
93+
show_disk_usage ansible
7994
cleanup_packages
8095
update_and_upgrade_apt
8196
cleanup_apt
97+
show_disk_usage update_and_upgrade

ebssurrogate/scripts/surrogate-bootstrap-nix.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,13 @@ device_partition_mappings
347347
format_and_mount_rootfs
348348
format_build_partition
349349
setup_chroot_environment
350+
df /mnt
351+
df -h /mnt
352+
du -x -h --max-depth=2 /mnt | sort -rh | head -30
350353
execute_playbook
351354
update_systemd_services
352355
clean_system
356+
df /mnt
357+
df -h /mnt
358+
du -x -h --max-depth=2 /mnt | sort -rh | head -30
353359
umount_reset_mappings

0 commit comments

Comments
 (0)