Skip to content

Commit fcbba7d

Browse files
committed
libvirt: Ensure all volume drivers log the instance whenever possible
This trivial change ensures the instance is logged within the volume drivers whenever possible to ease debugging. Change-Id: Ib61ba7266ad58b311adcac566a96149839cb688e
1 parent 7670303 commit fcbba7d

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

nova/virt/libvirt/volume/fibrechannel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def get_config(self, connection_info, disk_info):
5050
def connect_volume(self, connection_info, instance):
5151
"""Attach the volume to instance_name."""
5252

53-
LOG.debug("Calling os-brick to attach FC Volume")
53+
LOG.debug("Calling os-brick to attach FC Volume", instance=instance)
5454
device_info = self.connector.connect_volume(connection_info['data'])
55-
LOG.debug("Attached FC volume %s", device_info)
55+
LOG.debug("Attached FC volume %s", device_info, instance=instance)
5656

5757
connection_info['data']['device_path'] = device_info['path']
5858
if 'multipath_id' in device_info:

nova/virt/libvirt/volume/iscsi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def get_config(self, connection_info, disk_info):
6060
def connect_volume(self, connection_info, instance):
6161
"""Attach the volume to instance_name."""
6262

63-
LOG.debug("Calling os-brick to attach iSCSI Volume")
63+
LOG.debug("Calling os-brick to attach iSCSI Volume", instance=instance)
6464
device_info = self.connector.connect_volume(connection_info['data'])
65-
LOG.debug("Attached iSCSI volume %s", device_info)
65+
LOG.debug("Attached iSCSI volume %s", device_info, instance=instance)
6666

6767
connection_info['data']['device_path'] = device_info['path']
6868

nova/virt/libvirt/volume/mount.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,17 @@ def mount(self, fstype, export, vol_name, mountpoint, instance, options):
290290
'options=%(options)s) generation %(gen)s',
291291
{'fstype': fstype, 'export': export, 'vol_name': vol_name,
292292
'mountpoint': mountpoint, 'options': options,
293-
'gen': self.generation})
293+
'gen': self.generation}, instance=instance)
294294
with self._get_locked(mountpoint) as mount:
295295
if os.path.ismount(mountpoint):
296296
LOG.debug(('Mounting %(mountpoint)s generation %(gen)s, '
297297
'mountpoint already mounted'),
298-
{'mountpoint': mountpoint, 'gen': self.generation})
298+
{'mountpoint': mountpoint, 'gen': self.generation},
299+
instance=instance)
299300
else:
300301
LOG.debug('Mounting %(mountpoint)s generation %(gen)s',
301-
{'mountpoint': mountpoint, 'gen': self.generation})
302+
{'mountpoint': mountpoint, 'gen': self.generation},
303+
instance=instance)
302304

303305
fileutils.ensure_tree(mountpoint)
304306

@@ -316,7 +318,7 @@ def mount(self, fstype, export, vol_name, mountpoint, instance, options):
316318
'%(mountpoint)s. Continuing because mountpount is '
317319
'mounted despite this.',
318320
{'fstype': fstype, 'export': export,
319-
'mountpoint': mountpoint})
321+
'mountpoint': mountpoint}, instance=instance)
320322
else:
321323
# If the mount failed there's no reason for us to keep
322324
# a record of it. It will be created again if the
@@ -331,7 +333,8 @@ def mount(self, fstype, export, vol_name, mountpoint, instance, options):
331333

332334
LOG.debug('_HostMountState.mount() for %(mountpoint)s '
333335
'generation %(gen)s completed successfully',
334-
{'mountpoint': mountpoint, 'gen': self.generation})
336+
{'mountpoint': mountpoint, 'gen': self.generation},
337+
instance=instance)
335338

