Skip to content

Commit c2c8560

Browse files
authored
Merge pull request #77 from VirrageS/januszm-update
Update Go version and libraries
2 parents 590457e + 9ec06e8 commit c2c8560

File tree

518 files changed

+73905
-19021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

518 files changed

+73905
-19021
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
22
#
33
# Redistribution and use in source and binary forms, with or without
44
# modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@ ARG CUDA_IMAGE=cuda
2828
ARG CUDA_VERSION=12.2.0
2929
ARG BASE_DIST=ubi8
3030

31-
FROM golang:1.18 AS builder
31+
FROM golang:1.20 AS builder
3232

3333
ENV GOOS=linux\
3434
GOARCH=amd64
@@ -54,7 +54,6 @@ LABEL description="See summary"
5454
RUN mkdir /licenses && mv /NGC-DL-CONTAINER-LICENSE /licenses/NGC-DL-CONTAINER-LICENSE
5555

5656
COPY --from=builder /go/src/kubevirt-gpu-device-plugin/nvidia-kubevirt-gpu-device-plugin /usr/bin/
57-
5857
COPY --from=builder /go/src/kubevirt-gpu-device-plugin/utils/pci.ids /usr/pci.ids
5958

6059
RUN yum update -y

go.mod

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,26 @@ go 1.18
44

55
require (
66
github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20211102125545-5a2c58442e48
7-
github.com/fsnotify/fsnotify v1.4.9
8-
github.com/golang/glog v1.1.0
9-
github.com/onsi/ginkgo v1.11.0
10-
github.com/onsi/gomega v1.7.0
7+
github.com/fsnotify/fsnotify v1.6.0
8+
github.com/onsi/ginkgo/v2 v2.11.0
9+
github.com/onsi/gomega v1.27.10
1110
google.golang.org/grpc v1.56.2
12-
k8s.io/kubelet v0.19.16
11+
k8s.io/klog/v2 v2.100.1
12+
k8s.io/kubelet v0.21.0
1313
)
1414

1515
require (
16+
github.com/go-logr/logr v1.2.4 // indirect
17+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
1618
github.com/gogo/protobuf v1.3.2 // indirect
1719
github.com/golang/protobuf v1.5.3 // indirect
18-
github.com/hpcloud/tail v1.0.0 // indirect
20+
github.com/google/go-cmp v0.5.9 // indirect
21+
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
1922
golang.org/x/net v0.12.0 // indirect
2023
golang.org/x/sys v0.10.0 // indirect
2124
golang.org/x/text v0.11.0 // indirect
22-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b // indirect
25+
golang.org/x/tools v0.11.0 // indirect
26+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230725213213-b022f6e96895 // indirect
2327
google.golang.org/protobuf v1.31.0 // indirect
24-
gopkg.in/fsnotify.v1 v1.4.7 // indirect
25-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
26-
gopkg.in/yaml.v2 v2.2.8 // indirect
27-
)
28-
29-
replace (
30-
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
31-
google.golang.org/protobuf => google.golang.org/protobuf v1.28.0
28+
gopkg.in/yaml.v3 v3.0.1 // indirect
3229
)

go.sum

Lines changed: 195 additions & 62 deletions
Large diffs are not rendered by default.

pkg/device_plugin/device_plugin.go

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -31,33 +31,32 @@ package device_plugin
3131
import (
3232
"bufio"
3333
"fmt"
34-
"io/ioutil"
3534
"log"
3635
"os"
3736
"path/filepath"
3837
"regexp"
3938
"strings"
4039

41-
"github.com/golang/glog"
40+
klog "k8s.io/klog/v2"
4241
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
4342
)
4443

4544
const (
4645
nvidiaVendorID = "10de"
4746
)
4847

49-
//Structure to hold details about Nvidia GPU Device
48+
// Structure to hold details about Nvidia GPU Device
5049
type NvidiaGpuDevice struct {
5150
addr string // PCI address of device
5251
}
5352

54-
//Key is iommu group id and value is a list of gpu devices part of the iommu group
53+
// Key is iommu group id and value is a list of gpu devices part of the iommu group
5554
var iommuMap map[string][]NvidiaGpuDevice
5655

57-
//Keys are the distinct Nvidia GPU device ids present on system and value is the list of all iommu group ids which are of that device id
56+
// Keys are the distinct Nvidia GPU device ids present on system and value is the list of all iommu group ids which are of that device id
5857
var deviceMap map[string][]string
5958

60-
//Key is vGPU Type and value is the list of Nvidia vGPUs of that type
59+
// Key is vGPU Type and value is the list of Nvidia vGPUs of that type
6160
var vGpuMap map[string][]NvidiaGpuDevice
6261

6362
// Key is the Nvidia GPU id and value is the list of associated vGPU ids
@@ -74,7 +73,6 @@ var readGpuIDForVgpu = readGpuIDForVgpuFunc
7473
var startVgpuDevicePlugin = startVgpuDevicePluginFunc
7574
var stop = make(chan struct{})
7675

