Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Migration log: reduce number of entries and use microtime to avoid chances of conflicts #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this test timestamp be updated to the new format too, in case we ever restrict in Serveradmin?


vm_migrate(
VM_HOSTNAME,
Expand Down