From cd3ab2c4179a4b248645d78037705efa878f7185 Mon Sep 17 00:00:00 2001 From: Edwinhr716 Date: Wed, 28 Feb 2024 22:03:30 +0000 Subject: [PATCH] changed InstanceTemplateNameType to InstanceTemplateName --- .../gce/autoscaling_gce_client.go | 14 ++-- cluster-autoscaler/cloudprovider/gce/cache.go | 20 +++--- .../cloudprovider/gce/gce_manager_test.go | 2 +- .../cloudprovider/gce/mig_info_provider.go | 34 ++++----- .../gce/mig_info_provider_test.go | 71 +++++++++++-------- 5 files changed, 76 insertions(+), 65 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go index f24c05729dba..64b85272b19a 100644 --- a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go +++ b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go @@ -103,7 +103,7 @@ type AutoscalingGceClient interface { FetchMigTargetSize(GceRef) (int64, error) FetchMigBasename(GceRef) (string, error) FetchMigInstances(GceRef) ([]GceInstance, error) - FetchMigTemplateName(migRef GceRef) (InstanceTemplateNameType, 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) @@ -580,28 +580,28 @@ func (client *autoscalingGceClientV1) FetchAvailableCpuPlatforms() (map[string][ return availableCpuPlatforms, nil } -func (client *autoscalingGceClientV1) FetchMigTemplateName(migRef GceRef) (InstanceTemplateNameType, 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 InstanceTemplateNameType{}, errors.NewAutoscalerError(errors.NodeGroupDoesNotExistError, "%s", err.Error()) + return InstanceTemplateName{}, errors.NewAutoscalerError(errors.NodeGroupDoesNotExistError, "%s", err.Error()) } } - return InstanceTemplateNameType{}, err + return InstanceTemplateName{}, err } templateUrl, err := url.Parse(igm.InstanceTemplate) if err != nil { - return InstanceTemplateNameType{}, err + return InstanceTemplateName{}, err } regional, err := regexp.MatchString("(/projects/.*[A-Za-z0-9]+.*/regions/)", templateUrl.String()) if err != nil { - return InstanceTemplateNameType{}, err + return InstanceTemplateName{}, err } _, templateName := path.Split(templateUrl.EscapedPath()) - return InstanceTemplateNameType{templateName, regional}, nil + return InstanceTemplateName{templateName, regional}, nil } func (client *autoscalingGceClientV1) FetchMigTemplate(migRef GceRef, templateName string, regional bool) (*gce.InstanceTemplate, error) { diff --git a/cluster-autoscaler/cloudprovider/gce/cache.go b/cluster-autoscaler/cloudprovider/gce/cache.go index 166c59bf3ffe..d31f20dd37b9 100644 --- a/cluster-autoscaler/cloudprovider/gce/cache.go +++ b/cluster-autoscaler/cloudprovider/gce/cache.go @@ -33,9 +33,9 @@ type MachineTypeKey struct { MachineTypeName string } -// InstanceTemplateNameType is used to store the name, and +// InstanceTemplateName is used to store the name, and // whether or not the instance template is regional -type InstanceTemplateNameType struct { +type InstanceTemplateName struct { Name string Regional bool } @@ -74,7 +74,7 @@ type GceCache struct { migTargetSizeCache map[GceRef]int64 migBaseNameCache map[GceRef]string listManagedInstancesResultsCache map[GceRef]string - instanceTemplateNameCache map[GceRef]InstanceTemplateNameType + instanceTemplateNameCache map[GceRef]InstanceTemplateName instanceTemplatesCache map[GceRef]*gce.InstanceTemplate kubeEnvCache map[GceRef]KubeEnv } @@ -92,7 +92,7 @@ func NewGceCache() *GceCache { migTargetSizeCache: map[GceRef]int64{}, migBaseNameCache: map[GceRef]string{}, listManagedInstancesResultsCache: map[GceRef]string{}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{}, kubeEnvCache: map[GceRef]KubeEnv{}, } @@ -341,23 +341,23 @@ func (gc *GceCache) InvalidateAllMigTargetSizes() { } // GetMigInstanceTemplateName returns the cached instance template ref for a mig GceRef -func (gc *GceCache) GetMigInstanceTemplateName(ref GceRef) (InstanceTemplateNameType, bool) { +func (gc *GceCache) GetMigInstanceTemplateName(ref GceRef) (InstanceTemplateName, bool) { gc.cacheMutex.Lock() defer gc.cacheMutex.Unlock() - instanceTemplateNameType, found := gc.instanceTemplateNameCache[ref] + instanceTemplateName, found := gc.instanceTemplateNameCache[ref] if found { klog.V(5).Infof("Instance template names cache hit for %s", ref) } - return instanceTemplateNameType, found + return instanceTemplateName, found } // SetMigInstanceTemplateName sets instance template ref for a mig GceRef -func (gc *GceCache) SetMigInstanceTemplateName(ref GceRef, instanceTemplateNameType InstanceTemplateNameType) { +func (gc *GceCache) SetMigInstanceTemplateName(ref GceRef, instanceTemplateName InstanceTemplateName) { gc.cacheMutex.Lock() defer gc.cacheMutex.Unlock() - gc.instanceTemplateNameCache[ref] = instanceTemplateNameType + gc.instanceTemplateNameCache[ref] = instanceTemplateName } // InvalidateMigInstanceTemplateName clears the instance template ref cache for a mig GceRef @@ -377,7 +377,7 @@ func (gc *GceCache) InvalidateAllMigInstanceTemplateNames() { defer gc.cacheMutex.Unlock() klog.V(5).Infof("Instance template names cache invalidated") - gc.instanceTemplateNameCache = map[GceRef]InstanceTemplateNameType{} + 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 55256acca4ab..207c04deb9b3 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]InstanceTemplateNameType{}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{}, kubeEnvCache: map[GceRef]KubeEnv{}, migBaseNameCache: map[GceRef]string{}, diff --git a/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go b/cluster-autoscaler/cloudprovider/gce/mig_info_provider.go index b0a7b59ce9e3..38a632832d5a 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) (InstanceTemplateNameType, error) + GetMigInstanceTemplateName(migRef GceRef) (InstanceTemplateName, error) // GetMigInstanceTemplate returns instance template for given MIG ref GetMigInstanceTemplate(migRef GceRef) (*gce.InstanceTemplate, error) // GetMigKubeEnv returns kube-env for given MIG ref @@ -244,44 +244,44 @@ func (c *cachingMigInfoProvider) GetMigBasename(migRef GceRef) (string, error) { return basename, nil } -func (c *cachingMigInfoProvider) GetMigInstanceTemplateName(migRef GceRef) (InstanceTemplateNameType, error) { +func (c *cachingMigInfoProvider) GetMigInstanceTemplateName(migRef GceRef) (InstanceTemplateName, error) { c.migInfoMutex.Lock() defer c.migInfoMutex.Unlock() - instanceTemplateNameType, found := c.cache.GetMigInstanceTemplateName(migRef) + instanceTemplateName, found := c.cache.GetMigInstanceTemplateName(migRef) if found { - return instanceTemplateNameType, nil + return instanceTemplateName, nil } err := c.fillMigInfoCache() - instanceTemplateNameType, found = c.cache.GetMigInstanceTemplateName(migRef) + instanceTemplateName, found = c.cache.GetMigInstanceTemplateName(migRef) if err == nil && found { - return instanceTemplateNameType, nil + return instanceTemplateName, nil } // fallback to querying for single mig - instanceTemplateNameType, err = c.gceClient.FetchMigTemplateName(migRef) + instanceTemplateName, err = c.gceClient.FetchMigTemplateName(migRef) if err != nil { c.migLister.HandleMigIssue(migRef, err) - return InstanceTemplateNameType{}, err + return InstanceTemplateName{}, err } - c.cache.SetMigInstanceTemplateName(migRef, instanceTemplateNameType) - return instanceTemplateNameType, nil + c.cache.SetMigInstanceTemplateName(migRef, instanceTemplateName) + return instanceTemplateName, nil } func (c *cachingMigInfoProvider) GetMigInstanceTemplate(migRef GceRef) (*gce.InstanceTemplate, error) { - instanceTemplateNameType, 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 == instanceTemplateNameType.Name { + if found && template.Name == instanceTemplateName.Name { return template, nil } - klog.V(2).Infof("Instance template of mig %v changed to %v", migRef.Name, instanceTemplateNameType.Name) - template, err = c.gceClient.FetchMigTemplate(migRef, instanceTemplateNameType.Name, instanceTemplateNameType.Regional) + 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 } @@ -290,13 +290,13 @@ func (c *cachingMigInfoProvider) GetMigInstanceTemplate(migRef GceRef) (*gce.Ins } func (c *cachingMigInfoProvider) GetMigKubeEnv(migRef GceRef) (KubeEnv, error) { - instanceTemplateNameType, err := c.GetMigInstanceTemplateName(migRef) + instanceTemplateName, err := c.GetMigInstanceTemplateName(migRef) if err != nil { return KubeEnv{}, err } kubeEnv, kubeEnvFound := c.cache.GetMigKubeEnv(migRef) - if kubeEnvFound && kubeEnv.templateName == instanceTemplateNameType.Name { + if kubeEnvFound && kubeEnv.templateName == instanceTemplateName.Name { return kubeEnv, nil } @@ -365,7 +365,7 @@ func (c *cachingMigInfoProvider) fillMigInfoCache() error { if err == nil { _, templateName := path.Split(templateUrl.EscapedPath()) regional, _ := regexp.MatchString("(/projects/.*[A-Za-z0-9]+.*/regions/)", templateUrl.String()) - c.cache.SetMigInstanceTemplateName(zoneMigRef, InstanceTemplateNameType{templateName, regional}) + 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 380ad7f4a8ae..f01d928c8dbf 100644 --- a/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go +++ b/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go @@ -53,7 +53,7 @@ type mockAutoscalingGceClient struct { fetchMigTargetSize func(GceRef) (int64, error) fetchMigBasename func(GceRef) (string, error) fetchMigInstances func(GceRef) ([]GceInstance, error) - fetchMigTemplateName func(GceRef) (InstanceTemplateNameType, error) + fetchMigTemplate func(GceRef, string, bool) (*gce.InstanceTemplate, error) fetchMigTemplate func(GceRef, string) (*gce.InstanceTemplate, error) fetchMachineType func(string, string) (*gce.MachineType, error) fetchListManagedInstancesResults func(GceRef) (string, error) @@ -87,7 +87,7 @@ func (client *mockAutoscalingGceClient) FetchMigInstances(migRef GceRef) ([]GceI return client.fetchMigInstances(migRef) } -func (client *mockAutoscalingGceClient) FetchMigTemplateName(migRef GceRef) (InstanceTemplateNameType, error) { +func (client *mockAutoscalingGceClient) FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) { return client.fetchMigTemplateName(migRef) } @@ -859,7 +859,7 @@ func TestGetMigInstanceTemplateName(t *testing.T) { name string cache *GceCache fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTemplateName func(GceRef) (InstanceTemplateNameType, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) expectedTemplateName string expectedErr error }{ @@ -867,7 +867,7 @@ func TestGetMigInstanceTemplateName(t *testing.T) { name: "template name in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, }, expectedTemplateName: templateName, }, @@ -881,14 +881,14 @@ func TestGetMigInstanceTemplateName(t *testing.T) { name: "cache fill without mig, fallback success", cache: emptyCache(), fetchMigs: fetchMigsConst([]*gce.InstanceGroupManager{}), - fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateNameType{templateName, false}), + fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateName{templateName, false}), expectedTemplateName: templateName, }, { name: "cache fill failure, fallback success", cache: emptyCache(), fetchMigs: fetchMigsFail, - fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateNameType{templateName, false}), + fetchMigTemplateName: fetchMigTemplateNameConst(InstanceTemplateName{templateName, false}), expectedTemplateName: templateName, }, { @@ -916,14 +916,14 @@ func TestGetMigInstanceTemplateName(t *testing.T) { migLister := NewMigLister(tc.cache) provider := NewCachingMigInfoProvider(tc.cache, migLister, client, mig.GceRef().Project, 1, 0*time.Second) - instanceTemplateNameType, err := provider.GetMigInstanceTemplateName(mig.GceRef()) - cachedInstanceTemplateNameType, 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, instanceTemplateNameType.Name) - assert.Equal(t, tc.expectedTemplateName, cachedInstanceTemplateNameType.Name) + assert.Equal(t, tc.expectedTemplateName, instanceTemplateName.Name) + assert.Equal(t, tc.expectedTemplateName, cachedInstanceTemplateName.Name) } }) } @@ -944,7 +944,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name string cache *GceCache fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTemplateName func(GceRef) (InstanceTemplateNameType, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) fetchMigTemplate func(GceRef, string, bool) (*gce.InstanceTemplate, error) expectedTemplate *gce.InstanceTemplate expectedCachedTemplate *gce.InstanceTemplate @@ -954,7 +954,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "template in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): template}, }, expectedTemplate: template, @@ -964,7 +964,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache without template, fetch success", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), }, fetchMigTemplate: fetchMigTemplateConst(template), @@ -975,7 +975,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]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, }, fetchMigTemplate: fetchMigTemplateConst(template), @@ -986,7 +986,7 @@ func TestGetMigInstanceTemplate(t *testing.T) { name: "cache without template, fetch failure", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), }, fetchMigTemplate: fetchMigTemplateFail, @@ -996,7 +996,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]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, }, fetchMigTemplate: fetchMigTemplateFail, @@ -1075,7 +1075,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name string cache *GceCache fetchMigs func(string) ([]*gce.InstanceGroupManager, error) - fetchMigTemplateName func(GceRef) (InstanceTemplateNameType, error) + fetchMigTemplateName func(GceRef) (InstanceTemplateName, error) fetchMigTemplate func(GceRef, string, bool) (*gce.InstanceTemplate, error) expectedKubeEnv KubeEnv expectedCachedKubeEnv KubeEnv @@ -1085,7 +1085,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "kube-env in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, kubeEnvCache: map[GceRef]KubeEnv{mig.GceRef(): kubeEnv}, }, expectedKubeEnv: kubeEnv, @@ -1095,7 +1095,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache without kube-env, template in cache", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): template}, kubeEnvCache: make(map[GceRef]KubeEnv), }, @@ -1106,7 +1106,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache without kube-env, fetch success", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), kubeEnvCache: make(map[GceRef]KubeEnv), }, @@ -1118,7 +1118,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache with old kube-env, new template cached", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): template}, kubeEnvCache: map[GceRef]KubeEnv{mig.GceRef(): oldKubeEnv}, }, @@ -1129,7 +1129,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache with old kube-env, fetch success", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, kubeEnvCache: map[GceRef]KubeEnv{mig.GceRef(): oldKubeEnv}, }, @@ -1141,7 +1141,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache without kube-env, fetch failure", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), kubeEnvCache: make(map[GceRef]KubeEnv), }, @@ -1152,7 +1152,7 @@ func TestGetMigInstanceKubeEnv(t *testing.T) { name: "cache with old kube-env, fetch failure", cache: &GceCache{ migs: map[GceRef]Mig{mig.GceRef(): mig}, - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {templateName, false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {templateName, false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{mig.GceRef(): oldTemplate}, kubeEnvCache: map[GceRef]KubeEnv{mig.GceRef(): oldKubeEnv}, }, @@ -1251,7 +1251,7 @@ func TestGetMigMachineType(t *testing.T) { }, } cache := &GceCache{ - instanceTemplateNameCache: map[GceRef]InstanceTemplateNameType{mig.GceRef(): {"template", false}}, + instanceTemplateNameCache: map[GceRef]InstanceTemplateName{mig.GceRef(): {"template", false}}, instanceTemplatesCache: map[GceRef]*gce.InstanceTemplate{ mig.GceRef(): { Name: "template", @@ -1371,6 +1371,7 @@ func (f *fakeTime) Now() time.Time { func emptyCache() *GceCache { return &GceCache{ +<<<<<<< HEAD migs: map[GceRef]Mig{mig.GceRef(): mig}, instances: make(map[GceRef][]GceInstance), instancesUpdateTime: make(map[GceRef]time.Time), @@ -1380,6 +1381,16 @@ func emptyCache() *GceCache { instanceTemplateNameCache: make(map[GceRef]InstanceTemplateNameType), instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), instancesFromUnknownMig: make(map[GceRef]bool), +======= + migs: map[GceRef]Mig{mig.GceRef(): mig}, + instances: make(map[GceRef][]GceInstance), + instancesUpdateTime: make(map[GceRef]time.Time), + migTargetSizeCache: make(map[GceRef]int64), + migBaseNameCache: make(map[GceRef]string), + instanceTemplateNameCache: make(map[GceRef]InstanceTemplateName), + instanceTemplatesCache: make(map[GceRef]*gce.InstanceTemplate), + instancesFromUnknownMig: make(map[GceRef]bool), +>>>>>>> 2aeec4097 (changed InstanceTemplateNameType to InstanceTemplateName) } } @@ -1436,13 +1447,13 @@ func fetchMigBasenameConst(basename string) func(GceRef) (string, error) { } } -func fetchMigTemplateNameFail(_ GceRef) (InstanceTemplateNameType, error) { - return InstanceTemplateNameType{}, errFetchMigTemplateName +func fetchMigTemplateNameFail(_ GceRef) (InstanceTemplateName, error) { + return InstanceTemplateName{}, errFetchMigTemplateName } -func fetchMigTemplateNameConst(instanceTemplateNameType InstanceTemplateNameType) func(GceRef) (InstanceTemplateNameType, error) { - return func(GceRef) (InstanceTemplateNameType, error) { - return instanceTemplateNameType, nil +func fetchMigTemplateNameConst(instanceTemplateName InstanceTemplateName) func(GceRef) (InstanceTemplateName, error) { + return func(GceRef) (InstanceTemplateName, error) { + return instanceTemplateName, nil } }