From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 30 Jun 2022 11:21:19 -0400
Subject: Disable update checks by default

Don't let PDB call home by default. Note that setting 'disable-update-checking'
to 'false' is not enough; it only disables PDB's internal periodic update
checker, but the dashboard triggers an on-demand check with a call to
/pdb/meta/v1/version/latest.

Last-Update: 2022-06-30
Forwarded: not-needed
---
 src/puppetlabs/puppetdb/config.clj       | 7 ++++++-
 src/puppetlabs/puppetdb/meta.clj         | 2 +-
 test/puppetlabs/puppetdb/config_test.clj | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)

Index: puppetdb/src/puppetlabs/puppetdb/config.clj
===================================================================
--- puppetdb.orig/src/puppetlabs/puppetdb/config.clj
+++ puppetdb/src/puppetlabs/puppetdb/config.clj
@@ -204,7 +204,7 @@
   (all-optional
    {:certificate-whitelist s/Str
     :certificate-allowlist s/Str
-    :disable-update-checking (pls/defaulted-maybe String "false")
+    :disable-update-checking (pls/defaulted-maybe String "true")
     :add-agent-report-filter (pls/defaulted-maybe String "true")
     :log-queries (pls/defaulted-maybe String "false")
     :query-timeout-default (pls/defaulted-maybe String "600")
@@ -705,6 +705,11 @@
 (defn pe? [config]
   (= "pe-puppetdb" (get-in config [:global :product-name])))
 
+(defn update-checking-disabled? [config]
+  (or
+    (pe? config)
+    (get-in config [:puppetdb :disable-update-checking])))
+
 (defn update-server [config]
   (get-in config [:global :update-server]))
 
Index: puppetdb/src/puppetlabs/puppetdb/meta.clj
===================================================================
--- puppetdb.orig/src/puppetlabs/puppetdb/meta.clj
+++ puppetdb/src/puppetlabs/puppetdb/meta.clj
@@ -37,7 +37,7 @@
         ;; If we get one of these requests from pe-puppetdb, we always want to
         ;; return 'newer->false' so that the dashboard will never try
         ;; to display info about a newer version being available.
-        (if (conf/pe? config)
+        (if (conf/update-checking-disabled? config)
           (http/json-response {:newer false
                                :version (v/version)
                                :link nil})
Index: puppetdb/test/puppetlabs/puppetdb/config_test.clj
===================================================================
--- puppetdb.orig/test/puppetlabs/puppetdb/config_test.clj
+++ puppetdb/test/puppetlabs/puppetdb/config_test.clj
@@ -52,9 +52,9 @@
       (is (thrown? clojure.lang.ExceptionInfo
                    (configure-puppetdb {:puppetdb {:add-agent-report-filter 1337}}))))
 
-    (testing "disable-update-checking should default to 'false' if left unspecified"
+    (testing "disable-update-checking should default to 'true' if left unspecified"
       (let [config (configure-puppetdb {})]
-        (is (= (get-in config [:puppetdb :disable-update-checking]) false))))
+        (is (= (get-in config [:puppetdb :disable-update-checking]) true))))
 
     (testing "shold default :log-queries to false"
       (let [config (configure-puppetdb {})]