77-
//
7876
func InitiateDevicePlugin() {
7977
//Identifies GPUs and represents it in appropriate structures
8078
createIommuDeviceMap()
@@ -84,7 +82,7 @@ func InitiateDevicePlugin() {
8482
createDevicePlugins()
8583
}
8684

87-
//Starts gpu pass through and vGPU device plugin
85+
// Starts gpu pass through and vGPU device plugin
8886
func createDevicePlugins() {
8987
var devicePlugins []*GenericDevicePlugin
9088
var vGpuDevicePlugins []*GenericVGpuDevicePlugin
@@ -160,7 +158,7 @@ func startVgpuDevicePluginFunc(dp *GenericVGpuDevicePlugin) error {
160158
return dp.Start(stop)
161159
}
162160

163-
//Discovers all Nvidia GPUs which are loaded with VFIO-PCI driver and creates corresponding maps
161+
// Discovers all Nvidia GPUs which are loaded with VFIO-PCI driver and creates corresponding maps
164162
func createIommuDeviceMap() {
165163
iommuMap = make(map[string][]NvidiaGpuDevice)
166164
deviceMap = make(map[string][]string)
@@ -214,7 +212,7 @@ func createIommuDeviceMap() {
214212
})
215213
}
216214

217-
//Discovers all Nvidia vGPUs configured on a node and creates corresponding maps
215+
// Discovers all Nvidia vGPUs configured on a node and creates corresponding maps
218216
func createVgpuIDMap() {
219217
vGpuMap = make(map[string][]NvidiaGpuDevice)
220218
gpuVgpuMap = make(map[string][]string)
@@ -248,46 +246,46 @@ func createVgpuIDMap() {
248246
})
249247
}
250248

251-
//Read a file to retrieve ID
249+
// Read a file to retrieve ID
252250
func readIDFromFileFunc(basePath string, deviceAddress string, property string) (string, error) {
253-
data, err := ioutil.ReadFile(filepath.Join(basePath, deviceAddress, property))
251+
data, err := os.ReadFile(filepath.Join(basePath, deviceAddress, property))
254252
if err != nil {
255-
glog.Errorf("Could not read %s for device %s: %s", property, deviceAddress, err)
253+
klog.Errorf("Could not read %s for device %s: %s", property, deviceAddress, err)
256254
return "", err
257255
}
258256
id := strings.Trim(string(data[2:]), "\n")
259257
return id, nil
260258
}
261259

262-
//Read a file link
260+
// Read a file link
263261
func readLinkFunc(basePath string, deviceAddress string, link string) (string, error) {
264262
path, err := os.Readlink(filepath.Join(basePath, deviceAddress, link))
265263
if err != nil {
266-
glog.Errorf("Could not read link %s for device %s: %s", link, deviceAddress, err)
264+
klog.Errorf("Could not read link %s for device %s: %s", link, deviceAddress, err)
267265
return "", err
268266
}
269267
_, file := filepath.Split(path)
270268
return file, nil
271269
}
272270

273-
//Read vGPU type name from the corresponding file
271+
// Read vGPU type name from the corresponding file
274272
func readVgpuIDFromFileFunc(basePath string, deviceAddress string, property string) (string, error) {
275-
reg, _ := regexp.Compile("\\s+")
276-
data, err := ioutil.ReadFile(filepath.Join(basePath, deviceAddress, property))
273+
reg := regexp.MustCompile("\\s+")
274+
data, err := os.ReadFile(filepath.Join(basePath, deviceAddress, property))
277275
if err != nil {
278-
glog.Errorf("Could not read %s for device %s: %s", property, deviceAddress, err)
276+
klog.Errorf("Could not read %s for device %s: %s", property, deviceAddress, err)
279277
return "", err
280278
}
281279
str := strings.Trim(string(data[:]), "\n")
282280
str = reg.ReplaceAllString(str, "_") // Replace all spaces with underscore
283281
return str, nil
284282
}
285283

286-
//Read GPU id for a specific vGPU
284+
// Read GPU id for a specific vGPU
287285
func readGpuIDForVgpuFunc(basePath string, deviceAddress string) (string, error) {
288286
path, err := os.Readlink(filepath.Join(basePath, deviceAddress))
289287
if err != nil {
290-
glog.Errorf("Could not read link for device %s: %s", deviceAddress, err)
288+
klog.Errorf("Could not read link for device %s: %s", deviceAddress, err)
291289
return "", err
292290
}
293291
splitStr := strings.Split(path, "/")
Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
/*
2-
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions
6-
* are met:
7-
* * Redistributions of source code must retain the above copyright
8-
* notice, this list of conditions and the following disclaimer.
9-
* * Redistributions in binary form must reproduce the above copyright
10-
* notice, this list of conditions and the following disclaimer in the
11-
* documentation and/or other materials provided with the distribution.
12-
* * Neither the name of NVIDIA CORPORATION nor the names of its
13-
* contributors may be used to endorse or promote products derived
14-
* from this software without specific prior written permission.
15-
*
16-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24-
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27-
*/
28-
29-
package device_plugin_test
30-
31-
import (
32-
"testing"
33-
34-
. "github.com/onsi/ginkgo"
35-
. "github.com/onsi/gomega"
36-
)
37-
38-
func TestDevicePlugin(t *testing.T) {
39-
//log.Log.SetIOWriter(GinkgoWriter)
40-
RegisterFailHandler(Fail)
41-
RunSpecs(t, "DevicePlugin Suite")
42-
}
1+
/*
2+
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of NVIDIA CORPORATION nor the names of its
13+
* contributors may be used to endorse or promote products derived
14+
* from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
package device_plugin_test
30+
31+
import (
32+
"testing"
33+
34+
. "github.com/onsi/ginkgo/v2"
35+
. "github.com/onsi/gomega"
36+
)
37+
38+
func TestDevicePlugin(t *testing.T) {
39+
RegisterFailHandler(Fail)
40+
RunSpecs(t, "DevicePlugin Suite")
41+
}

0 commit comments

Comments
 (0)