Patch out jolokia support, as it's a very large java package, it's not in the
archive and it's very unlikely to make it in Bullseye.
Index: trapperkeeper-metrics-clojure/src/clj/puppetlabs/trapperkeeper/services/metrics/jolokia.clj
===================================================================
--- trapperkeeper-metrics-clojure.orig/src/clj/puppetlabs/trapperkeeper/services/metrics/jolokia.clj
+++ /dev/null
@@ -1,103 +0,0 @@
-(ns puppetlabs.trapperkeeper.services.metrics.jolokia
-  "Clojure helpers for constructing and configuring Jolokia servlets."
-  (:require [clojure.tools.logging :as log]
-            [clojure.walk :as walk]
-            [ring.util.servlet :as ring-servlet]
-            [schema.core :as schema])
-  (:import [javax.servlet.http HttpServletRequest]
-           [org.jolokia.config ConfigKey]
-           [org.jolokia.util LogHandler]
-           [org.jolokia.http AgentServlet]))
-
-
-(def config-mapping
-  "Inspects the Jolokia ConfigKey Enum and generates a mapping that associates
-  a Clojure keyword with each configuration parameter. The keyword used is the
-  camel-cased identifier that would be used to configure a servlet via a
-  web.xml file. For example, `ConfigKey/AGENT_ID` is associated with the
-  keyword `:agentId`.
-
-  For a complete list of configuration options, see:
-
-    https://jolokia.org/reference/html/agents.html#agent-war-init-params"
-  (->> (ConfigKey/values)
-       (map (juxt
-              #(-> % .getKeyValue keyword)
-              identity))
-       (into {})))
-
-(schema/defschema JolokiaConfig
-  "Schema for validating Clojure maps containing Jolokia configuration.
-
-  Creates a map of optional keys which have string values using the
-  config-mapping extracted from the ConfigKey enum."
-  (->> (keys config-mapping)
-       (map #(vector (schema/optional-key %) schema/Str))
-       (into {})))
-
-(def config-defaults
-  "Default configuration values for Jolokia."
-  {;; When set to "false", no debug-level messages are produced by the Jolokia
-   ;; namespace. This is unfortunate for debuggability, but having debug set to
-   ;; "true" causes a lot of useless error messages and backtraces to flood the
-   ;; logs when 404 results are generated by requests for JMX items that
-   ;; do not exist.
-   :debug "false"
-   ;; Don't include backtraces in error results returned by the API.
-   :allowErrorDetails "false"
-   ;; Used by jolokia-access to match IPv4 and IPv6 to "localhost"
-   :allowDnsReverseLookup "true"
-   ;; Load access policy from: resources/jolokia-access.xml
-   :policyLocation "classpath:/jolokia-access.xml"
-   :mimeType "application/json"})
-
-
-(defn create-servlet-config
-  "Generate Jolokia AgentServlet configuration from a Clojure map"
-  ([]
-   (create-servlet-config {}))
-  ([config]
-   (->> config
-        (merge config-defaults)
-        ;; Validate here to ensure defaults are also valid.
-        (schema/validate JolokiaConfig)
-        walk/stringify-keys)))
-
-(defn create-logger
-  "Return an object that implements the Jolokia logging interface using the
-  logger from clojure.tools.logging"
-  []
-  (reify
-    LogHandler
-    (debug [this message] (log/debug message))
-    (info [this message] (log/info message))
-    (error [this message throwable] (log/error throwable message))))
-
-(defn create-servlet
-  "Builds a Jolokia Servlet that uses Clojure logging."
-  [auth-check-fn]
-  (let [check-auth (if auth-check-fn
-                     (fn [^HttpServletRequest request]
-                      (auth-check-fn
-                       (ring-servlet/build-request-map request)))
-                     (fn [^HttpServletRequest request]
-                       {:authorized true :message ""}))]
-    (if auth-check-fn
-      (log/info "Metrics access control using trapperkeeper-authorization is enabled.")
-      (log/warn "Metrics access control using trapperkeeper-authorization is disabled. Add the authorization service to the trapperkeeper bootstrap configuration file to enable it."))
-    (proxy [AgentServlet] []
-     ;; NOTE: An alternative to this method override would be to use defrecord
-     ;; to create a class that can be set as `:logHandlerClass` in the servlet
-     ;; configuration. This requires AOT compilation for the namespace defining
-     ;; the record so that Jolokia can find the resulting class.
-     (createLogHandler [_ _]
-       (create-logger))
-     (service [request response]
-       (let [{:keys [authorized message]} (check-auth request)]
-          (if-not authorized
-            (ring-servlet/update-servlet-response
-             response
-             {:status 403
-              :headers {}
-              :body message})
-            (proxy-super service request response)))))))
Index: trapperkeeper-metrics-clojure/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_core.clj
===================================================================
--- trapperkeeper-metrics-clojure.orig/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_core.clj
+++ trapperkeeper-metrics-clojure/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_core.clj
@@ -14,8 +14,6 @@
             [puppetlabs.ring-middleware.utils :as ringutils]
             [puppetlabs.trapperkeeper.services.metrics.metrics-utils
              :as metrics-utils]
-            [puppetlabs.trapperkeeper.services.metrics.jolokia
-             :as jolokia]
             [puppetlabs.kitchensink.core :as ks]
             [puppetlabs.i18n.core :as i18n :refer [trs tru]]))
 
