Subject: [PATCH 04/47] gnu: go-github-com-prometheus-client-golang: Update to 1.12.1.

From: Leo Nikkilä <[email-masked]>
Date: Fri, 25 Mar 2022 15:31:28 +0200

* gnu/packages/patches/go-github-com-prometheus-common-remove-readidletimeout.patch:
New patch, avoid updating go-golang-org-x-net just yet.
* gnu/packages/syncthing.scm (go-github-com-prometheus-client-golang):
Update to 1.12.1.
(go-github-com-prometheus-client-model): Update to 0.2.0.
(go-github-com-prometheus-common): Update to 0.32.1.
[patches]: Use patch.
(go-github-com-prometheus-procfs): Update to 0.7.3.
{unpack-test-data}, {delete-test-data}: New phases.
[arguments]: Enable tests.
---
 ...etheus-common-remove-readidletimeout.patch |  28 +++
 gnu/packages/syncthing.scm                    | 182 ++++++++++--------
 2 files changed, 130 insertions(+), 80 deletions(-)
 create mode 100644 gnu/packages/patches/go-github-com-prometheus-common-remove-readidletimeout.patch

diff --git a/gnu/packages/patches/go-github-com-prometheus-common-remove-readidletimeout.patch b/gnu/packages/patches/go-github-com-prometheus-common-remove-readidletimeout.patch
new file mode 100644
index 0000000000..4eea8ae5c5
--- /dev/null
+++ b/gnu/packages/patches/go-github-com-prometheus-common-remove-readidletimeout.patch
@@ -0,0 +1,28 @@
+ConfigureTransports was introduced in a newer version of
+go-golang-org-x-net:
+<https://github.com/golang/net/commit/08b38378de702b893ee869b94b32f833e2933bd2>
+
+Prior to this, Prometheus didn't configure ReadIdleTimeout:
+<https://github.com/prometheus/common/commit/b5c358997cbf126e8f8518cdc024c32da3996d48>
+
+It's somewhat unclear whether ReadIdleTimeout is absolutely required to
+work around the upstream issues with HTTP/2 mentioned in the codebase,
+however HTTP/2 can be disabled using enable_http2 if this is the case.
+
+diff --git a/config/http_config.go b/config/http_config.go
+index 4b87241..7698ba4 100644
+--- a/config/http_config.go
++++ b/config/http_config.go
+@@ -411,11 +411,10 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
+ 			// issues again, but will be removed once we are confident that
+ 			// things work as expected.
+ 
+-			http2t, err := http2.ConfigureTransports(rt.(*http.Transport))
++			err := http2.ConfigureTransport(rt.(*http.Transport))
+ 			if err != nil {
+ 				return nil, err
+ 			}
+-			http2t.ReadIdleTimeout = time.Minute
+ 		}
+ 
+ 		// If a authorization_credentials is provided, create a round tripper that will set the
diff --git a/gnu/packages/syncthing.scm b/gnu/packages/syncthing.scm
index 107b97e547..b9c72a3212 100644
--- a/gnu/packages/syncthing.scm
+++ b/gnu/packages/syncthing.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2021 Arun Isaac <[email-masked]>
 ;;; Copyright © 2022 John Kehayias <[email-masked]>
