Skip to content

Commit 711e53e

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

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

igvm/hypervisor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import logging
77
import math
88
from contextlib import contextmanager
9-
from time import sleep, time
9+
from time import sleep
10+
from datetime import datetime
1011
from xml.etree import ElementTree
1112

1213
from igvm.vm import VM
@@ -1149,9 +1150,12 @@ def log_migration(self, vm: VM, operator: str) -> None:
11491150
:param operator: plus for migration to HV, minus for migration from HV
11501151
"""
11511152

1152-
cpu_usage_vm = self.estimate_vm_cpu_usage(vm)
1153-
timestamp = int(time())
1154-
log_entry = '{} {}{}'.format(timestamp, operator, round(cpu_usage_vm))
1153+
cpu_usage_vm = round(self.estimate_vm_cpu_usage(vm))
1154+
if cpu_usage_vm == 0:
1155+
return
1156+
1157+
timestamp = datetime.now().isoformat()
1158+
log_entry = '{} {}{}'.format(timestamp, operator, cpu_usage_vm)
11551159

11561160
self.dataset_obj['igvm_migration_log'].add(log_entry)
11571161
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)