From 7226f26cb2f91b8cc94bdc6ba7023c8b72654269 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Thu, 24 Feb 2022 12:57:36 +0100 Subject: [PATCH] Removes caching for MAAS availability zones, fetching them fresh each time. The calls to this method are not frequent enough to attempt number-of-request amelioration. --- provider/maas/environ.go | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/provider/maas/environ.go b/provider/maas/environ.go index 33a39c977ff..d8032ee7f8b 100644 --- a/provider/maas/environ.go +++ b/provider/maas/environ.go @@ -100,9 +100,6 @@ type maasEnviron struct { // namespace is used to create the machine and device hostnames. namespace instance.Namespace - availabilityZonesMutex sync.Mutex - availabilityZones corenetwork.AvailabilityZones - // apiVersion tells us if we are using the MAAS 1.0 or 2.0 api. apiVersion string @@ -534,25 +531,20 @@ func (z maasAvailabilityZone) Available() bool { // AvailabilityZones returns a slice of availability zones // for the configured region. func (env *maasEnviron) AvailabilityZones(ctx context.ProviderCallContext) (corenetwork.AvailabilityZones, error) { - env.availabilityZonesMutex.Lock() - defer env.availabilityZonesMutex.Unlock() - if env.availabilityZones == nil { - var availabilityZones corenetwork.AvailabilityZones - var err error - if env.usingMAAS2() { - availabilityZones, err = env.availabilityZones2(ctx) - if err != nil { - return nil, errors.Trace(err) - } - } else { - availabilityZones, err = env.availabilityZones1(ctx) - if err != nil { - return nil, errors.Trace(err) - } + var zones corenetwork.AvailabilityZones + var err error + if env.usingMAAS2() { + zones, err = env.availabilityZones2(ctx) + if err != nil { + return nil, errors.Trace(err) + } + } else { + zones, err = env.availabilityZones1(ctx) + if err != nil { + return nil, errors.Trace(err) } - env.availabilityZones = availabilityZones } - return env.availabilityZones, nil + return zones, nil } func (env *maasEnviron) availabilityZones1(ctx context.ProviderCallContext) (corenetwork.AvailabilityZones, error) {