14911: Fix initialization order.
authorTom Clegg <tclegg@veritasgenetics.com>
Mon, 4 Mar 2019 20:57:05 +0000 (15:57 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 4 Mar 2019 20:57:05 +0000 (15:57 -0500)
Nil az.ctx was being passed to ListKeys(), causing panic.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/cloud/azure/azure.go

index b88962714e709765f1c93e0a6a88dbcf860aabaa..d19e4bef2372ff87dfb13e26db1ffddb9726bdca 100644 (file)
@@ -220,12 +220,14 @@ func newAzureInstanceSet(config json.RawMessage, dispatcherID cloud.InstanceSetI
                return nil, err
        }
 
-       ap := azureInstanceSet{logger: logger}
-       err = ap.setup(azcfg, string(dispatcherID))
+       az := azureInstanceSet{logger: logger}
+       az.ctx, az.stopFunc = context.WithCancel(context.Background())
+       err = az.setup(azcfg, string(dispatcherID))
        if err != nil {
+               az.stopFunc()
                return nil, err
        }
-       return &ap, nil
+       return &az, nil
 }
 
 func (az *azureInstanceSet) setup(azcfg azureInstanceSetConfig, dispatcherID string) (err error) {
@@ -276,7 +278,6 @@ func (az *azureInstanceSet) setup(azcfg azureInstanceSetConfig, dispatcherID str
        az.dispatcherID = dispatcherID
        az.namePrefix = fmt.Sprintf("compute-%s-", az.dispatcherID)
 
-       az.ctx, az.stopFunc = context.WithCancel(context.Background())
        go func() {
                az.stopWg.Add(1)
                defer az.stopWg.Done()