@@ -25,16 +23,11 @@
 (def JmxReporterConfig
   {:enabled schema/Bool})
 
-(def JolokiaApiConfig
-  {(schema/optional-key :enabled) schema/Bool
-   (schema/optional-key :servlet-init-params) jolokia/JolokiaConfig})
-
 (def MbeansApiConfig
   {(schema/optional-key :enabled) schema/Bool})
 
 (def WebserviceConfig
-  {(schema/optional-key :mbeans) MbeansApiConfig
-   (schema/optional-key :jolokia) JolokiaApiConfig})
+  {(schema/optional-key :mbeans) MbeansApiConfig})
 
 (def BaseGraphiteReporterConfig
   {:host schema/Str
Index: trapperkeeper-metrics-clojure/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_service.clj
===================================================================
--- trapperkeeper-metrics-clojure.orig/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_service.clj
+++ trapperkeeper-metrics-clojure/src/clj/puppetlabs/trapperkeeper/services/metrics/metrics_service.clj
@@ -3,7 +3,6 @@
             [puppetlabs.trapperkeeper.services.authorization.authorization-service :as tk-auth]
             [puppetlabs.trapperkeeper.services.protocols.metrics :as metrics]
             [puppetlabs.trapperkeeper.services.metrics.metrics-core :as core]
-            [puppetlabs.trapperkeeper.services.metrics.jolokia :as jolokia]
             [puppetlabs.trapperkeeper.services :as tk-services]
             [clojure.tools.logging :as log]
             [schema.core :as schema]
@@ -69,25 +68,6 @@
       (add-ring-handler this
                         (core/build-handler (get-route this))))
 
-    (when (get-in-config [:metrics :metrics-webservice :jolokia :enabled] true)
-      (let [config (->> (get-in-config [:metrics :metrics-webservice :jolokia :servlet-init-params] {})
-                        jolokia/create-servlet-config)
-            ;; NOTE: Normally, these route and server lookups would be done by
-            ;; WebroutingService/add-servlet-handler, but that doesn't properly
-            ;; mount sub-paths at the moment (TK-420). So we explicitly compute
-            ;; these items and use WebserverService/add-servlet-handler instead.
-            route (str (get-route this) "/v2")
-            server (get-server this)
-            options (if (nil? server)
-                      {:servlet-init-params config}
-                      {:servlet-init-params config :server-id (keyword server)})
-            auth-service (tk-services/maybe-get-service this :AuthorizationService)
-            auth-check-fn (if auth-service (partial tk-auth/authorization-check auth-service))]
-        (add-servlet-handler
-         (jolokia/create-servlet auth-check-fn)
-         route
-         options)))
-
     context)
 
   (stop [this context] context))