+;;; Copyright © 2022 Leo Nikkilä <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -819,34 +820,32 @@ (define-public go-github-com-beorn7-perks-quantile
       (license expat))))
 
 (define-public go-github-com-prometheus-client-model
-  (let ((commit "14fe0d1b01d4d5fc031dd4bec1823bd3ebbe8016")
-        (revision "2"))
-    (package
-      (name "go-github-com-prometheus-client-model")
-      (version (git-version "0.0.2" revision commit))
-      (source (origin
-                (method git-fetch)
-                (uri (git-reference
-                       (url "https://github.com/prometheus/client_model")
-                       (commit commit)))
-                (file-name (git-file-name name version))
-                (sha256
-                 (base32
-                  "0zdmk6rbbx39cvfz0r59v2jg5sg9yd02b4pds5n5llgvivi99550"))))
-      (build-system go-build-system)
-      (arguments
-       '(#:import-path "github.com/prometheus/client_model"
-         #:tests? #f
-         #:phases
-         (modify-phases %standard-phases
-           ;; Source-only package
-           (delete 'build))))
-      (propagated-inputs
-       (list go-github-com-golang-protobuf-proto))
-      (synopsis "Data model artifacts for Prometheus")
-      (description "This package provides data model artifacts for Prometheus.")
-      (home-page "https://github.com/prometheus/client_model")
-      (license asl2.0))))
+  (package
+    (name "go-github-com-prometheus-client-model")
+    (version "0.2.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/prometheus/client_model")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0jffnz94d6ff39fr96b5w8i8yk26pwnrfggzz8jhi8k0yihg2c9d"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "github.com/prometheus/client_model"
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         ;; Source-only package
+         (delete 'build))))
+    (propagated-inputs (list go-github-com-golang-protobuf-proto
+                             go-github-com-golang-protobuf-ptypes))
+    (synopsis "Data model artifacts for Prometheus")
+    (description "This package provides data model artifacts for Prometheus.")
+    (home-page "https://github.com/prometheus/client_model")
+    (license asl2.0)))
 
 (define-public go-github-com-matttproud-golang-protobuf-extensions-pbutil
   (let ((commit "c12348ce28de40eed0136aa2b644d0ee0650e56c")
@@ -879,65 +878,87 @@ (define-public go-github-com-matttproud-golang-protobuf-extensions-pbutil
       (license asl2.0))))
 
 (define-public go-github-com-prometheus-common
-    (package
-      (name "go-github-com-prometheus-common")
-      (version "0.4.1")
-      (source (origin
-                (method git-fetch)
-                (uri (git-reference
-                       (url "https://github.com/prometheus/common")
-                       (commit (string-append "v" version))))
-                (file-name (git-file-name name version))
-                (sha256
-                 (base32
-                  "0sf4sjdckblz1hqdfvripk3zyp8xq89w7q75kbsyg4c078af896s"))))
-      (build-system go-build-system)
-      (arguments
-       '(#:import-path "github.com/prometheus/common"
-         #:tests? #f
-         #:phases
-         (modify-phases %standard-phases
-           ;; Source-only package
-           (delete 'build))))
-      (propagated-inputs
-       (list go-github-com-golang-protobuf-proto
-             go-github-com-matttproud-golang-protobuf-extensions-pbutil
-             go-github-com-prometheus-client-model))
-      (synopsis "Prometheus metrics")
-      (description "This package provides tools for reading and writing
+  (package
+    (name "go-github-com-prometheus-common")
+    (version "0.32.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/prometheus/common")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0501dwlv427vr78c59h4z25vxzkzjx76haydjj4pql1sx44546vv"))
+              ;; This can be removed once go-golang-org-x-net is
+              ;; updated past 08b38378de702b893ee869b94b32f833e2933bd2.
+              (patches
+               (search-patches
+                "go-github-com-prometheus-common-remove-readidletimeout.patch"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "github.com/prometheus/common"
+                     #:tests? #f
+                     #:phases
+                     (modify-phases %standard-phases
+                       ;; Source-only package
+                       (delete 'build))))
+    (propagated-inputs
+     (list go-github-com-golang-protobuf-proto
+           go-github-com-golang-protobuf-ptypes
+           go-github-com-julienschmidt-httprouter
+           go-github-com-matttproud-golang-protobuf-extensions-pbutil
+           go-github-com-prometheus-client-model))
+    (synopsis "Prometheus metrics")
+    (description "This package provides tools for reading and writing
 Prometheus metrics.")
-      (home-page "https://github.com/prometheus/common")
-      (license asl2.0)))
+    (home-page "https://github.com/prometheus/common")
+    (license asl2.0)))
 
 (define-public go-github-com-prometheus-procfs
-    (package
-      (name "go-github-com-prometheus-procfs")
-      (version "0.0.4")
-      (source (origin
-                (method git-fetch)
-                (uri (git-reference
-                       (url "https://github.com/prometheus/procfs")
-                       (commit (string-append "v" version))))
-                (file-name (git-file-name name version))
-                (sha256
-                 (base32
-                  "1z5jq5rjala0a0di4nwk1rai0z9f73qwqj6mgcbpjbg2qknlb544"))))
-      (build-system go-build-system)
-      (arguments
-       '(#:import-path "github.com/prometheus/procfs"
-         ;; The tests require Go modules, which are not yet supported in Guix's
-         ;; Go build system.
-         #:tests? #f))
-      (synopsis "Go library for reading @file{/proc}")
-      (description "The @code{procfs} Go package provides functions to retrieve
+  (package
+    (name "go-github-com-prometheus-procfs")
+    (version "0.7.3")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/prometheus/procfs")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "00z7ghcb86y2ajx0xvwmn3d18nq4djmvmjn52crgm85gsl442lb4"))))
+    (build-system go-build-system)
+    (arguments
+     '(#:import-path "github.com/prometheus/procfs"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'check 'unpack-test-data
+           (lambda* (#:key tests? import-path #:allow-other-keys)
+             (when tests?
+               (with-directory-excursion (string-append "src/" import-path)
+                 (invoke "make" "fixtures")))
+             #t))
+         ;; We don't want to install fixtures and other test data.
+         (add-before 'install 'delete-test-data
+           (lambda* (#:key import-path #:allow-other-keys)
+              (with-directory-excursion (string-append "src/" import-path)
+                (delete-file "ttar")
+                (delete-file "fixtures.ttar")
+                (delete-file-recursively "fixtures"))
+             #t)))))
+    (propagated-inputs (list go-golang-org-x-sys))
+    (native-inputs (list go-github-com-google-go-cmp-cmp))
+    (synopsis "Go library for reading @file{/proc}")
+    (description "The @code{procfs} Go package provides functions to retrieve
 system, kernel, and process metrics from the @file{/proc} pseudo file system.")
-      (home-page "https://github.com/prometheus/procfs")
-      (license asl2.0)))
+    (home-page "https://github.com/prometheus/procfs")
+    (license asl2.0)))
 
 (define-public go-github-com-prometheus-client-golang
     (package
       (name "go-github-com-prometheus-client-golang")
-      (version "1.2.1")
+      (version "1.12.1")
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
@@ -946,7 +967,7 @@ (define-public go-github-com-prometheus-client-golang
                 (file-name (git-file-name name version))
                 (sha256
                  (base32
-                  "0zs49psk23n9z8wrl02d5vib5wclpym8kaxcy6n5pk696i419065"))))
+                  "0d46nindizpjgdygryc140fd94j1qfkzwyzwh9p2g3zp6v4fw0s1"))))
       (build-system go-build-system)
       (arguments
        '(#:tests? #f
@@ -958,6 +979,7 @@ (define-public go-github-com-prometheus-client-golang
       (propagated-inputs
        (list go-github-com-beorn7-perks-quantile
              go-github-com-golang-protobuf-proto
+             go-github-com-golang-protobuf-ptypes
              go-github-com-prometheus-client-model
              go-github-com-prometheus-common
              go-github-com-prometheus-procfs
-- 
2.34.0