Skip to content

Commit f1b5d91

Browse files
Merge pull request #2820 from jonathannewman/PE-37635/main/logging-level
2 parents 6100a56 + b37b4ee commit f1b5d91

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

src/clj/puppetlabs/puppetserver/certificate_authority.clj

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -720,26 +720,26 @@
720720

721721
(defn stream-content-to-file
722722
[^String cert-inventory ^String entry ^BufferedWriter writer]
723-
(log/trace (i18n/trs "Begin append to inventory file."))
724-
(let [copy-buffer (CharBuffer/allocate buffer-copy-size)]
725-
(try
726-
(with-open [^BufferedReader reader (io/reader cert-inventory)]
727-
;; copy all the existing content
728-
(loop [read-length (.read reader copy-buffer)]
729-
;; theoretically read can return 0, which means try again
730-
(when (<= 0 read-length)
731-
(when (pos? read-length)
732-
(.write writer (.array copy-buffer) 0 read-length))
733-
(.clear copy-buffer)
734-
(recur (.read reader copy-buffer)))))
735-
(catch FileNotFoundException _e
736-
(log/trace (i18n/trs "Inventory file not found. Assume empty.")))
737-
(catch Throwable e
738-
(log/error e (i18n/trs "Error while appending to inventory file."))
739-
(throw e))))
740-
(.write writer entry)
741-
(.flush writer)
742-
(log/trace (i18n/trs "Finish append to inventory file. ")))
723+
(log/trace (i18n/trs "Begin append to inventory file."))
724+
(let [copy-buffer (CharBuffer/allocate buffer-copy-size)]
725+
(try
726+
(with-open [^BufferedReader reader (io/reader cert-inventory)]
727+
;; copy all the existing content
728+
(loop [read-length (.read reader copy-buffer)]
729+
;; theoretically read can return 0, which means try again
730+
(when (<= 0 read-length)
731+
(when (pos? read-length)
732+
(.write writer (.array copy-buffer) 0 read-length))
733+
(.clear copy-buffer)
734+
(recur (.read reader copy-buffer)))))
735+
(catch FileNotFoundException _e
736+
(log/trace (i18n/trs "Inventory file not found. Assume empty.")))
737+
(catch Throwable e
738+
(log/error e (i18n/trs "Error while appending to inventory file."))
739+
(throw e))))
740+
(.write writer entry)
741+
(.flush writer)
742+
(log/trace (i18n/trs "Finish append to inventory file. ")))
743743

744744

745745
(schema/defn ^:always-validate
@@ -792,16 +792,16 @@
792792
* $S = The distinguished name of the cert's subject."
793793
[cert :- Certificate
794794
{:keys [inventory-lock inventory-lock-timeout-seconds] :as settings} :- CaSettings]
795-
(common/with-safe-write-lock inventory-lock inventory-lock-descriptor inventory-lock-timeout-seconds
796-
(write-cert-to-inventory-unlocked! cert settings)))
795+
(common/with-safe-write-lock inventory-lock inventory-lock-descriptor inventory-lock-timeout-seconds
796+
(write-cert-to-inventory-unlocked! cert settings)))
797797

798798
(schema/defn is-subject-in-inventory-row? :- schema/Bool
799799
[cn-subject :- utils/ValidX500Name
800800
[_serial _not-before _not-after row-subject] :- [schema/Str]]
801-
;; row subject always starts with a slash, so drop it.
802-
(if (some? row-subject)
803-
(= (subs row-subject 1) cn-subject)
804-
false))
801+
;; row subject always starts with a slash, so drop it.
802+
(if (some? row-subject)
803+
(= (subs row-subject 1) cn-subject)
804+
false))
805805

806806
(schema/defn is-not-expired? :- schema/Bool
807807
[now :- DateTime
@@ -831,7 +831,7 @@
831831
(if (fs/exists? cert-inventory)
832832
(with-open [inventory-reader (io/reader cert-inventory)]
833833
(let [inventory-rows (map extract-inventory-row-contents (line-seq inventory-reader))
834-
cn-subject (utils/cn certname)]
834+
cn-subject (utils/cn certname)]
835835
(some? (some (partial is-subject-in-inventory-row? cn-subject) inventory-rows))))
836836
(do
837837
(log/debug "Unable to find inventory file {0}" cert-inventory)
@@ -852,7 +852,7 @@
852852
(doall
853853
(->>
854854
(line-seq inventory-reader)
855-
(map extract-inventory-row-contents )
855+
(map extract-inventory-row-contents)
856856
(filter (partial is-expired? now))
857857
(map first)
858858
;; assume serials are base 16 strings
@@ -2465,10 +2465,11 @@
24652465
(write-cert-to-inventory-unlocked! signed-cert ca-settings)
24662466
(write-cert signed-cert (path-to-cert signeddir subject))
24672467
(delete-certificate-request! ca-settings subject)
2468+
(log/info (i18n/trs "Signed CSR for {0}" subject))
24682469
;; success case, add the host to the set of signed results
24692470
:signed))
24702471
(catch Throwable e
2471-
(log/debug e (i18n/trs "Failed in bulk signing for entry {0}" subject))
2472+
(log/error e (i18n/trs "Failed in bulk signing for entry {0}" subject))
24722473
;; failure case, add the host to the set of not signed results
24732474
:signing-errors)))
24742475

0 commit comments

Comments
 (0)