Skip to content

Commit

Permalink
Merge pull request #220 from NVIDIA/golang-version-upgrade
Browse files Browse the repository at this point in the history
go version updated to 1.21
  • Loading branch information
nvvfedorov authored Dec 20, 2023
2 parents 56aa52e + e30c0a7 commit 32e8016
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.21

- name: Build
run: make binary
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dcgm-exporter
!etc/
!deployment/
tags
.env
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MKDIR ?= mkdir
REGISTRY ?= nvidia

DCGM_VERSION := 3.3.0
GOLANG_VERSION := 1.18
GOLANG_VERSION := 1.21.5
VERSION := 3.2.0
FULL_VERSION := $(DCGM_VERSION)-$(VERSION)
OUTPUT := type=oci,dest=/tmp/dcgm-exporter.tar
Expand All @@ -36,7 +36,7 @@ binary:
cd cmd/dcgm-exporter; go build -ldflags "-X main.BuildVersion=${DCGM_VERSION}-${VERSION}"

test-main: $(NON_TEST_FILES) $(MAIN_TEST_FILES)
go test ./...
go test ./... -short

install: binary
install -m 755 cmd/dcgm-exporter/dcgm-exporter /usr/bin/dcgm-exporter
Expand Down
37 changes: 36 additions & 1 deletion docker/Dockerfile.ubi8
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
FROM nvcr.io/nvidia/cuda:12.2.2-base-ubi8 AS builder
ARG GOLANG_VERSION
FROM golang:$GOLANG_VERSION AS builder
WORKDIR /go/src/github.com/NVIDIA/dcgm-exporter
RUN set -eux; \
dnf clean expire-cache; \
dnf install -y go-toolset make wget
RUN dnf clean all

# Install Go official release
RUN set -eux; \
url=; \
arch=$(uname -m) && if [ "${arch}" = "x86_64" ]; then arch=amd64; fi && if [ "${arch}" = "aarch64" ]; then arch=arm64; fi; \
case "$arch" in \
'amd64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
;; \
'arm64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \
build=; \
if [ -z "$url" ]; then \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
build=1; \
url="https://dl.google.com/go/go${GOLANG_VERSION}.src.tar.gz"; \
echo >&2; \
echo >&2 "warning: current architecture ($arch) does not have a compatible Go binary release; will be building from source"; \
echo >&2; \
fi; \
wget -O go.tgz "$url" --progress=dot:giga; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz;
ENV GOTOOLCHAIN=local
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH"
ENV PATH $PATH:/usr/local/go/bin
COPY . .

RUN make binary check-format
Expand All @@ -11,6 +45,7 @@ LABEL io.k8s.display-name="NVIDIA DCGM Exporter"

ARG DCGM_VERSION

RUN dnf update --disablerepo=* --enablerepo=ubi-8-appstream-rpms --enablerepo=ubi-8-baseos-rpms -y && rm -rf /var/cache/yum
RUN dnf clean expire-cache && dnf install -y datacenter-gpu-manager-${DCGM_VERSION} libcap

COPY --from=builder /go/src/github.com/NVIDIA/dcgm-exporter/cmd/dcgm-exporter/dcgm-exporter /usr/bin/
Expand Down
45 changes: 42 additions & 3 deletions docker/Dockerfile.ubuntu20.04
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
ARG GOLANG_VERSION
FROM golang:$GOLANG_VERSION AS builder
FROM nvcr.io/nvidia/cuda:12.2.2-base-ubuntu20.04 AS builder
ARG GOLANG_VERSION=1.21.5
WORKDIR /go/src/github.com/NVIDIA/dcgm-exporter

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
pkg-config \
wget \
; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
url=; \
case "$arch" in \
'amd64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
;; \
'arm64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \
build=; \
if [ -z "$url" ]; then \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
build=1; \
url="https://dl.google.com/go/go${GOLANG_VERSION}.src.tar.gz"; \
echo >&2; \
echo >&2 "warning: current architecture ($arch) does not have a compatible Go binary release; will be building from source"; \
echo >&2; \
fi; \
wget -O go.tgz "$url" --progress=dot:giga; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz;
ENV GOTOOLCHAIN=local
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH"
ENV PATH $PATH:/usr/local/go/bin
COPY . .

RUN make binary check-format
Expand Down
35 changes: 18 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/NVIDIA/dcgm-exporter

go 1.18
go 1.21

replace (
k8s.io/api => k8s.io/api v0.20.2
Expand Down Expand Up @@ -31,19 +31,19 @@ require (
github.com/NVIDIA/go-dcgm v0.0.0-20231211194335-fa02d3a1c15f
github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20211102125545-5a2c58442e48
github.com/avast/retry-go/v4 v4.5.1
github.com/bits-and-blooms/bitset v1.2.1
github.com/gorilla/mux v1.8.0
github.com/bits-and-blooms/bitset v1.12.0
github.com/gorilla/mux v1.8.1
github.com/prometheus/common v0.45.0
github.com/prometheus/exporter-toolkit v0.10.0
github.com/sirupsen/logrus v1.9.0
github.com/prometheus/exporter-toolkit v0.11.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.3.0
google.golang.org/grpc v1.56.3
github.com/urfave/cli/v2 v2.26.0
google.golang.org/grpc v1.60.0
k8s.io/api v0.20.2
k8s.io/apimachinery v0.20.2
k8s.io/client-go v0.20.2
k8s.io/kubelet v0.20.2
k8s.io/kubernetes v0.0.0-00010101000000-000000000000
k8s.io/kubernetes v1.18.20
)

require (
Expand Down Expand Up @@ -74,16 +74,17 @@ require (
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 32e8016

Please sign in to comment.