Index: trapperkeeper-metrics-clojure/test/puppetlabs/trapperkeeper/services/metrics/metrics_service_test.clj
===================================================================
--- trapperkeeper-metrics-clojure.orig/test/puppetlabs/trapperkeeper/services/metrics/metrics_service_test.clj
+++ trapperkeeper-metrics-clojure/test/puppetlabs/trapperkeeper/services/metrics/metrics_service_test.clj
@@ -120,24 +120,7 @@
          (is (= 200 (:status resp)))
          (doseq [[metric path] body
                  :let [resp (http-client/get (str "http://localhost:8180/metrics/v1" path))]]
-           (is (= 200 (:status resp)))))
-
-       (let [resp (http-client/get "http://localhost:8180/metrics/v2/list")
-             body (parse-response resp)]
-         (is (= 200 (:status  resp)))
-         (doseq [[namesp mbeans] (get body "value") mbean (keys mbeans)
-                 :let [url (str "http://localhost:8180/metrics/v2/read/"
-                                (jolokia-encode (str namesp ":" mbean))
-                                ;; NOTE: Some memory pools intentionally don't
-                                ;; implement MBean attributes. This results
-                                ;; in an error being thrown when those
-                                ;; attributes are read and is expected.
-                                "?ignoreErrors=true")
-                       resp (http-client/get url)
-                       body (parse-response resp)]]
-           ;; NOTE: Jolokia returns 200 OK for most responses. The actual
-           ;; status code is in the JSON payload that makes up the body.
-           (is (= 200 (get body "status"))))))
+           (is (= 200 (:status resp))))))
 
       (testing "register should add a metric to the registry with a keyword domain"
         (let [svc (app/get-service app :MetricsService)
@@ -196,34 +179,7 @@
                       {:body "{\"malformed json"})
                 body (slurp (:body resp))]
             (is (= 400 (:status resp)))
-            (is (re-find #"Unexpected end-of-input" body)))
-
-          (let [resp (http-client/post
-                      "http://localhost:8180/metrics/v2"
-                      {:body (json/generate-string
-                               [{:type "read" :mbean "pl.other.reg:name=puppetlabs.localhost.foo"}
-                                {:type "read" :mbean "pl.other.reg:name=puppetlabs.localhost.bar"}])})
-                body (parse-response resp true)]
-            (is (= [200 200] (map :status body)))
-            (is (= [{:Value 2} {:Value 500}] (map :value body))))))
-
-      (testing "metrics/v2 should deny write requests"
-        (with-test-logging
-          (let [resp (http-client/get
-                       (str "http://localhost:8180/metrics/v2/write/"
-                            (jolokia-encode "java.lang:type=Memory")
-                            "/Verbose/true"))
-                body (parse-response resp)]
-            (is (= 403 (get body "status"))))))
-
-      (testing "metrics/v2 should deny exec requests"
-        (with-test-logging
-          (let [resp (http-client/get
-                       (str "http://localhost:8180/metrics/v2/exec/"
-                            (jolokia-encode "java.util.logging:type=Logging")
-                            "/getLoggerLevel/root"))
-                body (parse-response resp)]
-            (is (= 403 (get body "status")))))))))
+            (is (re-find #"Unexpected end-of-input" body))))))))
 
 (deftest metrics-service-with-tk-auth
   (testing "tk-auth works when included in bootstrap"
@@ -232,9 +188,11 @@
       (conj services authorization-service/authorization-service)
       (merge metrics-service-config auth-config ssl-webserver-config)
       (let [resp (http-client/get "https://localhost:8180/metrics/v2/list" ssl-opts)]
-        (is (= 200 (:status resp))))
+        ; 404 since jolokia support is disabled
+        (is (= 404 (:status resp))))
       (let [resp (http-client/get "https://localhost:8180/metrics/v2" ssl-opts)]
-        (is (= 403 (:status resp)))))))
+        ; 404 since jolokia support is disabled
+        (is (= 404 (:status resp)))))))
 
 (deftest metrics-v1-endpoint-disabled-by-default
   (testing "metrics/v1 is disabled by default, returns 404"
@@ -248,38 +206,6 @@
         (let [resp (http-client/get "http://localhost:8180/metrics/v1/mbeans")]
           (is (= 404 (:status resp)))))))
 
-(deftest metrics-endpoint-with-jolokia-disabled-test
-  (testing "metrics/v2 returns 404 when Jolokia is not enabled"
-    (let [config (assoc-in metrics-service-config [:metrics :metrics-webservice :jolokia :enabled] false)]
-      (with-app-with-config
-       app
-       [jetty9-service/jetty9-service
-        webrouting-service/webrouting-service
-        metrics-service
-        metrics-webservice]
-       config
-        (let [resp (http-client/get "http://localhost:8180/metrics/v2/version")]
-          (is (= 404 (:status resp))))))))
-
-(deftest metrics-endpoint-with-permissive-jolokia-policy
-  (testing "metrics/v2 allows exec requests when configured with a permissive policy"
-    (let [config (assoc-in metrics-service-config
-                           [:metrics :metrics-webservice :jolokia :servlet-init-params :policyLocation]
-                           (str "file://" test-resources-dir "/jolokia-access-permissive.xml"))]
-      (with-app-with-config
-       app
-       [jetty9-service/jetty9-service
-        webrouting-service/webrouting-service
-        metrics-service
-        metrics-webservice]
-       config
-        (let [resp (http-client/get
-                     (str "http://localhost:8180/metrics/v2/exec/"
-                          (jolokia-encode "java.util.logging:type=Logging")
-                          "/getLoggerLevel/root"))
-              body (parse-response resp)]
-          (is (= 200 (get body "status"))))))))
-
 (deftest metrics-endpoint-with-jmx-disabled-test
   (testing "returns data for jvm even when jmx is not enabled"
     (let [config (-> metrics-service-config
Index: trapperkeeper-metrics-clojure/project.clj
===================================================================
--- trapperkeeper-metrics-clojure.orig/project.clj
+++ trapperkeeper-metrics-clojure/project.clj
@@ -21,7 +21,6 @@
                  [org.clojure/tools.logging "debian"]
                  [io.dropwizard.metrics/metrics-core "debian"]
                  [io.dropwizard.metrics/metrics-graphite "debian"]
-                 [org.jolokia/jolokia-core "1.6.2"]
                  [puppetlabs/comidi "debian"]
                  [puppetlabs/i18n "debian"]
 
