From 6bca92da4a7f9d1573db4fa7badffde5ed2747d6 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Tue, 5 May 2026 10:38:57 -0400 Subject: [PATCH] fix: stop pip's patchelf 'ERROR' line from polluting sosetup.log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cmd.run for psycopg2 install was already tolerating pip's non-zero exit with `|| true`, but pip's stderr — which contains the literal string "ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'patchelf'" — was still being captured into salt's state-result dict. so-setup logs salt state output to /root/sosetup.log, and verify_setup() then greps for the substring "ERROR" to build /root/errors.log. The patchelf line then shows up at the end of every install as "WARNING: Errors detected during setup" even though the install is in fact green. Redirect pip's combined stdout/stderr to /opt/so/log/so_pillar/psycopg2_install.log so the noise lives in a dedicated, predictable triage location instead of leaking into salt's state result. The `unless: import psycopg2` check is still the actual readiness gate, so a real install failure (rather than just the patchelf RPATH-rewrite step that has no functional effect on the wheel) would still surface via the state being re-run on every apply and `import psycopg2` failing. --- salt/postgres/schema_pillar.sls | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/salt/postgres/schema_pillar.sls b/salt/postgres/schema_pillar.sls index b08dcebc8..2f7e6ac2b 100644 --- a/salt/postgres/schema_pillar.sls +++ b/salt/postgres/schema_pillar.sls @@ -123,9 +123,19 @@ so_pillar_role_login_passwords: # installed and importable. salt's pip.installed surfaces the non-zero exit # as a state failure and the cascade kills schema_pillar's downstream work. # `import psycopg2` succeeds either way, so that's the actual readiness gate. +# +# Pip's stdout/stderr is redirected to /opt/so/log/so_pillar/psycopg2_install.log +# so the literal "ERROR: ... patchelf" line doesn't get hoovered up into +# /root/sosetup.log and then into /root/errors.log by verify_setup's +# substring-grep for "ERROR". The redirect target is preserved for +# triage if `import psycopg2` ever does fail. so_pillar_psycopg2_in_salt_python: cmd.run: - - name: /opt/saltstack/salt/bin/pip3 install --quiet psycopg2-binary || true + - name: | + mkdir -p /opt/so/log/so_pillar + /opt/saltstack/salt/bin/pip3 install --quiet psycopg2-binary \ + >/opt/so/log/so_pillar/psycopg2_install.log 2>&1 \ + || true - unless: /opt/saltstack/salt/bin/python3 -c "import psycopg2" - require: - cmd: so_pillar_role_login_passwords