Skip to content

opt: expand short hostnames in -x when PDSH_DEFAULT_DOMAIN is set#181

Open
BiloxiGeek wants to merge 1 commit intochaos:masterfrom
BiloxiGeek:feature/pdsh-default-domain-exclusion
Open

opt: expand short hostnames in -x when PDSH_DEFAULT_DOMAIN is set#181
BiloxiGeek wants to merge 1 commit intochaos:masterfrom
BiloxiGeek:feature/pdsh-default-domain-exclusion

Conversation

@BiloxiGeek
Copy link
Copy Markdown

When using -g to target a netgroup that returns FQDNs, exclusions specified with short hostnames via -x silently fail because the names don't match entries in the working collection.

This patch checks for a PDSH_DEFAULT_DOMAIN environment variable. If set, any short hostname (containing no '.') passed to -x is also tried as a FQDN (hostname.domain) against the working collection, so exclusions work correctly in mixed short/FQDN environments.

Also adds documentation for PDSH_DEFAULT_DOMAIN to the man page.

  When a netgroup (-g) returns FQDNs but exclusions (-x) are specified
  as short hostnames, the delete silently fails because the names don't
  match. If PDSH_DEFAULT_DOMAIN is set, append the domain to any short
  hostname (no '.') in the exclusion list before attempting hostlist_delete,
  so short hostnames correctly match FQDNs in the working collection.
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.49%. Comparing base (398ca48) to head (21bdd8d).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/pdsh/opt.c 40.00% 6 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #181      +/-   ##
==========================================
- Coverage   72.57%   72.49%   -0.09%     
==========================================
  Files          25       25              
  Lines        4088     4097       +9     
==========================================
+ Hits         2967     2970       +3     
- Misses       1121     1127       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@grondo
Copy link
Copy Markdown
Member

grondo commented Mar 2, 2026

This seems pretty reasonable. Note that -x also supports regex matching, but I can see how that would be cumbersome for this use case.

If PDSH_DEFAULT_DOMAIN is set, should the domain also be automatically added to hostnames in -w (if no domain is already there?) If the environment variable is only meant to apply to excluded hosts then maybe using PDSH_EXCLUDE_DEFAULT_DOMAIN would be a more appropriate name.

Also, tests for this work should be added under tests/ if you don't mind. Thanks!

@BiloxiGeek
Copy link
Copy Markdown
Author

BiloxiGeek commented Mar 3, 2026

Actually I hadn't known -x could do regex, that might be a better solution since it's already cooked in. I must have missed that when I was first learning how to use pdsh and never thought to revisit the man page about it. I'd say you can reject this as a fix for a non-existent problem. The idea I came up with still has merits though in that the regex is great for hostname matching but the default domain environment gets rid of the regex string for the more overall domain name matching. If you want to roll this into the code independently of this PR please do so but I can deal with the regex way for now.

Adding the default domain to hosts in -w would make sense if DNS doesn't resolve the short name. All the systems I deal with have a good search domain set in resolve.conf so using short hostnames in -w hasn't been a problem. Maybe change the -x so it will do a direct match to whatever hostnames are already in -w or from the group in -g and if there's no match from those then try adding the default domain. Basically let -x use dns and the list already populated by -w or -g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants