Merge branch '14669-java-sdk-v2' into 14670-new-java-sdk-docs
[arvados.git] / lib / cloud / azure / azure.go
index b88962714e709765f1c93e0a6a88dbcf860aabaa..d37183fbdf5e5f4b7ec639a61be1abf960a4f200 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()
@@ -340,6 +341,10 @@ func (az *azureInstanceSet) Create(
        az.stopWg.Add(1)
        defer az.stopWg.Done()
 
+       if instanceType.AddedScratch > 0 {
+               return nil, fmt.Errorf("cannot create instance type %q: driver does not implement non-zero AddedScratch (%d)", instanceType.Name, instanceType.AddedScratch)
+       }
+
        name, err := randutil.String(15, "abcdefghijklmnopqrstuvwxyz0123456789")
        if err != nil {
                return nil, err
@@ -646,7 +651,8 @@ func (ai *azureInstance) Destroy() error {
 func (ai *azureInstance) Address() string {
        if ai.nic.IPConfigurations != nil &&
                len(*ai.nic.IPConfigurations) > 0 &&
-               (*ai.nic.IPConfigurations)[0].PrivateIPAddress != nil {
+               (*ai.nic.IPConfigurations)[0].InterfaceIPConfigurationPropertiesFormat != nil &&
+               (*ai.nic.IPConfigurations)[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress != nil {
 
                return *(*ai.nic.IPConfigurations)[0].PrivateIPAddress
        }