From b227b4acd481bf7dd7073e80031a51f3d16aea63 Mon Sep 17 00:00:00 2001 From: Kris Jacque Date: Mon, 30 Sep 2024 11:42:55 -0600 Subject: [PATCH 1/2] DAOS-16621 build: Fix Go versions in rpm/deb packaging (#15174) - Set Go minimum version to 1.21 in rpm and debian packaging spec files. - Update scons Go version check to use version in go.mod. - Add a reminder in go.mod file so we remember the packaging files when bumping the minimum Go version in the future. - Update Ubuntu 22.04 Dockerfile to get an appropriate version of Go. Required-githooks: true Signed-off-by: Kris Jacque --- debian/changelog | 6 ++++++ debian/control | 4 ++-- site_scons/site_tools/go_builder.py | 27 ++++++++++++++++++++++----- src/control/go.mod | 6 ++++-- utils/docker/Dockerfile.ubuntu | 3 +++ utils/rpms/daos.spec | 7 +++++-- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6891cea4737f..86add3a50837 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +daos (2.6.1-4) unstable; urgency=medium + [ Kris Jacque ] + * Bump minimum golang-go version to 1.21 + + -- Kris Jacque Fri, 04 Oct 2024 15:13:00 -0700 + daos (2.6.1-3) unstable; urgency=medium [ Phillip Henderson ] * Third release candidate for 2.6.1 diff --git a/debian/control b/debian/control index bdc377e6d94a..53f84d7f9c12 100644 --- a/debian/control +++ b/debian/control @@ -25,7 +25,7 @@ Build-Depends: debhelper (>= 10), dpdk-dev (>= 21.11.2), libisal-crypto-dev, libcunit1-dev, - golang-go (>= 1.18), + golang-go (>= 2:1.21), libboost-dev, libspdk-dev (>= 22.01.2), libipmctl-dev, @@ -117,7 +117,7 @@ Depends: python (>=3.8), python3, python-yaml, python3-yaml, ${shlibs:Depends}, ${misc:Depends}, daos-client (= ${binary:Version}), daos-admin (= ${binary:Version}), - golang-go (>=1.18), + golang-go (>= 2:1.21), libcapstone-dev Description: The Distributed Asynchronous Object Storage (DAOS) is an open-source software-defined object store designed from the ground up for diff --git a/site_scons/site_tools/go_builder.py b/site_scons/site_tools/go_builder.py index 33455f16b68b..8d5d86b90163 100644 --- a/site_scons/site_tools/go_builder.py +++ b/site_scons/site_tools/go_builder.py @@ -5,10 +5,9 @@ import re import subprocess # nosec B404 -from SCons.Script import Configure, Exit, File, GetOption, Glob, Scanner +from SCons.Script import Configure, Dir, Exit, File, GetOption, Glob, Scanner GO_COMPILER = 'go' -MIN_GO_VERSION = '1.18.0' include_re = re.compile(r'\#include [<"](\S+[>"])', re.M) @@ -49,6 +48,17 @@ def _scan_go_file(node, env, _path): return includes +def get_min_go_version(): + """Get go minimum version from go.mod""" + go_mod_path = os.path.join(Dir('#').abspath, "src", "control", "go.mod") + with open(go_mod_path, 'r') as f: + for line in f: + if line.startswith('go '): # e.g. "go 1.21" + parts = line.split() + return get_go_version("go" + parts[1]) + return None + + def get_go_version(output): """Capture only the version after 'go'""" ver_re = re.compile(r'go([0-9\.]+)') @@ -81,6 +91,13 @@ def _check_go_version(context): context.Result(0) return 0 + context.Display('Getting minimum go version... ') + min_go_version = get_min_go_version() + if min_go_version is None: + context.Result('no minimum go version found in go.mod') + return 0 + context.Display(min_go_version + '\n') + context.Display(f'Checking {env.d_go_bin} version... ') cmd_rc = subprocess.run([env.d_go_bin, 'version'], check=True, stdout=subprocess.PIPE) out = cmd_rc.stdout.decode('utf-8').strip() @@ -93,11 +110,11 @@ def _check_go_version(context): if go_version is None: context.Result(f'failed to get version from "{out}"') return 0 - if len([x for x, y in - zip(go_version.split('.'), MIN_GO_VERSION.split('.')) + if len([x for x, y in zip(go_version.split('.'), min_go_version.split('.')) if int(x) < int(y)]) > 0: - context.Result(f'{out} is too old (min supported: {MIN_GO_VERSION}) ') + context.Result(f'{out} is too old (min supported: {min_go_version}) ') return 0 + context.Result(go_version) return 1 diff --git a/src/control/go.mod b/src/control/go.mod index 364179c1fb65..dde1a47b7dad 100644 --- a/src/control/go.mod +++ b/src/control/go.mod @@ -1,9 +1,11 @@ module github.com/daos-stack/daos/src/control +// NB: When updating minimum Go build version, don't forget to update: +// - rpm packaging version checks: utils/rpms/daos.spec +// - debian packaging version checks: debian/control +// Scons uses this file to extract the minimum version. go 1.21 -toolchain go1.22.3 - require ( github.com/Jille/raft-grpc-transport v1.2.0 github.com/desertbit/grumble v1.1.3 diff --git a/utils/docker/Dockerfile.ubuntu b/utils/docker/Dockerfile.ubuntu index c7bf969e009c..4f6c138db023 100644 --- a/utils/docker/Dockerfile.ubuntu +++ b/utils/docker/Dockerfile.ubuntu @@ -22,6 +22,9 @@ RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/no-prompt RUN echo "APT::Install-Recommends \"false\";" > /etc/apt/apt.conf.d/no-recommends RUN apt-get update && \ apt-get upgrade && \ + apt-get install gpg-agent software-properties-common && \ + add-apt-repository ppa:longsleep/golang-backports && \ + apt-get update && \ chmod +x /tmp/install.sh && \ /tmp/install.sh && \ apt-get clean all diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 14fa74776a22..9ced041ec72b 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -81,7 +81,7 @@ BuildRequires: libyaml-devel BuildRequires: libcmocka-devel BuildRequires: valgrind-devel BuildRequires: systemd -BuildRequires: go >= 1.17 +BuildRequires: go >= 1.21 BuildRequires: pciutils-devel %if (0%{?rhel} >= 8) BuildRequires: numactl-devel @@ -218,7 +218,7 @@ Requires: dbench Requires: lbzip2 Requires: attr Requires: ior -Requires: go >= 1.18 +Requires: go >= 1.21 %if (0%{?suse_version} >= 1315) Requires: lua-lmod Requires: libcapstone-devel @@ -591,6 +591,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog +* Fri Oct 04 2024 Kris Jacque 2.6.1-4 +- Bump min supported go version to 1.21 + * Tue Oct 01 2024 Phillip Henderson 2.6.1-3 - Third release candidate for 2.6.1 From 631eb8f4315315bae9befb2595b0559d3fb6f994 Mon Sep 17 00:00:00 2001 From: Kris Jacque Date: Wed, 11 Dec 2024 14:05:01 -0700 Subject: [PATCH 2/2] Fix email address and RPM spec date/version Required-githooks: true Signed-off-by: Kris Jacque --- debian/changelog | 2 +- utils/rpms/daos.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index c1c2e5194164..ab4ebc856cf4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ daos (2.6.2-3) unstable; urgency=medium [ Kris Jacque ] * Bump minimum golang-go version to 1.21 - -- Kris Jacque Wed, 11 Dec 2024 11:43:00 -0700 + -- Kris Jacque Wed, 11 Dec 2024 11:43:00 -0700 daos (2.6.2-2) unstable; urgency=medium [ Phillip Henderson ] diff --git a/utils/rpms/daos.spec b/utils/rpms/daos.spec index 9491b2ec20ee..623365e83939 100644 --- a/utils/rpms/daos.spec +++ b/utils/rpms/daos.spec @@ -598,7 +598,7 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent # No files in a shim package %changelog -* Fri Oct 04 2024 Kris Jacque 2.6.1-5 +* Wed Dec 11 2024 Kris Jacque 2.6.2-3 - Bump min supported go version to 1.21 * Wed Nov 06 2024 Phillip Henderson 2.6.2-2