Skip to content

Commit ae8fe34

Browse files
committed
fix lint error
1 parent de8b013 commit ae8fe34

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

launcher/internal/gpu/driverinstaller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package gpu
44
import (
55
"context"
66
"fmt"
7-
"log"
87
"os"
98
"os/exec"
109
"strings"
@@ -14,6 +13,7 @@ import (
1413
"github.com/containerd/containerd/cio"
1514
"github.com/containerd/containerd/namespaces"
1615
"github.com/containerd/containerd/oci"
16+
"github.com/google/go-tpm-tools/launcher/internal/logging"
1717
"github.com/google/go-tpm-tools/launcher/spec"
1818
"github.com/opencontainers/runtime-spec/specs-go"
1919
)
@@ -35,11 +35,11 @@ var supportedGpuTypes = []deviceinfo.GPUType{
3535
type DriverInstaller struct {
3636
cdClient *containerd.Client
3737
launchSpec spec.LaunchSpec
38-
logger *log.Logger
38+
logger logging.Logger
3939
}
4040

4141
// NewDriverInstaller instanciates an object of driver installer
42-
func NewDriverInstaller(cdClient *containerd.Client, launchSpec spec.LaunchSpec, logger *log.Logger) *DriverInstaller {
42+
func NewDriverInstaller(cdClient *containerd.Client, launchSpec spec.LaunchSpec, logger logging.Logger) *DriverInstaller {
4343
return &DriverInstaller{
4444
cdClient: cdClient,
4545
launchSpec: launchSpec,
@@ -69,11 +69,11 @@ func (di *DriverInstaller) InstallGPUDrivers(ctx context.Context) error {
6969
ctx = namespaces.WithNamespace(ctx, namespaces.Default)
7070
installerImageRef, err := getInstallerImageReference()
7171
if err != nil {
72-
di.logger.Printf("failed to get the installer container image reference: %v", err)
72+
di.logger.Info(fmt.Sprintf("failed to get the installer container image reference: %v", err))
7373
return err
7474
}
7575

76-
di.logger.Printf("cos gpu installer version : %s", installerImageRef)
76+
di.logger.Info(fmt.Sprintf("cos gpu installer version : %s", installerImageRef))
7777
image, err := di.cdClient.Pull(ctx, installerImageRef, containerd.WithPullUnpack)
7878
if err != nil {
7979
return fmt.Errorf("failed to pull installer image: %v", err)
@@ -95,7 +95,7 @@ func (di *DriverInstaller) InstallGPUDrivers(ctx context.Context) error {
9595

9696
hostname, err := os.Hostname()
9797
if err != nil {
98-
di.logger.Printf("cannot get hostname: %v", err)
98+
di.logger.Info(fmt.Sprintf("cannot get hostname: %v", err))
9999
}
100100

101101
container, err := di.cdClient.NewContainer(
@@ -138,11 +138,11 @@ func (di *DriverInstaller) InstallGPUDrivers(ctx context.Context) error {
138138
code, _, _ := status.Result()
139139

140140
if code != 0 {
141-
di.logger.Printf("Gpu driver installation task ended and returned non-zero status code %d", code)
141+
di.logger.Info(fmt.Sprintf("Gpu driver installation task ended and returned non-zero status code %d", code))
142142
return fmt.Errorf("gpu driver installation task ended with non-zero status code %d", code)
143143
}
144144

145-
di.logger.Println("Gpu driver installation task exited with status: 0")
145+
di.logger.Info("Gpu driver installation task exited with status: 0")
146146
return nil
147147
}
148148

launcher/launcher/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ func startLauncher(launchSpec spec.LaunchSpec, serialConsole *os.File) error {
192192
if launchSpec.InstallGpuDriver {
193193
if launchSpec.Experiments.EnableGpuDriverInstallation {
194194
installer := gpu.NewDriverInstaller(containerdClient, launchSpec, logger)
195-
err = installer.InstallGPUDrivers(ctx)
195+
err = installer.InstallGPUDrivers(context.Background())
196196
if err != nil {
197197
return fmt.Errorf("failed to install gpu drivers: %v", err)
198198
}
199199
} else {
200-
logger.Println("Gpu installation experiment flag is not enabled for this project. Ensure that it is enabled when tee-install-gpu-driver is set to true")
200+
logger.Info("Gpu installation experiment flag is not enabled for this project. Ensure that it is enabled when tee-install-gpu-driver is set to true")
201201
return fmt.Errorf("gpu installation experiment flag is not enabled")
202202
}
203203
}

0 commit comments

Comments
 (0)