Skip to content

Commit 4523fc8

Browse files
committed
Migration log: reduce number of entries and use microtime to avoid chances of duplicates
1 parent 1151b6b commit 4523fc8

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

igvm/hypervisor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,9 +1149,12 @@ def log_migration(self, vm: VM, operator: str) -> None:
11491149
:param operator: plus for migration to HV, minus for migration from HV
11501150
"""
11511151

1152-
cpu_usage_vm = self.estimate_vm_cpu_usage(vm)
1153-
timestamp = int(time())
1154-
log_entry = '{} {}{}'.format(timestamp, operator, round(cpu_usage_vm))
1152+
cpu_usage_vm = round(self.estimate_vm_cpu_usage(vm))
1153+
if cpu_usage_vm == 0:
1154+
return
1155+
1156+
timestamp = int(time() * 1000)
1157+
log_entry = '{} {}{}'.format(timestamp, operator, cpu_usage_vm)
11551158

11561159
self.dataset_obj['igvm_migration_log'].add(log_entry)
11571160
self.dataset_obj.commit()

igvm/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
'igvm_migration_log',
126126
'intern_ip',
127127
'iops_avg',
128-
'igvm_migration_log',
129128
'libvirt_memory_total_gib',
130129
'libvirt_memory_used_gib',
131130
'libvirt_pool_total_gib',

tests/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def test_igvm_migration_log(self, performance_value, mock_time):
518518

519519
src_hv = self.vm.hypervisor.dataset_obj['hostname']
520520
cpu_usage_vm_src = self.vm.hypervisor.estimate_vm_cpu_usage(self.vm)
521-
timestamp = 1234567890
521+
timestamp = 1234567890000
522522

523523
vm_migrate(
524524
VM_HOSTNAME,

0 commit comments

Comments
 (0)