cos-gpu-installer: download artifacts using new schema
This schema has been in place for over a year to satisfy arm64
requirements. New COS images are safe to use the new schema. Let's start
using the new schema to support other COS variants.
Example log snippet on cos-101:
```
I0914 20:14:53.577534 935 utils.go:88] Downloading NVIDIA-Linux-x86_64-470.199.02-custom.run from https://storage.googleapis.com/cos-tools/17162.279.34/lakitu/extensions/gpu/NVIDIA-Linux-x86_64-470.199.02-custom.run
I0914 20:14:57.179793 935 signature.go:32] Downloading driver signature for version 470.199.02
I0914 20:14:57.180131 935 utils.go:88] Downloading nvidia-drivers-470.199.02-signature.tar.gz from https://storage.googleapis.com/cos-tools/17162.279.34/lakitu/extensions/gpu/nvidia-drivers-470.199.02-signature.tar.gz
I0914 20:14:57.271293 935 signature.go:86] Decompressing signature /build/sign-gpu-driver/nvidia-drivers-470.199.02-signature.tar.gz
```
BUG=b/300487959
TEST=Build cos-gpu-installer; run it on 109, 105, 101, 97, and 93 with
the default version (`COS_GPU_INSTALLER=... cos-extensions install gpu`)
Change-Id: Id82d40e6950f5509f01cab3129d53319759bd63b
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/57268
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
Reviewed-by: Arnav Kansal <rnv@google.com>
Tested-by: Robert Kolchmeyer <rkolchmeyer@google.com>
diff --git a/src/cmd/cos_gpu_installer/internal/commands/install.go b/src/cmd/cos_gpu_installer/internal/commands/install.go
index eb5c8c3..9cbea92 100644
--- a/src/cmd/cos_gpu_installer/internal/commands/install.go
+++ b/src/cmd/cos_gpu_installer/internal/commands/install.go
@@ -150,7 +150,7 @@
"Those are the public COS artifacts buckets.")
f.StringVar(&c.gcsDownloadPrefix, "gcs-download-prefix", "",
"The GCS path prefix when downloading COS artifacts."+
- "If not set then the COS version build number (e.g. 13310.1041.38) will be used.")
+ "If not set then the COS build number and board (e.g. 13310.1041.38/lakitu) will be used.")
f.StringVar(&c.nvidiaInstallerURL, "nvidia-installer-url", "",
"A URL to an nvidia-installer to use for driver installation. This flag is mutually exclusive with `-version`. "+
"This flag must be used with `-allow-unsigned-driver`. This flag is only for debugging and testing.")
diff --git a/src/cmd/cos_gpu_installer/internal/commands/list.go b/src/cmd/cos_gpu_installer/internal/commands/list.go
index 4aed9ff..c4649ba 100644
--- a/src/cmd/cos_gpu_installer/internal/commands/list.go
+++ b/src/cmd/cos_gpu_installer/internal/commands/list.go
@@ -38,7 +38,7 @@
"For example, the default value is 'cos-tools' which is the public COS artifacts bucket.")
f.StringVar(&c.gcsDownloadPrefix, "gcs-download-prefix", "",
"The GCS path prefix when downloading COS artifacts."+
- "If not set then the COS version build number (e.g. 13310.1041.38) will be used.")
+ "If not set then the COS build number and board (e.g. 13310.1041.38/lakitu) will be used.")
f.BoolVar(&c.debug, "debug", false,
"Enable debug mode.")
}
diff --git a/src/pkg/cos/artifacts.go b/src/pkg/cos/artifacts.go
index 16592ac..f46defd 100644
--- a/src/pkg/cos/artifacts.go
+++ b/src/pkg/cos/artifacts.go
@@ -75,9 +75,9 @@
}
}
}
- // Use build number as the default GCS download prefix.
+ // Use {build number}/{board} as the default GCS download prefix.
if prefix == "" {
- prefix = e.BuildNumber()
+ prefix = path.Join(e.BuildNumber(), e.Board())
}
return &GCSDownloader{e, bucket, prefix}
}
diff --git a/src/pkg/cos/env_reader.go b/src/pkg/cos/env_reader.go
index 44fa948..e0d819f 100644
--- a/src/pkg/cos/env_reader.go
+++ b/src/pkg/cos/env_reader.go
@@ -59,6 +59,9 @@
// ReleaseTrack returns the COS release track.
func (c *EnvReader) ReleaseTrack() string { return c.lsbRelease[releaseTrack] }
+// Board returns the COS board name. Retrieved from /etc/lsb-release.
+func (c *EnvReader) Board() string { return c.lsbRelease["CHROMEOS_RELEASE_BOARD"] }
+
// BuildNumber returns COS build number.
func (c *EnvReader) BuildNumber() string { return c.osRelease[buildID] }