336339
def umount(self, vol_name, mountpoint, instance):
337340
"""Mark an attachment as no longer in use, and unmount its mountpoint
@@ -345,16 +348,15 @@ def umount(self, vol_name, mountpoint, instance):
345348
LOG.debug('_HostMountState.umount(vol_name=%(vol_name)s, '
346349
'mountpoint=%(mountpoint)s) generation %(gen)s',
347350
{'vol_name': vol_name, 'mountpoint': mountpoint,
348-
'gen': self.generation})
351+
'gen': self.generation}, instance=instance)
349352
with self._get_locked(mountpoint) as mount:
350353
try:
351354
mount.remove_attachment(vol_name, instance.uuid)
352355
except KeyError:
353-
LOG.warning("Request to remove attachment "
354-
"(%(vol_name)s, %(instance)s) from "
356+
LOG.warning("Request to remove attachment (%(vol_name)s from "
355357
"%(mountpoint)s, but we don't think it's in use.",
356-
{'vol_name': vol_name, 'instance': instance.uuid,
357-
'mountpoint': mountpoint})
358+
{'vol_name': vol_name, 'mountpoint': mountpoint},
359+
instance=instance)
358360

359361
if not mount.in_use():
360362
mounted = os.path.ismount(mountpoint)
@@ -368,7 +370,8 @@ def umount(self, vol_name, mountpoint, instance):
368370

369371
LOG.debug('_HostMountState.umount() for %(mountpoint)s '
370372
'generation %(gen)s completed successfully',
371-
{'mountpoint': mountpoint, 'gen': self.generation})
373+
{'mountpoint': mountpoint, 'gen': self.generation},
374+
instance=instance)
372375

373376
def _real_umount(self, mountpoint):
374377
# Unmount and delete a mountpoint.

nova/virt/libvirt/volume/nvme.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ def connect_volume(self, connection_info, instance):
3939

4040
device_info = self.connector.connect_volume(
4141
connection_info['data'])
42-
LOG.debug(
43-
"Connecting NVMe volume with device_info %s",
44-
device_info)
42+
LOG.debug("Connecting NVMe volume with device_info %s",
43+
device_info, instance=instance)
4544

4645
connection_info['data']['device_path'] = device_info['path']
4746

4847
def disconnect_volume(self, connection_info, instance):
4948
"""Detach the volume from the instance."""
50-
LOG.debug("Disconnecting NVMe disk")
49+
LOG.debug("Disconnecting NVMe disk", instance=instance)
5150
self.connector.disconnect_volume(
5251
connection_info['data'], None)
5352
super(LibvirtNVMEVolumeDriver,

nova/virt/libvirt/volume/quobyte.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def get_config(self, connection_info, disk_info):
158158
def connect_volume(self, connection_info, instance):
159159
"""Connect the volume."""
160160
if is_systemd():
161-
LOG.debug("systemd detected.")
161+
LOG.debug("systemd detected.", instance=instance)
162162
else:
163-
LOG.debug("No systemd detected.")
163+
LOG.debug("No systemd detected.", instance=instance)
164164

165165
data = connection_info['data']
166166
quobyte_volume = self._normalize_export(data['export'])
@@ -171,7 +171,7 @@ def connect_volume(self, connection_info, instance):
171171
except nova_exception.StaleVolumeMount:
172172
mounted = False
173173
LOG.info('Fixing previous mount %s which was not '
174-
'unmounted correctly.', mount_path)
174+
'unmounted correctly.', mount_path, instance=instance)
175175
umount_volume(mount_path)
176176
except nova_exception.InvalidVolume:
177177
mounted = False
@@ -185,7 +185,8 @@ def connect_volume(self, connection_info, instance):
185185
validate_volume(mount_path)
186186
except (nova_exception.InvalidVolume,
187187
nova_exception.StaleVolumeMount) as nex:
188-
LOG.error("Could not mount Quobyte volume: %s", nex)
188+
LOG.error("Could not mount Quobyte volume: %s", nex,
189+
instance=instance)
189190

190191
@utils.synchronized('connect_qb_volume')
191192
def disconnect_volume(self, connection_info, instance):
@@ -196,7 +197,8 @@ def disconnect_volume(self, connection_info, instance):
196197
validate_volume(mount_path)
197198
except (nova_exception.InvalidVolume,
198199
nova_exception.StaleVolumeMount) as exc:
199-
LOG.warning("Could not disconnect Quobyte volume mount: %s", exc)
200+
LOG.warning("Could not disconnect Quobyte volume mount: %s", exc,
201+
instance=instance)
200202
else:
201203
umount_volume(mount_path)
202204

nova/virt/libvirt/volume/scaleio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def get_config(self, connection_info, disk_info):
5353

5454
def connect_volume(self, connection_info, instance):
5555
device_info = self.connector.connect_volume(connection_info['data'])
56-
LOG.debug("Attached ScaleIO volume %s.", device_info)
56+
LOG.debug("Attached ScaleIO volume %s.", device_info,
57+
instance=instance)
5758
connection_info['data']['device_path'] = device_info['path']
5859

5960
def disconnect_volume(self, connection_info, instance):

0 commit comments

Comments
 (0)