Skip to content

(PE-38948) Respect rich_data in compileCatalog #2875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/ruby/puppetserver-lib/puppet/server/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ def handleRequest(request)
end

def compileCatalog(request_data)
Puppet.override(lookup_key_recorder: create_recorder) do
Puppet.override(
lookup_key_recorder: create_recorder,
# rich_data was moved to the context because determining if it should be true, in
# some code paths, needs to inspect the global settings, per-environment settings,
# and the request's content-type. For the `handleRequest` endpoint this logic is
# handled by the indirector. We need to provide some value, as the default in
# Puppet's context is, as of Puppet 8.9.0, hardcoded to be false, which will cause
# any rich_data in a catalog to fail via this endpoint (but likely not via the
# indirected endpoint). So here we set it to the global setting value, as the
# per-environment settings logic is fairly complicated to implement and have never
# gotten user facing documentation anyways.
rich_data: Puppet[:rich_data]
) do
@catalog_compiler.compile(convert_java_args_to_ruby(request_data))
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,29 @@
(finally
(jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test)))))))

(deftest ^:integration rich-data-is-honored
(let [tmpdir (fs/tmpdir)]
(fs/mkdir (str tmpdir "/yaml"))
(bootstrap-testutils/with-puppetserver-running
app
{:jruby-puppet {:gem-path gem-path
:max-active-instances 1
:server-code-dir test-resources-code-dir
:server-conf-dir master-service-test-runtime-dir
:server-var-dir (fs/tmpdir)}}
(let [jruby-service (tk-app/get-service app :JRubyPuppetService)
jruby-instance (jruby-testutils/borrow-instance jruby-service :rich-data-test)]
(try
(let [container (:scripting-container jruby-instance)
puppet-instance (:jruby-puppet jruby-instance)
catalog-compiler (.runScriptlet container "o = Object.new; o.define_singleton_method(:compile) {|args| Puppet.lookup(:rich_data) }; o")
_ (.callMethodWithArgArray container puppet-instance "instance_variable_set" (into-array Object ["@catalog_compiler" catalog-compiler]) Object)
rich-data (.callMethodWithArgArray container puppet-instance "compileCatalog" (into-array Object [{}]) Boolean)]
(testing "rich_data is true by default"
(is (= true rich-data))))
(finally
(jruby-testutils/return-instance jruby-service jruby-instance :rich-data-test)))))))

(deftest ^:integration v4-queue-limit
(bootstrap-testutils/with-puppetserver-running
app
Expand Down
Loading