From a42e2dbe9bb88a55d9fd6ea18927cc0a9a420b2d Mon Sep 17 00:00:00 2001 From: rileynewton <95654936+rileynewton@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:13:54 -0800 Subject: [PATCH] (PE-35511) Update to tk-webserver-jetty-10 --- documentation/configure.markdown | 2 +- project.clj | 6 +++--- resources/puppetlabs/puppetdb/bootstrap.cfg | 2 +- src/puppetlabs/puppetdb/http/query.clj | 5 +++-- src/puppetlabs/puppetdb/pdb_routing.clj | 3 +-- test-resources/integration-bootstrap.cfg | 2 +- test-resources/puppetserver/bootstrap.cfg | 2 +- .../puppetdb/command_broadcast_test.clj | 18 ++++++++++++++---- test/puppetlabs/puppetdb/testutils/repl.clj | 4 ++-- .../puppetlabs/puppetdb/testutils/services.clj | 8 +++++--- 10 files changed, 32 insertions(+), 20 deletions(-) diff --git a/documentation/configure.markdown b/documentation/configure.markdown index 29c08ff606..e217132c65 100644 --- a/documentation/configure.markdown +++ b/documentation/configure.markdown @@ -714,7 +714,7 @@ Sets the maximum number of threads assigned to responding to HTTP and HTTPS requests, effectively changing how many concurrent requests can be made at one time. Defaults to 50. -> **Note:** Due to the behaviour of our web server (Jetty 9), this setting +> **Note:** Due to the behaviour of our web server (Jetty 10), this setting must be higher then the number of CPUs on your system or it will stop processing any HTTP requests. diff --git a/project.clj b/project.clj index 8ae26dfc09..7b7f19b495 100644 --- a/project.clj +++ b/project.clj @@ -72,7 +72,7 @@ '[[ring/ring-mock] [puppetlabs/trapperkeeper :classifier "test"] [puppetlabs/kitchensink :classifier "test"] - [puppetlabs/trapperkeeper-webserver-jetty9 :classifier "test"] + [com.puppetlabs/trapperkeeper-webserver-jetty10 :classifier "test"] [org.flatland/ordered "1.5.9"] [org.clojure/test.check "0.9.0"] [com.gfredericks/test.chuck "0.2.7" @@ -177,8 +177,8 @@ [puppetlabs/stockpile "0.0.4"] [puppetlabs/structured-logging] [puppetlabs/trapperkeeper] - [puppetlabs/trapperkeeper-webserver-jetty9] - [puppetlabs/trapperkeeper-metrics] + [com.puppetlabs/trapperkeeper-webserver-jetty10] + [puppetlabs/trapperkeeper-metrics "2.0.0"] [puppetlabs/trapperkeeper-status] [puppetlabs/trapperkeeper-authorization] diff --git a/resources/puppetlabs/puppetdb/bootstrap.cfg b/resources/puppetlabs/puppetdb/bootstrap.cfg index 44a6ac6a70..6b916d13c7 100644 --- a/resources/puppetlabs/puppetdb/bootstrap.cfg +++ b/resources/puppetlabs/puppetdb/bootstrap.cfg @@ -4,7 +4,7 @@ # https://github.com/puppetlabs/trapperkeeper/wiki/Bootstrapping # Web Server -puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service +puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service # Webrouting puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service diff --git a/src/puppetlabs/puppetdb/http/query.clj b/src/puppetlabs/puppetdb/http/query.clj index f0abda9ee2..3d35a76c71 100644 --- a/src/puppetlabs/puppetdb/http/query.clj +++ b/src/puppetlabs/puppetdb/http/query.clj @@ -12,7 +12,6 @@ [murphy :refer [try!]] [puppetlabs.puppetdb.query-eng :as qeng] [puppetlabs.puppetdb.query.monitor :as qmon] - [puppetlabs.trapperkeeper.services.webserver.jetty9 :as jetty9] [puppetlabs.i18n.core :refer [trs tru]] [puppetlabs.kitchensink.core :as kitchensink] [schema.core :as s] @@ -428,8 +427,10 @@ ;; May have no response because some tests (e.g. some ;; with-http-app based tests) don't add one right now. + _ (println "-DEBUG- \n what is req? " req) + _ (println "-DEBUG- \n what is (:response req)? " (:response req)) monitor-id (when-let [chan (and query-monitor - (some-> (::jetty9/response req) + (some-> (:response req) response->channel))] (qmon/stop-query-at-deadline-or-disconnect query-monitor query-uuid diff --git a/src/puppetlabs/puppetdb/pdb_routing.clj b/src/puppetlabs/puppetdb/pdb_routing.clj index dc4744d407..d68667c2a0 100644 --- a/src/puppetlabs/puppetdb/pdb_routing.clj +++ b/src/puppetlabs/puppetdb/pdb_routing.clj @@ -130,8 +130,7 @@ clean delete-node)) (mid/wrap-cert-authn cert-allowlist) - mid/wrap-with-puppetdb-middleware) - {:include-response true}) + mid/wrap-with-puppetdb-middleware)) (enable-maint-mode) (pdb-status/register-pdb-status diff --git a/test-resources/integration-bootstrap.cfg b/test-resources/integration-bootstrap.cfg index 49fc19cd17..54412ec03c 100644 --- a/test-resources/integration-bootstrap.cfg +++ b/test-resources/integration-bootstrap.cfg @@ -1,4 +1,4 @@ -puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service +puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service puppetlabs.trapperkeeper.services.metrics.metrics-service/metrics-webservice puppetlabs.trapperkeeper.services.status.status-service/status-service diff --git a/test-resources/puppetserver/bootstrap.cfg b/test-resources/puppetserver/bootstrap.cfg index 62d970f887..1a4881053a 100644 --- a/test-resources/puppetserver/bootstrap.cfg +++ b/test-resources/puppetserver/bootstrap.cfg @@ -2,7 +2,7 @@ puppetlabs.services.request-handler.request-handler-service/request-handler-serv puppetlabs.services.jruby.jruby-puppet-service/jruby-puppet-pooled-service puppetlabs.services.jruby-pool-manager.jruby-pool-manager-service/jruby-pool-manager-service puppetlabs.services.puppet-profiler.puppet-profiler-service/puppet-profiler-service -puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service +puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service puppetlabs.services.config.puppet-server-config-service/puppet-server-config-service puppetlabs.services.master.master-service/master-service diff --git a/test/puppetlabs/puppetdb/command_broadcast_test.clj b/test/puppetlabs/puppetdb/command_broadcast_test.clj index 2f3fad8ac7..55c7f29cdc 100644 --- a/test/puppetlabs/puppetdb/command_broadcast_test.clj +++ b/test/puppetlabs/puppetdb/command_broadcast_test.clj @@ -53,7 +53,8 @@ pg2 (int/setup-postgres) pdb1 (int/run-puppetdb pg1 {:database {:gc-interval "0"} :database-pg1 (int/server-info pg1) - :database-pg2 (int/server-info pg2)})] + :database-pg2 (int/server-info pg2)}) + _ (println "-DEBUG-:\n" pg1 "\n" pg2 "\n" pdb1 "\n")] ;; post a few commands to trigger broadcast to both pgs (populate-db pdb1) @@ -64,19 +65,28 @@ (is (= expected (int/pql-query pdb1 "catalogs [certname] {}"))))) (let [port (-> pdb1 int/server-info :base-url :port) + get-response-body (:body (svc-utils/get-ssl (str "https://localhost:" port "/metrics/v2/list"))) + get-response-body-value (-> get-response-body + :value) + get-response-body-value-storage (-> get-response-body-value + :puppetlabs.puppetdb.storage) list-metrics (fn [metric-type] ;; return metrics in :name=pg1. format - (-> (str "https://localhost:" port "/metrics/v2/list") - svc-utils/get-ssl + (-> get-response-body :body :value metric-type - keys))] + keys)) + _ (println "-DEBUG-: \n get-response-body: \n " get-response-body "\n") + _ (println "-DEBUG-: \n get-response-body-value: \n " get-response-body-value "\n") + _ (println "-DEBUG-: \n get-response-body-value-storage: \n " get-response-body-value-storage "\n")] (testing "Expected number of storage metrics are created for both PGs" (let [storage-metrics (list-metrics :puppetlabs.puppetdb.storage) + _ (println "-DEBUG-: \n storage-metrics: \n " storage-metrics "\n") ;; filter out non-broadcast metrics created in the registry during other tests broadcast-metrics (filter #(re-find (re-pattern (str "pg1" "|" "pg2")) (str %)) storage-metrics) + _ (println "-DEBUG-: \n broadcast-metrics: \n " broadcast-metrics "\n") expected-count 22 ;; 22 per pg metrics registered in storage.clj [pg-1 pg-2] (vals (group-by #(subs (str %) 1 9) broadcast-metrics))] (is (= expected-count (count pg-1))) diff --git a/test/puppetlabs/puppetdb/testutils/repl.clj b/test/puppetlabs/puppetdb/testutils/repl.clj index cfff5c8ed7..7a42d782dc 100644 --- a/test/puppetlabs/puppetdb/testutils/repl.clj +++ b/test/puppetlabs/puppetdb/testutils/repl.clj @@ -4,7 +4,7 @@ [puppetlabs.puppetdb.testutils :as testutils] [me.raynes.fs :as fs] [puppetlabs.puppetdb.cli.services :as svcs :refer [puppetdb-service]] - [puppetlabs.trapperkeeper.services.webserver.jetty9-service :refer [jetty9-service]] + [puppetlabs.trapperkeeper.services.webserver.jetty10-service :refer [jetty10-service]] [puppetlabs.trapperkeeper.core :as tk] [puppetlabs.trapperkeeper.app :as tka] [clojure.tools.namespace.repl :refer (refresh)])) @@ -41,7 +41,7 @@ (defn start [config-path] (alter-var-root #'system (fn [_] (tk/boot-services-with-cli-data - [jetty9-service puppetdb-service] + [jetty10-service puppetdb-service] {:config config-path})))) (defn stop [] diff --git a/test/puppetlabs/puppetdb/testutils/services.clj b/test/puppetlabs/puppetdb/testutils/services.clj index e495950e4e..ca02309db1 100644 --- a/test/puppetlabs/puppetdb/testutils/services.clj +++ b/test/puppetlabs/puppetdb/testutils/services.clj @@ -10,7 +10,7 @@ [clojure.walk :as walk] [puppetlabs.trapperkeeper.app :as tk-app :refer [get-service]] [puppetlabs.trapperkeeper.testutils.bootstrap :as tkbs] - [puppetlabs.trapperkeeper.services.webserver.jetty9-service :refer [jetty9-service]] + [puppetlabs.trapperkeeper.services.webserver.jetty10-service :refer [jetty10-service]] [puppetlabs.trapperkeeper.services.webrouting.webrouting-service :refer [webrouting-service]] [puppetlabs.trapperkeeper.services.status.status-service :refer [status-service]] [puppetlabs.trapperkeeper.services.scheduler.scheduler-service :refer [scheduler-service]] @@ -78,7 +78,7 @@ (def ^:dynamic *server*) (def default-services - [#'jetty9-service + [#'jetty10-service #'webrouting-service #'puppetdb-service #'command-service @@ -291,7 +291,9 @@ [url-str :- String & [opts]] (let [resp (get-unparsed url-str opts) - ctype (rr/get-header resp "content-type")] + ctype (rr/get-header resp "content-type") + _ (println "-DEBUG- what is ctype? " ctype) + _ (println "-DEBUG- json-utf8-ctype? " (json-utf8-ctype? ctype))] (if (some-> ctype json-utf8-ctype?) (update resp :body #(json/parse-string % true)) resp)))