Skip to content

Commit bbec082

Browse files
Merge pull request #2875 from justinstoller/thats_rich
(PE-38948) Respect rich_data in compileCatalog
2 parents 6e2f08a + b1a7ce5 commit bbec082

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/ruby/puppetserver-lib/puppet/server/master.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ def handleRequest(request)
9797
end
9898

9999
def compileCatalog(request_data)
100-
Puppet.override(lookup_key_recorder: create_recorder) do
100+
Puppet.override(
101+
lookup_key_recorder: create_recorder,
102+
# rich_data was moved to the context because determining if it should be true, in
103+
# some code paths, needs to inspect the global settings, per-environment settings,
104+
# and the request's content-type. For the `handleRequest` endpoint this logic is
105+
# handled by the indirector. We need to provide some value, as the default in
106+
# Puppet's context is, as of Puppet 8.9.0, hardcoded to be false, which will cause
107+
# any rich_data in a catalog to fail via this endpoint (but likely not via the
108+
# indirected endpoint). So here we set it to the global setting value, as the
109+
# per-environment settings logic is fairly complicated to implement and have never
110+
# gotten user facing documentation anyways.
111+
rich_data: Puppet[:rich_data]
112+
) do
101113
@catalog_compiler.compile(convert_java_args_to_ruby(request_data))
102114
end
103115
end

test/integration/puppetlabs/services/master/master_service_test.clj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,29 @@
724724
(finally
725725
(jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test)))))))
726726

727+
(deftest ^:integration rich-data-is-honored
728+
(let [tmpdir (fs/tmpdir)]
729+
(fs/mkdir (str tmpdir "/yaml"))
730+
(bootstrap-testutils/with-puppetserver-running
731+
app
732+
{:jruby-puppet {:gem-path gem-path
733+
:max-active-instances 1
734+
:server-code-dir test-resources-code-dir
735+
:server-conf-dir master-service-test-runtime-dir
736+
:server-var-dir (fs/tmpdir)}}
737+
(let [jruby-service (tk-app/get-service app :JRubyPuppetService)
738+
jruby-instance (jruby-testutils/borrow-instance jruby-service :rich-data-test)]
739+
(try
740+
(let [container (:scripting-container jruby-instance)
741+
puppet-instance (:jruby-puppet jruby-instance)
742+
catalog-compiler (.runScriptlet container "o = Object.new; o.define_singleton_method(:compile) {|args| Puppet.lookup(:rich_data) }; o")
743+
_ (.callMethodWithArgArray container puppet-instance "instance_variable_set" (into-array Object ["@catalog_compiler" catalog-compiler]) Object)
744+
rich-data (.callMethodWithArgArray container puppet-instance "compileCatalog" (into-array Object [{}]) Boolean)]
745+
(testing "rich_data is true by default"
746+
(is (= true rich-data))))
747+
(finally
748+
(jruby-testutils/return-instance jruby-service jruby-instance :rich-data-test)))))))
749+
727750
(deftest ^:integration v4-queue-limit
728751
(bootstrap-testutils/with-puppetserver-running
729752
app

0 commit comments

Comments
 (0)