Skip to content

Commit bc54d36

Browse files
Merge pull request docker-archive-public#3269 from ahmetalpbalkan/azure_msg
azure: more accurate messages for resources created
2 parents 1f27895 + 6c3faf7 commit bc54d36

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

drivers/azure/azureutil/azureutil.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (a AzureClient) CreateResourceGroup(name, location string) error {
9898
return nil
9999
}
100100

101-
log.Info("Creating resource group...", logutil.Fields{
101+
log.Info("Creating resource group.", logutil.Fields{
102102
"name": name,
103103
"location": location})
104104
_, err := a.resourceGroupsClient().CreateOrUpdate(name,
@@ -109,13 +109,13 @@ func (a AzureClient) CreateResourceGroup(name, location string) error {
109109
}
110110

111111
func (a AzureClient) resourceGroupExists(name string) (bool, error) {
112-
log.Info("Querying existing resource group...", logutil.Fields{"name": name})
112+
log.Info("Querying existing resource group.", logutil.Fields{"name": name})
113113
_, err := a.resourceGroupsClient().Get(name)
114114
return checkResourceExistsFromError(err)
115115
}
116116

117117
func (a AzureClient) CreateNetworkSecurityGroup(ctx *DeploymentContext, resourceGroup, name, location string, rules *[]network.SecurityRule) error {
118-
log.Info("Creating network security group...", logutil.Fields{
118+
log.Info("Configuring network security group.", logutil.Fields{
119119
"name": name,
120120
"location": location})
121121
_, err := a.securityGroupsClient().CreateOrUpdate(resourceGroup, name,
@@ -143,7 +143,7 @@ func (a AzureClient) DeleteNetworkSecurityGroupIfExists(resourceGroup, name stri
143143
}
144144

145145
func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool) error {
146-
log.Info("Creating public IP address...", logutil.Fields{
146+
log.Info("Creating public IP address.", logutil.Fields{
147147
"name": name,
148148
"static": isStatic})
149149

@@ -183,7 +183,7 @@ func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, locati
183183
"name": name,
184184
"location": location}
185185

186-
log.Info("Querying if virtual network already exists...", f)
186+
log.Info("Querying if virtual network already exists.", f)
187187

188188
if exists, err := a.virtualNetworkExists(resourceGroup, name); err != nil {
189189
return err
@@ -192,7 +192,7 @@ func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, locati
192192
return nil
193193
}
194194

195-
log.Debug("Virtual network does not exist, creating...", f)
195+
log.Debug("Creating virtual network.", f)
196196
_, err := a.virtualNetworksClient().CreateOrUpdate(resourceGroup, name,
197197
network.VirtualNetwork{
198198
Location: to.StringPtr(location),
@@ -223,7 +223,7 @@ func (a AzureClient) GetSubnet(resourceGroup, virtualNetwork, name string) (netw
223223
}
224224

225225
func (a AzureClient) CreateSubnet(ctx *DeploymentContext, resourceGroup, virtualNetwork, name, subnetPrefix string) error {
226-
log.Info("Creating subnet...", logutil.Fields{
226+
log.Info("Configuring subnet.", logutil.Fields{
227227
"name": name,
228228
"vnet": virtualNetwork,
229229
"cidr": subnetPrefix})
@@ -256,7 +256,7 @@ func (a AzureClient) CreateNetworkInterface(ctx *DeploymentContext, resourceGrou
256256
// specified Azure location is different than location of the virtual
257257
// network as Azure does not support cross-region virtual networks. In this
258258
// situation, user will get an explanatory API error from Azure.
259-
log.Info("Creating network interface...", logutil.Fields{"name": name})
259+
log.Info("Creating network interface.", logutil.Fields{"name": name})
260260

261261
var publicIP *network.PublicIPAddress
262262
if publicIPAddressID != "" {
@@ -330,7 +330,7 @@ func (a AzureClient) findStorageAccount(resourceGroup, location, prefix string,
330330
"type": storageType,
331331
"prefix": prefix,
332332
"location": location}
333-
log.Debug("Querying existing storage accounts...", f)
333+
log.Debug("Querying existing storage accounts.", f)
334334
l, err := a.storageAccountsClient().ListByResourceGroup(resourceGroup)
335335
if err != nil {
336336
return nil, err
@@ -359,7 +359,7 @@ func (a AzureClient) createStorageAccount(resourceGroup, location string, storag
359359
"name": name,
360360
"location": location}
361361

362-
log.Info("Creating storage account...", f)
362+
log.Info("Creating storage account.", f)
363363
_, err := a.storageAccountsClient().Create(resourceGroup, name,
364364
storage.AccountCreateParameters{
365365
Location: to.StringPtr(location),
@@ -409,7 +409,7 @@ func (a AzureClient) removeOSDiskBlob(resourceGroup, vmName, vhdURL string) erro
409409
// Machine functionality which deletes the attached disks along with the VM
410410
// as well. Therefore we find out the storage account from OS disk URL and
411411
// fetch storage account keys to delete the container containing the disk.
412-
log.Debug("Attempting to remove OS disk...", logutil.Fields{"vm": vmName})
412+
log.Debug("Attempting to remove OS disk.", logutil.Fields{"vm": vmName})
413413
log.Debugf("OS Disk vhd URL: %q", vhdURL)
414414

415415
vhdContainer := osDiskStorageContainerName(vmName)
@@ -447,7 +447,7 @@ func (a AzureClient) removeOSDiskBlob(resourceGroup, vmName, vhdURL string) erro
447447

448448
func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, availabilitySetID, networkInterfaceID,
449449
username, sshPublicKey, imageName string, storageAccount *storage.AccountProperties) error {
450-
log.Info("Creating Virtual Machine...", logutil.Fields{
450+
log.Info("Creating virtual machine.", logutil.Fields{
451451
"name": name,
452452
"location": location,
453453
"size": size,
@@ -536,12 +536,7 @@ func (a AzureClient) GetAvailabilitySet(resourceGroup, name string) (compute.Ava
536536

537537
func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error {
538538
f := logutil.Fields{"name": name}
539-
if ctx.AvailabilitySetID != "" {
540-
log.Info("Availability Set already exists.", f)
541-
return nil
542-
}
543-
log.Debug("Could not find existing availability set.", f)
544-
log.Info("Creating availability set...", f)
539+
log.Info("Configuring availability set.", f)
545540
as, err := a.availabilitySetsClient().CreateOrUpdate(resourceGroup, name,
546541
compute.AvailabilitySet{
547542
Location: to.StringPtr(location),
@@ -634,7 +629,7 @@ func deleteResourceIfExists(resourceType, name string, getFunc func() error, del
634629
log.Info(fmt.Sprintf("%s does not exist. Skipping.", resourceType), f)
635630
return nil
636631
}
637-
log.Info(fmt.Sprintf("Removing %s resource...", resourceType), f)
632+
log.Info(fmt.Sprintf("Removing %s resource.", resourceType), f)
638633
_, err := deleteFunc()
639634
return err
640635
}

0 commit comments

Comments
 (0)