Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
meetrajvala committed Dec 24, 2024
1 parent de8b013 commit ae8fe34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions launcher/internal/gpu/driverinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package gpu
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"strings"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/google/go-tpm-tools/launcher/internal/logging"
"github.com/google/go-tpm-tools/launcher/spec"
"github.com/opencontainers/runtime-spec/specs-go"
)
Expand All @@ -35,11 +35,11 @@ var supportedGpuTypes = []deviceinfo.GPUType{
type DriverInstaller struct {
cdClient *containerd.Client
launchSpec spec.LaunchSpec
logger *log.Logger
logger logging.Logger
}

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

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

hostname, err := os.Hostname()
if err != nil {
di.logger.Printf("cannot get hostname: %v", err)
di.logger.Info(fmt.Sprintf("cannot get hostname: %v", err))
}

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

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

di.logger.Println("Gpu driver installation task exited with status: 0")
di.logger.Info("Gpu driver installation task exited with status: 0")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions launcher/launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ func startLauncher(launchSpec spec.LaunchSpec, serialConsole *os.File) error {
if launchSpec.InstallGpuDriver {
if launchSpec.Experiments.EnableGpuDriverInstallation {
installer := gpu.NewDriverInstaller(containerdClient, launchSpec, logger)
err = installer.InstallGPUDrivers(ctx)
err = installer.InstallGPUDrivers(context.Background())
if err != nil {
return fmt.Errorf("failed to install gpu drivers: %v", err)
}
} else {
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")
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")
return fmt.Errorf("gpu installation experiment flag is not enabled")
}
}
Expand Down

0 comments on commit ae8fe34

Please sign in to comment.