Skip to content

Commit

Permalink
set installer version as part of build step
Browse files Browse the repository at this point in the history
  • Loading branch information
meetrajvala committed Dec 23, 2024
1 parent 796705b commit 5fea8f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions launcher/image/preload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
readonly OEM_PATH='/usr/share/oem'
readonly CS_PATH="${OEM_PATH}/confidential_space"
readonly EXPERIMENTS_BINARY="confidential_space_experiments"
readonly GPU_INSTALLER_IMAGE_REF="cos_gpu_installer_image_reference"

copy_launcher() {
cp launcher "${CS_PATH}/cs_container_launcher"
Expand All @@ -19,6 +20,10 @@ setup_launcher_systemd_unit() {
cp exit_script.sh "${CS_PATH}/exit_script.sh"
}

set_cos_gpu_installer_image_reference() {
cos-extensions list -- --gpu-installer >> "${CS_PATH}"/"${GPU_INSTALLER_IMAGE_REF}"
}

append_cmdline() {
local arg="$1"
if [[ ! -d /mnt/disks/efi ]]; then
Expand Down Expand Up @@ -116,6 +121,7 @@ main() {
append_cmdline "cos.protected_stateful_partition=m"
# Increase wait timeout of the protected stateful partition.
append_cmdline "systemd.default_timeout_start_sec=900s"
set_cos_gpu_installer_image_reference

if [[ "${IMAGE_ENV}" == "debug" ]]; then
configure_systemd_units_for_debug
Expand Down
2 changes: 2 additions & 0 deletions launcher/internal/gpu/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ const (
InstallationHostDir = "/var/lib/nvidia"
// InstallationContainerDir is the directory where gpu drivers will be available on the workload container.
InstallationContainerDir = "/usr/local/nvidia"
// GpuInstallerImageReferenceFile is a filename which has the container image reference of cos_gpu_installer.
GpuInstallerImageReferenceFile = "cos_gpu_installer_image_reference"
)
7 changes: 5 additions & 2 deletions launcher/internal/gpu/driverinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"log"
"os"
"os/exec"
"path"
"strings"

"cos.googlesource.com/cos/tools.git/src/cmd/cos_gpu_installer/deviceinfo"
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/google/go-tpm-tools/launcher/launcherfile"
"github.com/google/go-tpm-tools/launcher/spec"
"github.com/opencontainers/runtime-spec/specs-go"
)
Expand Down Expand Up @@ -147,11 +149,12 @@ func (di *DriverInstaller) InstallGPUDrivers(ctx context.Context) error {
}

func getInstallerImageReference() (string, error) {
installerImageRefBytes, err := exec.Command("cos-extensions", "list", "--", "--gpu-installer").Output()
referenceFile := path.Join(launcherfile.HostTmpPath, GpuInstallerImageReferenceFile)
imageRefBytes, err := os.ReadFile(referenceFile)
if err != nil {
return "", fmt.Errorf("failed to get the cos-gpu-installer version: %v", err)
}
installerImageRef := strings.TrimSpace(string(installerImageRefBytes))
installerImageRef := strings.TrimSpace(string(imageRefBytes))
return installerImageRef, nil
}

Expand Down

0 comments on commit 5fea8f0

Please sign in to comment.