Conversation
Since OpenVoxProject#536 removed the default `server=puppet`, `create_service` raised (or warned) whenever `server` was not set in the config, even when the caller had already resolved a server through `server_list`, DNS SRV records, or an explicit `puppet://host/...` URL. An agent configured with only `server_list`, or with `use_srv_records` and `srv_domain`, could not connect at all. Move the check into `check_server_setting` and skip it when the resolver passes an explicit server. The settings-based resolver, which is the only one that falls back on `server`, keeps the existing errors and deprecation warning. Fixes OpenVoxProject#658 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Steven Pritchard <steven.pritchard@gmail.com>
|
@silug Unless I missed something, the idea is to relax the guard when |
@corporate-gadfly https://github.com/OpenVoxProject/openvox/pull/659/changes#diff-53d60872a028f347232d3ed8cd4873c0f9b06f5932ed4f4cd9ed463614be6dbfL36 was looking specifically for |
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns with the stated regression fix, and is covered by targeted unit tests for both the resolved and fallback behaviors.
Pull request overview
This PR adjusts the HTTP service creation path so the server setting is only required when the resolver truly needs to fall back to Puppet[:server], fixing regressions introduced when the implicit default server=puppet was removed (#536). This restores connectivity for agents that resolve a server via server_list, DNS SRV records, or an explicit puppet://host/... URL (Fixes #658).
Changes:
- Move the “server setting required / warn / raise” logic into
Puppet::HTTP::Service.check_server_setting. - Only enforce the
serversetting requirement increate_servicewhen no explicitserverargument is provided. - Add/adjust unit tests to cover resolution via
server_list, SRV records, explicit URLs, and the remaining failure case when falling back to theserversetting.
File summaries
| File | Description |
|---|---|
| lib/puppet/http/service.rb | Centralizes and scopes the server-setting enforcement to only cases where no explicit server is provided. |
| spec/unit/http/session_spec.rb | Adds coverage for resolving without server configured when using server_list, SRV, or explicit puppet URLs; asserts fallback still raises. |
| spec/unit/http/service_spec.rb | Verifies create_service does not warn/raise about missing server when an explicit server is passed. |
| spec/unit/http/resolver_spec.rb | Adds/adjusts resolver specs to ensure server-less resolution works when resolver supplies an explicit server. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Note This comment was generated by Claude Code at @silug's request, to expand on the explanation above. @corporate-gadfly The guard itself is not relaxed; the same checks, messages, and deprecation warning are still there, now in Why that is the right trigger Every service constructor picks its host with
Before this change the guard ran unconditionally at the top of Why nothing slips through The concern behind #536 is an agent silently talking to an implicit
In other words, every path that ends up reading Coverage The new |
miharp
left a comment
There was a problem hiding this comment.
Thanks for this. I tested it as root on a 9.0.0-rc1 agent against a 9.x server, and it fixes #658: with only server_list in puppet.conf (no server), puppet agent -t does a full run, and SRV-only configs resolve too. Both fail on main. spec/unit/http passes (474 examples) and rubocop is clean.
One case still fails as root: server_list together with report_server or ca_server.
Client#build_resolvers removes :report / :ca from the ServerList resolver when those settings are configured, so those two services fall through to the Settings resolver. That calls create_service with no server, and check_server_setting raises for root before it looks at report_server / ca_server, even though Report.new / Ca.new would have used them. The non-root branch already accounts for this; the root branch doesn't.
Steps to reproduce
As root, on a 9.0.0-rc1 agent that already has certs. The PR only changes one file under lib/, and rc1's copy is identical to the PR base, so it can be dropped in:
F=/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/http/service.rb
cp -p $F /root/service.rb.orig
curl -fsSL https://raw.githubusercontent.com/OpenVoxProject/openvox/4e814df3cf/lib/puppet/http/service.rb -o $F
cp -p /etc/puppetlabs/puppet/puppet.conf /root/puppet.conf.orig
cat > /etc/puppetlabs/puppet/puppet.conf <<'EOF'
[main]
server_list = puppet.example.com
report_server = puppet.example.com
EOF
puppet agent -tResult: the catalog is retrieved and applied, then the report is dropped:
Notice: Applied catalog in 0.19 seconds
Error: Could not send report: OpenVox does not default to `server=puppet` as of version 9.0. Please update your configuration appropriately by providing a specific server of your choice.
Remove the report_server line and the same run is clean.
ca_server fails the same way, but agent -t only talks to the CA when a refresh is due, so it is easier to see with:
# puppet ssl download_cert (puppet.conf: server_list + ca_server, no server)
Error: Could not run: Failed to download certificate: OpenVox does not default to `server=puppet` as of version 9.0. ...
With the suggestion below, both commands succeed and spec/unit/http still passes. As a side effect it also drops the "no longer defaults to server=puppet" deprecation warning for non-root users in this case, which seems right since nothing is falling back on server there.
Spec
A test for this would fit in the new 'when the server setting is not configured' context in spec/unit/http/session_spec.rb (it runs as root there). These fail on the current branch and pass with the suggestion:
it 'resolves the ca service using ca_server when server_list is set' do
Puppet[:server_list] = 'apple.example.com'
Puppet[:ca_server] = 'ca.example.com'
expect(session.route_to(:ca).url.to_s).to eq("https://ca.example.com:8140/puppet-ca/v1")
end
it 'resolves the report service using report_server when server_list is set' do
Puppet[:server_list] = 'apple.example.com'
Puppet[:report_server] = 'report.example.com'
expect(session.route_to(:report).url.to_s).to eq("https://report.example.com:8140/puppet/v3")
end| # | ||
| # @api private | ||
| def self.check_server_setting(name) | ||
| return if Puppet.settings.set_by_config? :server |
There was a problem hiding this comment.
As root this raises for :ca and :report even when ca_server / report_server is configured, which is the setting those services actually fall back on. Details and a repro in the review summary.
| return if Puppet.settings.set_by_config? :server | |
| return if Puppet.settings.set_by_config? :server | |
| return if name == :ca && Puppet.settings.set_by_config?(:ca_server) | |
| return if name == :report && Puppet.settings.set_by_config?(:report_server) |
|
@binford2k #536 was mostly your idea (I was merely the person who fixed the tests and merged it). Please chime in. |
Short description
Since #536 removed the default
server=puppet,create_serviceraised (or warned) wheneverserverwas not set in the config, even when the caller had already resolved a server throughserver_list, DNS SRV records, or an explicitpuppet://host/...URL. An agent configured with onlyserver_list, or withuse_srv_recordsandsrv_domain, could not connect at all.Move the check into
check_server_settingand skip it when the resolver passes an explicit server. The settings-based resolver, which is the only one that falls back onserver, keeps the existing errors and deprecation warning.Fixes #658
Generated by Claude Code
Checklist
I have:
Signed-off-byannotation to each of my commitsGenerated-byorAssisted-byannotations to each of my commits created with the help of an AI agent