Repository navigation
(PE-47146) Use TCP-only ss and inode matching for S0041/S0042 - #254
Conversation
S0041 and S0042 ran `ss -onp state established ...`. Without `-t`, ss queries every socket family it knows, including DCCP. On kernels where SELinux's netlink table no longer has DCCPDIAG_GETSOCK (e.g. AL2023 with kernel 6.18) each run logs: SELinux: unrecognized netlink message: protocol=4 nlmsg_type=19 sclass=netlink_tcpdiag_socket ... comm=ss `-p` also made ss walk /proc/<pid>/fd for every process. Reuse the approach agent_status_check AS002 has used since v2.5.0, moved into PEStatusCheck so the checks can share it: * `ss -tone state established '( dport = :PORT )'` collects socket inodes (2 TCP netlink queries instead of 13, no DCCP, no -p) * the target process is found from the systemd unit's MainPID * the check passes if the process holds one of those socket inodes S0042 uses pxp-agent. S0041 uses pe-puppetserver: on compilers the PCP broker runs inside puppetserver, and pe-orchestration-services does not run there. This also stops S0041 matching any unrelated java process. Adds unit tests for the helpers and for the S0041/S0042 chunks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The use of systemctl show --value breaks compatibility with systemd 219 on supported Linux 7 hosts, causing S0041 and S0042 to falsely report unhealthy connections.
1 open issue
What changed in this PR
This PR changes S0041/S0042 connection checks to use TCP socket inodes and systemd service PIDs, avoiding unnecessary socket-family queries that trigger SELinux warnings.
Changes:
- Add shared helpers for TCP socket discovery, process socket ownership, and service PID lookup.
- Match S0041 against
pe-puppetserverand S0042 againstpxp-agent, replacing process-name matching. - Add unit coverage for the helpers and both fact chunks.
| File | Description |
|---|---|
spec/unit/pe_status_check_sockets_spec.rb |
Tests socket helpers and PID lookup. |
spec/unit/pe_status_check_fact_sockets_spec.rb |
Tests service selection, connection results, and failure handling. |
lib/shared/pe_status_check.rb |
Adds TCP inode matching and systemd PID helpers. |
lib/facter/pe_status_check.rb |
Switches S0041/S0042 to service-specific socket ownership checks. |
Review effort: Balanced
`systemctl show --value` needs systemd 230+. RHEL/CentOS/Oracle Linux 7 (still in metadata.json) ship systemd 219, where the command fails and S0041/S0042 would report false on healthy hosts. Read the `MainPID=<n>` line from plain `systemctl show --property=MainPID` instead. Addresses review feedback on #254. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
EL7 validation (follow-up to the systemd 219 review comment)Tested on RHEL 7.2 (systemd 219) with a real PE agent (puppet-agent 8.22.2.8, installed from a PE 2025.12.3 primary), with pxp-agent holding an established connection to the broker on 8142. Each version of the S0042 chunk was loaded from git history and run with the agent's own Ruby:
So the review comment was right: on systemd 219 the original change reported an unhealthy broker connection on a healthy host, and fd7d523 resolves it. Not covered: S0041 on EL7 (compiler-only; this host is not a compiler), and CentOS/OracleLinux/Scientific 7, which share systemd 219 but were not tested. S0041 uses the same 🤖 Generated with Claude Code |

Summary
S0041 and S0042 ran
ss -onp state established '( dport = :PORT )'. Without-t,ssqueries every socket family it knows, including DCCP, and-pmakes it walk/proc/<pid>/fdfor every process. On kernels whose SELinux netlink table no longer includesDCCPDIAG_GETSOCK(reproduced on AL2023 with kernel 6.18.56), every run logs:This reuses the approach
agent_status_checkAS002 has used since v2.5.0, moved intoPEStatusCheckso the checks can share it:ss -tone state established '( dport = :PORT )'collects socket inodes (2 TCP netlink queries instead of 13; no DCCP, no-p)MainPIDS0042 checks
pxp-agent. S0041 checkspe-puppetserver: on compilers the PCP broker runs inside puppetserver, andpe-orchestration-servicesdoes not run there. This also stops S0041 matching any unrelated java process (it usedresult.include?('java')).Jira: PE-47146. Not changed: AS002 (it still globs
/proc/*/cmdline; it could move to the shared helpers in a follow-up).Testing
Unit: 13 examples pass (helpers, plus S0041/S0042 chunks with a stubbed
PEStatusCheck). The chunk tests fail if S0041 looks at the wrong unit. The repo's normalspec_helperdoes not load in my environment (Puppet 8.19 on Ruby 3.3.7 raises aFrozenError, with or without this change), so I ran the new specs with a stubbedpuppet. Please run them in CI.Live PE 2025.12.3-rc0-7-gf7c6aae, RHEL 9 primary + compiler, SELinux enforcing:
true. S0042 goesfalsewith pxp-agent stopped and S0041 goesfalsewithpe-puppetserverstopped; both recover after restart.ss -tone ...only, no-p.AL2023, kernel 6.18.56, enforcing, real PE agent with an established 8142 connection (S0042 chunk):
truetruetrueAL2023 kernels 6.1.49 and 6.12.114 and RHEL 9 (5.14) do not log the warning with either version, so the fix only changes the logged output on newer kernels.
Not covered
ausearch/AVC check and a compiler in the matrix). I can follow up.2023.8.xline pinsv4.3.0, so it needs a bump or a patch release.syncing from "puppetlabs/support_workflows". If it is mirrored, this may need to land there first.🤖 Generated with Claude Code