Merge pull request #9356 from GennadySpb/remove-platform-validation-for-instances-with-gpu

Do not require 'gpu-standard-v1' platform_id for any GPU-based config.
This commit is contained in:
Megan Marsh 2020-06-03 14:52:36 -07:00 committed by GitHub
commit f520ced2a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 16 deletions

View File

@ -248,11 +248,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.FolderID = os.Getenv("YC_FOLDER_ID")
}
if c.PlatformID != defaultGpuPlatformID && c.InstanceGpus != 0 {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("for instances with gpu platform_id must be specified as `%s`", defaultGpuPlatformID))
}
if c.Token == "" && c.ServiceAccountKeyFile == "" {
errs = packer.MultiErrorAppend(
errs, errors.New("a token or service account key file must be specified"))

View File

@ -231,20 +231,10 @@ func TestGpuDefaultPlatformID(t *testing.T) {
var c Config
c.Prepare(raw)
if c.PlatformID != "gpu-standard-v1" {
t.Fatalf("expected 'gpu-standard-v1', but got '%s'", c.PlatformID)
t.Fatalf("expected 'gpu-standard-v1' as default platform_id for instance with GPU(s), but got '%s'", c.PlatformID)
}
}
func TestGpuWrongPlatformID(t *testing.T) {
raw := testConfig(t)
raw["instance_gpus"] = 1
raw["platform_id"] = "standard-v1"
var c Config
warns, errs := c.Prepare(raw)
testConfigErr(t, warns, errs, "incompatible GPU platform_id")
}
// Helper stuff below
func testConfig(t *testing.T) (config map[string]interface{}) {