Skip to content

Commit

Permalink
Merge pull request #3964 from puppetlabs/7.x
Browse files Browse the repository at this point in the history
7.x
  • Loading branch information
donoghuc committed Apr 11, 2024
2 parents e9557ce + 7eed8fd commit 0e71209
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
2 changes: 2 additions & 0 deletions acceptance/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,8 @@ def install_puppet_from_package(puppet_collection = "puppet6")
# Take new configuration file on debian to prevent tests from hanging
# when this is used to upgrade puppet
if get_os_family(database) == :debian
# Explicitly install ca-certificates-java before java to avoid error installing java on debian
database.install_package('ca-certificates-java')
database.install_package('puppetserver', '-o Dpkg::Options::="--force-confnew"')
else
install_package(database, 'puppetserver')
Expand Down
16 changes: 16 additions & 0 deletions documentation/release_notes_7.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ canonical: "/puppetdb/latest/release_notes.html"

# PuppetDB: Release notes

## PuppetDB 7.18.0

Released April 11 2024

### Improvements

* Ship with updated dependencies (clojure, and pgjdbc)

### Bug fixes

* Ensure producer_timestamp is logged with legacy commands.

### Contributors

Austin Blatt and Rob Browning.

## PuppetDB 7.17.1

Released February 27 2024
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(def pdb-version "7.17.2-SNAPSHOT")
(def pdb-version "7.18.1-SNAPSHOT")

(def clj-parent-version "5.6.11")
(def clj-parent-version "5.6.13")

(defn true-in-env? [x]
(#{"true" "yes" "1"} (System/getenv x)))
Expand Down
32 changes: 19 additions & 13 deletions src/puppetlabs/puppetdb/command.clj
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,19 @@
"Processes a command ref marked for deletion. This is similar to
processing a non-delete cmdref except different metrics need to be
updated to indicate the difference in command"
[cmd {:keys [command version certname id received producer_timestamp] :as cmdref}
[cmd {:keys [command version certname id received] :as cmdref}
q response-chan stats _options-config maybe-send-cmd-event!]
(swap! stats update :executed-commands inc)
((:callback cmd) {:command cmd :result nil})
(async/>!! response-chan (make-cmd-processed-message cmd nil))
(log-command-processed-messsage id received (now) (command-keys command)
certname producer_timestamp
{:status :obsolete})
(queue/ack-command q {:entry (queue/cmdref->entry cmdref)})
(maybe-send-cmd-event! cmdref ::processed)
(update-counter! :depth command version dec!)
(update-counter! :invalidated command version dec!))
(let [producer_timestamp (get-in cmd [:payload :producer_timestamp])]
(swap! stats update :executed-commands inc)
((:callback cmd) {:command cmd :result nil})
(async/>!! response-chan (make-cmd-processed-message cmd nil))
(log-command-processed-messsage id received (now) (command-keys command)
certname producer_timestamp
{:status :obsolete})
(queue/ack-command q {:entry (queue/cmdref->entry cmdref)})
(maybe-send-cmd-event! cmdref ::processed)
(update-counter! :depth command version dec!)
(update-counter! :invalidated command version dec!)))

(defn broadcast-cmd
[{:keys [certname command id callback] :as cmd}
Expand Down Expand Up @@ -811,8 +812,13 @@
(mark! (global-metric :fatal))
(maybe-send-cmd-event! cmdref ::processed))

delete? (process-delete-cmd cmd cmdref q response-chan stats
options-config maybe-send-cmd-event!)
delete? (-> cmd
;; :producer_timestamp is optional in some commands.
;; Normally handled by prep-command, but those operations
;; can be expensive and aren't necessary to drop the cmd.
(update-in [:payload :producer_timestamp] #(or % (now)))
(process-delete-cmd cmdref q response-chan stats
options-config maybe-send-cmd-event!))

:else (-> cmd
(prep-command options-config)
Expand Down
8 changes: 7 additions & 1 deletion test/puppetlabs/puppetdb/command_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
[puppetlabs.trapperkeeper.services
:refer [service-context]]
[puppetlabs.puppetdb.client :as client]
[puppetlabs.stockpile.queue :as stock]
[puppetlabs.puppetdb.threadpool :as pool])
(:import
(clojure.lang ExceptionInfo)
Expand Down Expand Up @@ -1627,6 +1628,8 @@
(svc-utils/with-puppetdb-instance
(let [{pdb-host :host pdb-port :port
:or {pdb-host "127.0.0.1" pdb-port 8080}} (:jetty (get-config))
pdb (get-service svc-utils/*server* :PuppetDBServer)
q (:q (cli-svc/shared-globals pdb))
base-url (utils/pdb-cmd-base-url pdb-host pdb-port :v1)
facts {:certname "foo.com"
:environment "test"
Expand Down Expand Up @@ -1662,7 +1665,10 @@

;; check the first command was "bashed"
(is (= #{{:id 0 :delete? true} {:id 1 :delete? nil}}
(set (map #(select-keys % [:id :delete?]) val))))))))))
(set (map #(select-keys % [:id :delete?]) val))))

;; check that all commands removed from stockpile
(is (= 0 (stock/reduce q (fn [acc _] (inc acc)) 0)))))))))

(deftest command-service-stats
(svc-utils/with-puppetdb-instance
Expand Down

0 comments on commit 0e71209

Please sign in to comment.