diff --git a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go index 39c5364e7b61..c2500205d532 100644 --- a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go +++ b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go @@ -97,8 +97,8 @@ type AutoscalingGceClient interface { FetchMigTargetSize(GceRef) (int64, error) FetchMigBasename(GceRef) (string, error) FetchMigInstances(GceRef) ([]cloudprovider.Instance, error) - FetchMigTemplateName(migRef GceRef) (string, error) - FetchMigTemplate(migRef GceRef, templateName string) (*gce.InstanceTemplate, error) + FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) + FetchMigTemplate(migRef GceRef, templateName string, regional bool) (*gce.InstanceTemplate, error) FetchMigsWithName(zone string, filter *regexp.Regexp) ([]string, error) FetchZones(region string) ([]string, error) FetchAvailableCpuPlatforms() (map[string][]string, error) @@ -550,26 +550,37 @@ func (client *autoscalingGceClientV1) FetchAvailableCpuPlatforms() (map[string][ return availableCpuPlatforms, nil } -func (client *autoscalingGceClientV1) FetchMigTemplateName(migRef GceRef) (string, error) { +func (client *autoscalingGceClientV1) FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) { registerRequest("instance_group_managers", "get") igm, err := client.gceService.InstanceGroupManagers.Get(migRef.Project, migRef.Zone, migRef.Name).Do() if err != nil { if err, ok := err.(*googleapi.Error); ok { if err.Code == http.StatusNotFound { - return "", errors.NewAutoscalerError(errors.NodeGroupDoesNotExistError, "%s", err.Error()) + return InstanceTemplateName{}, errors.NewAutoscalerError(errors.NodeGroupDoesNotExistError, "%s", err.Error()) } } - return "", err + return InstanceTemplateName{}, err } templateUrl, err := url.Parse(igm.InstanceTemplate) if err != nil { - return "", err + return InstanceTemplateName{}, err + } + regional, err := IsInstanceTemplateRegional(templateUrl.String()) + if err != nil { + return InstanceTemplateName{}, err } + _, templateName := path.Split(templateUrl.EscapedPath()) - return templateName, nil + return InstanceTemplateName{templateName, regional}, nil } -func (client *autoscalingGceClientV1) FetchMigTemplate(migRef GceRef, templateName string) (*gce.InstanceTemplate, error) { +func (client *autoscalingGceClientV1) FetchMigTemplate(migRef GceRef, templateName string, regional bool) (*gce.InstanceTemplate, error) { + if regional { + zoneHyphenIndex := strings.LastIndex(migRef.Zone, "-") + region := migRef.Zone[:zoneHyphenIndex] + registerRequest("region_instance_templates", "get") + return client.gceService.RegionInstanceTemplates.Get(migRef.Project, region, templateName).Do() + } registerRequest("instance_templates", "get") return client.gceService.InstanceTemplates.Get(migRef.Project, templateName).Do() } diff --git a/cluster-autoscaler/cloudprovider/gce/cache.go b/cluster-autoscaler/cloudprovider/gce/cache.go index 818f5d7aada9..63bee6018625 100644 --- a/cluster-autoscaler/cloudprovider/gce/cache.go +++ b/cluster-autoscaler/cloudprovider/gce/cache.go @@ -33,6 +33,13 @@ type MachineTypeKey struct { MachineTypeName string } +// InstanceTemplateName is used to store the name, and +// whether or not the instance template is regional +type InstanceTemplateName struct { + Name string + Regional bool +} + // GceCache is used for caching cluster resources state. // // It is needed to: @@ -66,7 +73,7 @@ type GceCache struct { machinesCache map[MachineTypeKey]MachineType migTargetSizeCache map[GceRef]int64 migBaseNameCache map[GceRef]string - instanceTemplateNameCache map[GceRef]string + instanceTemplateNameCache map[GceRef]InstanceTemplateName instanceTemplatesCache map[GceRef]*gce.InstanceTemplate } @@ -82,7 +89,7 @@ func NewGceCache() *GceCache { machinesCache: map[MachineTypeKey]MachineType{}, migTargetSizeCache: map[GceRef]int64{}, migBaseNameCache: map[GceRef]string{}, - instanceTemplateNameCache: map[GceRef]string{}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{}, } } @@ -330,23 +337,23 @@ func (gc *GceCache) InvalidateAllMigTargetSizes() { } // GetMigInstanceTemplateName returns the cached instance template ref for a mig GceRef -func (gc *GceCache) GetMigInstanceTemplateName(ref GceRef) (string, bool) { +func (gc *GceCache) GetMigInstanceTemplateName(ref GceRef) (InstanceTemplateName, bool) { gc.cacheMutex.Lock() defer gc.cacheMutex.Unlock() - templateName, found := gc.instanceTemplateNameCache[ref] + instanceTemplateName, found := gc.instanceTemplateNameCache[ref] if found { klog.V(5).Infof("Instance template names cache hit for %s", ref) } - return templateName, found + return instanceTemplateName, found } // SetMigInstanceTemplateName sets instance template ref for a mig GceRef -func (gc *GceCache) SetMigInstanceTemplateName(ref GceRef, templateName string) { +func (gc *GceCache) SetMigInstanceTemplateName(ref GceRef, instanceTemplateName InstanceTemplateName) { gc.cacheMutex.Lock() defer gc.cacheMutex.Unlock() - gc.instanceTemplateNameCache[ref] = templateName + gc.instanceTemplateNameCache[ref] = instanceTemplateName } // InvalidateMigInstanceTemplateName clears the instance template ref cache for a mig GceRef @@ -366,7 +373,7 @@ func (gc *GceCache) InvalidateAllMigInstanceTemplateNames() { defer gc.cacheMutex.Unlock() klog.V(5).Infof("Instance template names cache invalidated") - gc.instanceTemplateNameCache = map[GceRef]string{} + gc.instanceTemplateNameCache = map[GceRef]InstanceTemplateName{} } // GetMigInstanceTemplate returns the cached gce.InstanceTemplate for a mig GceRef diff --git a/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go b/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go index 609e6af91f06..d7c70fca2f6b 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go @@ -344,7 +344,7 @@ func newTestGceManager(t *testing.T, testServerURL string, regional bool) *gceMa {"us-central1-f", "n1-standard-1"}: {Name: "n1-standard-1", CPU: 1, Memory: 1}, }, migTargetSizeCache: map[GceRef]int64{}, - instanceTemplateNameCache: map[GceRef]string{}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{}, migBaseNameCache: map[GceRef]string{}, } diff --git a/cluster-autoscaler/cloudprovider/gce/gce_url.go b/cluster-autoscaler/cloudprovider/gce/gce_url.go index 7b0ab135a46c..80ef91207ff0 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_url.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_url.go @@ -78,6 +78,11 @@ func GenerateMigUrl(domainUrl string, ref GceRef) string { return fmt.Sprintf(migUrlTemplate, ref.Project, ref.Zone, ref.Name) } +// IsInstanceTemplateRegional determines whether or not an instance template is regional based on the url +func IsInstanceTemplateRegional(templateUrl string) (bool, error) { + return regexp.MatchString("(/projects/.*[A-Za-z0-9]+.*/regions/)", templateUrl) +} + func parseGceUrl(url, expectedResource string) (project string, zone string, name string, err error) { reg := regexp.MustCompile(fmt.Sprintf("https://.*/projects/.*/zones/.*/%s/.*", expectedResource)) errMsg := fmt.Errorf("wrong url: expected format /projects//zones//%s/, got %s", expectedResource, url) diff --git a/cluster-autoscaler/cloudprovider/gce/gce_url_test.go b/cluster-autoscaler/cloudprovider/gce/gce_url_test.go index 1317ef76e605..feee3b2432ae 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_url_test.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_url_test.go @@ -263,3 +263,34 @@ func TestParseMigUrl(t *testing.T) { }) } } + +func TestIsInstanceTemplateRegional(t *testing.T) { + tests := []struct { + name string + templateUrl string + expectRegional bool + wantErr error + }{ + { + name: "Has regional instance url", + templateUrl: "https://www.googleapis.com/compute/v1/projects/test-project/regions/us-central1/instanceTemplates/instance-template", + expectRegional: true, + }, + { + name: "Has global instance url", + templateUrl: "https://www.googleapis.com/compute/v1/projects/test-project/global/instanceTemplates/instance-template", + expectRegional: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + regional, err := IsInstanceTemplateRegional(tt.templateUrl) + assert.Equal(t, tt.wantErr, err) + if tt.wantErr != nil { + return + } + assert.Equal(t, tt.expectRegional, regional) + }) + } +} diff --git a/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go b/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go index abee9c4660ce..0757d1e68bd3 100644 --- a/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go +++ b/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go @@ -44,7 +44,7 @@ type MigInfoProvider interface { // GetMigBasename returns basename for given MIG ref GetMigBasename(migRef GceRef) (string, error) // GetMigInstanceTemplateName returns instance template name for given MIG ref - GetMigInstanceTemplateName(migRef GceRef) (string, error) + GetMigInstanceTemplateName(migRef GceRef) (InstanceTemplateName, error) // GetMigInstanceTemplate returns instance template for given MIG ref GetMigInstanceTemplate(migRef GceRef) (*gce.InstanceTemplate, error) // GetMigMachineType returns machine type used by a MIG. @@ -240,44 +240,44 @@ func (c *cachingMigInfoProvider) GetMigBasename(migRef GceRef) (string, error) { return basename, nil } -func (c *cachingMigInfoProvider) GetMigInstanceTemplateName(migRef GceRef) (string, error) { +func (c *cachingMigInfoProvider) GetMigInstanceTemplateName(migRef GceRef) (InstanceTemplateName, error) { c.migInfoMutex.Lock() defer c.migInfoMutex.Unlock() - templateName, found := c.cache.GetMigInstanceTemplateName(migRef) + instanceTemplateName, found := c.cache.GetMigInstanceTemplateName(migRef) if found { - return templateName, nil + return instanceTemplateName, nil } err := c.fillMigInfoCache() - templateName, found = c.cache.GetMigInstanceTemplateName(migRef) + instanceTemplateName, found = c.cache.GetMigInstanceTemplateName(migRef) if err == nil && found { - return templateName, nil + return instanceTemplateName, nil } // fallback to querying for single mig - templateName, err = c.gceClient.FetchMigTemplateName(migRef) + instanceTemplateName, err = c.gceClient.FetchMigTemplateName(migRef) if err != nil { c.migLister.HandleMigIssue(migRef, err) - return "", err + return InstanceTemplateName{}, err } - c.cache.SetMigInstanceTemplateName(migRef, templateName) - return templateName, nil + c.cache.SetMigInstanceTemplateName(migRef, instanceTemplateName) + return instanceTemplateName, nil } func (c *cachingMigInfoProvider) GetMigInstanceTemplate(migRef GceRef) (*gce.InstanceTemplate, error) { - templateName, err := c.GetMigInstanceTemplateName(migRef) + instanceTemplateName, err := c.GetMigInstanceTemplateName(migRef) if err != nil { return nil, err } template, found := c.cache.GetMigInstanceTemplate(migRef) - if found && template.Name == templateName { + if found && template.Name == instanceTemplateName.Name { return template, nil } - klog.V(2).Infof("Instance template of mig %v changed to %v", migRef.Name, templateName) - template, err = c.gceClient.FetchMigTemplate(migRef, templateName) + klog.V(2).Infof("Instance template of mig %v changed to %v", migRef.Name, instanceTemplateName.Name) + template, err = c.gceClient.FetchMigTemplate(migRef, instanceTemplateName.Name, instanceTemplateName.Regional) if err != nil { return nil, err } @@ -336,7 +336,12 @@ func (c *cachingMigInfoProvider) fillMigInfoCache() error { templateUrl, err := url.Parse(zoneMig.InstanceTemplate) if err == nil { _, templateName := path.Split(templateUrl.EscapedPath()) - c.cache.SetMigInstanceTemplateName(zoneMigRef, templateName) + regional, err := IsInstanceTemplateRegional(templateUrl.String()) + if err != nil { + klog.Errorf("Error parsing instance template url: %v; err=%v ", templateUrl.String(), err) + } else { + c.cache.SetMigInstanceTemplateName(zoneMigRef, InstanceTemplateName{templateName, regional}) + } } } } diff --git a/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go b/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go index adf2240329fb..c2c0f6f35981 100644 --- a/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go +++ b/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go @@ -48,13 +48,14 @@ var ( ) type mockAutoscalingGceClient struct { - fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTargetSize func(GceRef) (int64, error) - fetchMigBasename func(GceRef) (string, error) - fetchMigInstances func(GceRef) ([]cloudprovider.Instance, error) - fetchMigTemplateName func(GceRef) (string, error) - fetchMigTemplate func(GceRef, string) (*gce.InstanceTemplate, error) - fetchMachineType func(string, string) (*gce.MachineType, error) + fetchMigs func(string) ([]*gce.InstanceGroupManager, error) + fetchMigTargetSize func(GceRef) (int64, error) + fetchMigBasename func(GceRef) (string, error) + fetchMigInstances func(GceRef) ([]cloudprovider.Instance, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) + fetchMigTemplate func(GceRef, string, bool) (*gce.InstanceTemplate, error) + fetchMachineType func(string, string) (*gce.MachineType, error) + fetchListManagedInstancesResults func(GceRef) (string, error) } func (client *mockAutoscalingGceClient) FetchMachineType(zone, machineName string) (*gce.MachineType, error) { @@ -81,12 +82,12 @@ func (client *mockAutoscalingGceClient) FetchMigInstances(migRef GceRef) ([]clou return client.fetchMigInstances(migRef) } -func (client *mockAutoscalingGceClient) FetchMigTemplateName(migRef GceRef) (string, error) { +func (client *mockAutoscalingGceClient) FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) { return client.fetchMigTemplateName(migRef) } -func (client *mockAutoscalingGceClient) FetchMigTemplate(migRef GceRef, templateName string) (*gce.InstanceTemplate, error) { - return client.fetchMigTemplate(migRef, templateName) +func (client *mockAutoscalingGceClient) FetchMigTemplate(migRef GceRef, templateName string, regional bool) (*gce.InstanceTemplate, error) { + return client.fetchMigTemplate(migRef, templateName, regional) } func (client *mockAutoscalingGceClient) FetchMigsWithName(_ string, _ *regexp.Regexp) ([]string, error) { @@ -764,22 +765,29 @@ func TestGetMigInstanceTemplateName(t *testing.T) { instanceGroupManager := &gce.InstanceGroupManager{ Zone: mig.GceRef().Zone, Name: mig.GceRef().Name, - InstanceTemplate: templateName, + InstanceTemplate: "https://www.googleapis.com/compute/v1/projects/test-project/global/instanceTemplates/template-name", + } + + instanceGroupManagerRegional := &gce.InstanceGroupManager{ + Zone: mig.GceRef().Zone, + Name: mig.GceRef().Name, + InstanceTemplate: "https://www.googleapis.com/compute/v1/projects/test-project/regions/us-central1/instanceTemplates/template-name", } testCases := []struct { name string cache *GceCache fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTemplateName func(GceRef) (string, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) expectedTemplateName string + expectedRegion bool expectedErr error }{ { name: "template name in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, }, expectedTemplateName: templateName, }, @@ -789,18 +797,24 @@ func TestGetMigInstanceTemplateName(t *testing.T) { fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{instanceGroupManager}), expectedTemplateName: templateName, }, + { + name: "target size from cache fill, regional", + cache: emptyCache(), + fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{instanceGroupManagerRegional}), + expectedTemplateName: templateName, + }, { name: "cache fill without mig, fallback success", cache: emptyCache(), fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{}), - fetchMigTemplateName: fetchMigTemplateNameConst(templateName), + fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateName{templateName, false}), expectedTemplateName: templateName, }, { name: "cache fill failure, fallback success", cache: emptyCache(), fetchMigs: fetchMigsFail, - fetchMigTemplateName: fetchMigTemplateNameConst(templateName), + fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateName{templateName, false}), expectedTemplateName: templateName, }, { @@ -828,14 +842,14 @@ func TestGetMigInstanceTemplateName(t *testing.T) { migLister := NewMigLister(tc.cache) provider := NewCachingMigInfoProvider(tc.cache, migLister, client, mig.GceRef().Project, 1, 0*time.Second) - templateName, err := provider.GetMigInstanceTemplateName(mig.GceRef()) - cachedTemplateName, found := tc.cache.GetMigInstanceTemplateName(mig.GceRef()) + instanceTemplateName, err := provider.GetMigInstanceTemplateName(mig.GceRef()) + cachedInstanceTemplateName, found := tc.cache.GetMigInstanceTemplateName(mig.GceRef()) assert.Equal(t, tc.expectedErr, err) assert.Equal(t, tc.expectedErr == nil, found) if tc.expectedErr == nil { - assert.Equal(t, tc.expectedTemplateName, templateName) - assert.Equal(t, tc.expectedTemplateName, cachedTemplateName) + assert.Equal(t, tc.expectedTemplateName, instanceTemplateName.Name) + assert.Equal(t, tc.expectedTemplateName, cachedInstanceTemplateName.Name) } }) } @@ -856,8 +870,8 @@ func TestGetMigInstanceTemplate(t *testing.T) { name string cache *GceCache fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTemplateName func(GceRef) (string, error) - fetchMigTemplate func(GceRef, string) (*gce.InstanceTemplate, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) + fetchMigTemplate func(GceRef, string, bool) (*gce.InstanceTemplate, error) expectedTemplate *gce.InstanceTemplate expectedCachedTemplate *gce.InstanceTemplate expectedErr error @@ -866,7 +880,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "template in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): template}, }, expectedTemplate: template, @@ -876,7 +890,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache without template, fetch success", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), }, fetchMigTemplate: fetchMigTemplateConst(template), @@ -887,7 +901,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache with old template, fetch success", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, }, fetchMigTemplate: fetchMigTemplateConst(template), @@ -898,7 +912,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache without template, fetch failure", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), }, fetchMigTemplate: fetchMigTemplateFail, @@ -908,7 +922,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache with old template, fetch failure", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): templateName}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, }, fetchMigTemplate: fetchMigTemplateFail, @@ -1006,7 +1020,7 @@ func TestGetMigMachineType(t *testing.T) { }, } cache := &GceCache{ - instanceTemplateNameCache: map[GceRef]string{mig.GceRef(): "template"}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {"template", false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{ mig.GceRef(): { Name: "template", @@ -1131,7 +1145,7 @@ func emptyCache() *GceCache { instancesUpdateTime: make(map[GceRef]time.Time), migTargetSizeCache: make(map[GceRef]int64), migBaseNameCache: make(map[GceRef]string), - instanceTemplateNameCache: make(map[GceRef]string), + instanceTemplateNameCache: make(map[GceRef]InstanceTemplateName), instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), instancesFromUnknownMig: make(map[GceRef]bool), } @@ -1190,22 +1204,22 @@ func fetchMigBasenameConst(basename string) func(GceRef) (string, error) { } } -func fetchMigTemplateNameFail(_ GceRef) (string, error) { - return "", errFetchMigTemplateName +func fetchMigTemplateNameFail(_ GceRef) (InstanceTemplateName, error) { + return InstanceTemplateName{}, errFetchMigTemplateName } -func fetchMigTemplateNameConst(templateName string) func(GceRef) (string, error) { - return func(GceRef) (string, error) { - return templateName, nil +func fetchMigTemplateNameConst(instanceTemplateName InstanceTemplateName) func(GceRef) (InstanceTemplateName, error) { + return func(GceRef) (InstanceTemplateName, error) { + return instanceTemplateName, nil } } -func fetchMigTemplateFail(_ GceRef, _ string) (*gce.InstanceTemplate, error) { +func fetchMigTemplateFail(_ GceRef, _ string, _ bool) (*gce.InstanceTemplate, error) { return nil, errFetchMigTemplate } -func fetchMigTemplateConst(template *gce.InstanceTemplate) func(GceRef, string) (*gce.InstanceTemplate, error) { - return func(GceRef, string) (*gce.InstanceTemplate, error) { +func fetchMigTemplateConst(template *gce.InstanceTemplate) func(GceRef, string, bool) (*gce.InstanceTemplate, error) { + return func(GceRef, string, bool) (*gce.InstanceTemplate, error) { return template, nil } }