Skip to content

Commit

Permalink
Merge pull request #486 from elezar/cherry-pick-0.14.4
Browse files Browse the repository at this point in the history
Cherry pick change for 0.14.4 release
  • Loading branch information
elezar committed Jan 28, 2024
2 parents 0715067 + 05240e1 commit 5f516c9
Show file tree
Hide file tree
Showing 188 changed files with 5,830 additions and 13,864 deletions.
6 changes: 0 additions & 6 deletions .common-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ default:

variables:
GIT_SUBMODULE_STRATEGY: recursive
BUILDIMAGE: "${CI_REGISTRY_IMAGE}/build:${CI_COMMIT_SHORT_SHA}"
BUILD_MULTI_ARCH_IMAGES: "true"

stages:
- trigger
- image
- lint
- go-checks
- go-build
- unit-tests
- package-build
- image-build
- test
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Golang

on:
pull_request:
branches:
- main
- release-*
push:
branches:
- main
- release-*

jobs:
check:
# We disable checks on this branch.
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: -v --timeout 5m
skip-cache: true
test:
name: Unit test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- run: make test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build
run: make docker-build
75 changes: 75 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2024 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run this workflow on pull requests or merge to main/release branches
name: image

on:
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*
push:
branches:
- main
- release-*

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dist: [ubuntu20.04, ubi8]
steps:
- uses: actions/checkout@v4
name: Check out code
- name: Calculate build vars
id: vars
run: |
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
echo "${REPO_FULL_NAME}"
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
GENERATE_ARTIFACTS="false"
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
GENERATE_ARTIFACTS="false"
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
GENERATE_ARTIFACTS="true"
elif [[ "${{ github.event_name }}" == "push" ]]; then
GENERATE_ARTIFACTS="true"
fi
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
s- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-device-plugin
VERSION: ${COMMIT_SHORT_SHA}
run: |
echo "${VERSION}"
make -f deployments/container/Makefile build-${{ matrix.dist }}
63 changes: 0 additions & 63 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,6 @@
include:
- .common-ci.yml

build-dev-image:
stage: image
script:
- apk --no-cache add make bash
- make .build-image
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- make .push-build-image

.requires-build-image:
image: "${BUILDIMAGE}"

.go-check:
extends:
- .requires-build-image
stage: go-checks

fmt:
extends:
- .go-check
script:
- make assert-fmt

vet:
extends:
- .go-check
script:
- make vet

lint:
extends:
- .go-check
script:
- make lint
allow_failure: true

ineffassign:
extends:
- .go-check
script:
- make ineffassign
allow_failure: true

misspell:
extends:
- .go-check
script:
- make misspell

go-build:
extends:
- .requires-build-image
stage: go-build
script:
- make build

unit-tests:
extends:
- .requires-build-image
stage: unit-tests
script:
- make coverage


# Define the image build targets
.image-build:
stage: image-build
Expand Down
40 changes: 10 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ REGISTRY ?= nvidia
IMAGE_NAME = $(REGISTRY)/k8s-device-plugin
endif

BUILDIMAGE_TAG ?= golang$(GOLANG_VERSION)
BUILDIMAGE ?= $(IMAGE_NAME)-build:$(BUILDIMAGE_TAG)

EXAMPLES := $(patsubst ./examples/%/,%,$(sort $(dir $(wildcard ./examples/*/))))
EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES))

Expand Down Expand Up @@ -112,32 +109,14 @@ coverage: test
generate:
go generate $(MODULE)/...

# Generate an image for containerized builds
# Note: This image is local only
.PHONY: .build-image .pull-build-image .push-build-image
.build-image: docker/Dockerfile.devel
if [ x"$(SKIP_IMAGE_BUILD)" = x"" ]; then \
$(DOCKER) build \
--progress=plain \
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
--tag $(BUILDIMAGE) \
-f $(^) \
docker; \
fi

.pull-build-image:
$(DOCKER) pull $(BUILDIMAGE)

.push-build-image:
$(DOCKER) push $(BUILDIMAGE)

$(DOCKER_TARGETS): docker-%: .build-image
@echo "Running 'make $(*)' in docker container $(BUILDIMAGE)"
$(DOCKER_TARGETS): docker-%:
@echo "Running 'make $(*)' in container image $(BUILDIMAGE)"
$(DOCKER) run \
--rm \
-e GOCACHE=/tmp/.cache \
-v $(PWD):$(PWD) \
-w $(PWD) \
-e GOCACHE=/tmp/.cache/go \
-e GOMODCACHE=/tmp/.cache/gomod \
-v $(PWD):/work \
-w /work \
--user $$(id -u):$$(id -g) \
$(BUILDIMAGE) \
make $(*)
Expand All @@ -148,8 +127,9 @@ PHONY: .shell
$(DOCKER) run \
--rm \
-ti \
-e GOCACHE=/tmp/.cache \
-v $(PWD):$(PWD) \
-w $(PWD) \
-e GOCACHE=/tmp/.cache/go \
-e GOMODCACHE=/tmp/.cache/gomod \
-v $(PWD):/work \
-w /work \
--user $$(id -u):$$(id -g) \
$(BUILDIMAGE)
2 changes: 1 addition & 1 deletion api/config/v1/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package v1

import (
cdiapi "github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
cdiapi "tags.cncf.io/container-device-interface/pkg/cdi"
)

// Constants related to resource names
Expand Down
2 changes: 1 addition & 1 deletion cmd/nvidia-device-plugin/plugin-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package main
import (
"fmt"

"github.com/NVIDIA/go-nvlib/pkg/nvml"
spec "github.com/NVIDIA/k8s-device-plugin/api/config/v1"
"github.com/NVIDIA/k8s-device-plugin/internal/cdi"
"github.com/NVIDIA/k8s-device-plugin/internal/plugin/manager"
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvml"
)

// NewPluginManager creates an NVML-based plugin manager
Expand Down
19 changes: 9 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ replace (
)

require (
github.com/NVIDIA/go-gpuallocator v0.2.3
github.com/NVIDIA/nvidia-container-toolkit v1.13.3
github.com/container-orchestrated-devices/container-device-interface v0.5.4-0.20230111111500-5b3b5d81179a
github.com/NVIDIA/go-gpuallocator v0.3.1
github.com/NVIDIA/go-nvlib v0.0.0-20240109130712-11603560817a
github.com/NVIDIA/nvidia-container-toolkit v1.14.4-0.20231115203935-5d7ee25b37e2
github.com/fsnotify/fsnotify v1.6.0
github.com/google/uuid v1.3.1
github.com/google/uuid v1.4.0
github.com/prometheus/procfs v0.8.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.4.0
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230327171225-18ad7cd513cf
golang.org/x/net v0.18.0
google.golang.org/grpc v1.59.0
k8s.io/api v0.27.3
Expand All @@ -46,11 +45,11 @@ require (
k8s.io/klog/v2 v2.90.1
k8s.io/kubelet v0.0.0
sigs.k8s.io/yaml v1.3.0
tags.cncf.io/container-device-interface v0.6.2
)

require (
github.com/NVIDIA/go-nvml v0.12.0-1 // indirect
github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20201222072828-352eb4c503a7 // indirect
github.com/NVIDIA/go-nvml v0.12.0-1.0.20231020145430-e06766c5e74f // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
Expand All @@ -70,8 +69,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/opencontainers/runtime-spec v1.1.0-rc.2 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -93,4 +91,5 @@ require (
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
tags.cncf.io/container-device-interface/specs-go v0.6.0 // indirect
)
Loading

0 comments on commit 5f516c9

Please sign in to comment.