Skip to content

Commit

Permalink
Migration log: reduce number of entries and use microtime to avoid ch…
Browse files Browse the repository at this point in the history
…ances of duplicates
  • Loading branch information
brainexe committed Oct 11, 2023
1 parent 1151b6b commit 711e53e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions igvm/hypervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import logging
import math
from contextlib import contextmanager
from time import sleep, time
from time import sleep
from datetime import datetime
from xml.etree import ElementTree

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

cpu_usage_vm = self.estimate_vm_cpu_usage(vm)
timestamp = int(time())
log_entry = '{} {}{}'.format(timestamp, operator, round(cpu_usage_vm))
cpu_usage_vm = round(self.estimate_vm_cpu_usage(vm))
if cpu_usage_vm == 0:
return

timestamp = datetime.now().isoformat()
log_entry = '{} {}{}'.format(timestamp, operator, cpu_usage_vm)

self.dataset_obj['igvm_migration_log'].add(log_entry)
self.dataset_obj.commit()
1 change: 0 additions & 1 deletion igvm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
'igvm_migration_log',
'intern_ip',
'iops_avg',
'igvm_migration_log',
'libvirt_memory_total_gib',
'libvirt_memory_used_gib',
'libvirt_pool_total_gib',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def test_igvm_migration_log(self, performance_value, mock_time):

src_hv = self.vm.hypervisor.dataset_obj['hostname']
cpu_usage_vm_src = self.vm.hypervisor.estimate_vm_cpu_usage(self.vm)
timestamp = 1234567890
timestamp = 1234567890000

vm_migrate(
VM_HOSTNAME,
Expand Down

0 comments on commit 711e53e

Please sign in to comment.