Friday, February 02, 2024

Re: node_exporter vs syscall(2) removal

On 2024/02/02 18:11, Lucas Gabriel Vuotto wrote:
> Hi ports, Claudio,
>
> I noticed my for some time already that my -current node_exporters were
> returning no data for node_filesystem_* metrics. There has been a PR [0]
> that updates x/sys dep to a version that doesn't issue direct syscalls.
> I backported it, given that node_exporter releases are quite sporadic.
>
> I think it's one of my first times working with a Go port, and I'm not
> super about sure what I did. Even with the patched go.mod, I couldn't
> make modgo-gen-modules include x/sys v0.15.0 in the output. I don't know
> if there is a better approach.

modgo-gen-modules is not like the cargo equivalent, it just generates a
list of modules based on what it finds at proxy.golang.org. Don't expect
it to do anything sensible if you update the go.mod file in the wrkdir.

The way you have patched go.mod/go.sum makes sense.

...
> @@ -32,5 +33,6 @@ do-install:
> ${INSTALL_DATA} ${WRKSRC}/NOTICE ${PREFIX}/share/doc/node_exporter/
>
> .include "modules.inc"
> +MODGO_MODULES += golang.org/x/sys v0.15.0

I think it does make sense to add the MODGO_MODULES here to make it
more obvious that there's something funny going on, but I would add a
comment e.g.:

# updated from upstream's version, see patches

So I would go with this diff instead.

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/node_exporter/Makefile,v
diff -u -p -r1.20 Makefile
--- Makefile 22 Dec 2023 23:42:38 -0000 1.20
+++ Makefile 2 Feb 2024 18:19:14 -0000
@@ -2,6 +2,7 @@ COMMENT = prometheus exporter for hardw

MODGO_MODNAME = github.com/prometheus/node_exporter
MODGO_VERSION = v1.7.0
+REVISION = 0

DISTNAME = node_exporter-${MODGO_VERSION}

@@ -32,5 +33,7 @@ do-install:
${INSTALL_DATA} ${WRKSRC}/NOTICE ${PREFIX}/share/doc/node_exporter/

.include "modules.inc"
+# updated from upstream's old version, also see patches
+MODGO_MODULES += golang.org/x/sys v0.15.0

.include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/sysutils/node_exporter/distinfo,v
diff -u -p -r1.10 distinfo
--- distinfo 22 Dec 2023 23:42:38 -0000 1.10
+++ distinfo 2 Feb 2024 18:19:14 -0000
@@ -188,6 +188,8 @@ SHA256 (go_modules/golang.org/x/sys/@v/v
SHA256 (go_modules/golang.org/x/sys/@v/v0.12.0.mod) = 8DMzMJb+GY8xUd7tk/LeunTlC7/nc5E0BFvDt85KUCQ=
SHA256 (go_modules/golang.org/x/sys/@v/v0.13.0.mod) = 8DMzMJb+GY8xUd7tk/LeunTlC7/nc5E0BFvDt85KUCQ=
SHA256 (go_modules/golang.org/x/sys/@v/v0.13.0.zip) = PRSa/Jk5mANUN0wNR0Ydzb0dOYDrL3fmAwSyP+5vPTc=
+SHA256 (go_modules/golang.org/x/sys/@v/v0.15.0.mod) = 0iezJfYh9OvijTm6dz6pm4cPOTt8CcNFksNlsW3VYN4=
+SHA256 (go_modules/golang.org/x/sys/@v/v0.15.0.zip) = hhLrQWxznDsEzkjcvmVjLG+8QnAx/Zgcrs7sZBDR4fw=
SHA256 (go_modules/golang.org/x/sys/@v/v0.2.0.mod) = 8DMzMJb+GY8xUd7tk/LeunTlC7/nc5E0BFvDt85KUCQ=
SHA256 (go_modules/golang.org/x/sys/@v/v0.5.0.mod) = 8DMzMJb+GY8xUd7tk/LeunTlC7/nc5E0BFvDt85KUCQ=
SHA256 (go_modules/golang.org/x/sys/@v/v0.6.0.mod) = 8DMzMJb+GY8xUd7tk/LeunTlC7/nc5E0BFvDt85KUCQ=
@@ -430,6 +432,8 @@ SIZE (go_modules/golang.org/x/sys/@v/v0.
SIZE (go_modules/golang.org/x/sys/@v/v0.12.0.mod) = 33
SIZE (go_modules/golang.org/x/sys/@v/v0.13.0.mod) = 33
SIZE (go_modules/golang.org/x/sys/@v/v0.13.0.zip) = 1901653
+SIZE (go_modules/golang.org/x/sys/@v/v0.15.0.mod) = 33
+SIZE (go_modules/golang.org/x/sys/@v/v0.15.0.zip) = 1901954
SIZE (go_modules/golang.org/x/sys/@v/v0.2.0.mod) = 33
SIZE (go_modules/golang.org/x/sys/@v/v0.5.0.mod) = 33
SIZE (go_modules/golang.org/x/sys/@v/v0.6.0.mod) = 33
Index: patches/patch-go_mod
===================================================================
RCS file: patches/patch-go_mod
diff -N patches/patch-go_mod
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-go_mod 2 Feb 2024 18:19:14 -0000
@@ -0,0 +1,15 @@
+Update golang.org/x/sys to v0.15.0
+https://github.com/prometheus/node_exporter/pull/2863
+
+Index: go.mod
+--- go.mod.orig
++++ go.mod
+@@ -29,7 +29,7 @@ require (
+ github.com/prometheus/procfs v0.12.0
+ github.com/safchain/ethtool v0.3.0
+ golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
+- golang.org/x/sys v0.13.0
++ golang.org/x/sys v0.15.0
+ howett.net/plist v1.0.0
+ )
+
Index: patches/patch-go_sum
===================================================================
RCS file: patches/patch-go_sum
diff -N patches/patch-go_sum
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-go_sum 2 Feb 2024 18:19:14 -0000
@@ -0,0 +1,17 @@
+Update golang.org/x/sys to v0.15.0
+https://github.com/prometheus/node_exporter/pull/2863
+
+Index: go.sum
+--- go.sum.orig
++++ go.sum
+@@ -142,8 +142,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5
+ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+ golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+-golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
+-golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
++golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
++golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=

No comments:

Post a Comment