1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

M #-: Better trigger for sync state messages

This commit is contained in:
Ruben S. Montero 2020-04-23 18:44:11 +02:00
parent 1a65d1ad16
commit 8cd4b04ff8
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 10 additions and 4 deletions

View File

@ -36,6 +36,7 @@ $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
require 'sqlite3'
require 'yaml'
require 'fileutils'
# ------------------------------------------------------------------------------
# SQlite Interface for the status probes. It stores the last known state of
@ -74,7 +75,11 @@ class VirtualMachineDB
def initialize(hyperv, opts = {})
@conf = VirtualMachineDB.load_conf(hyperv, opts)
@db = SQLite3::Database.new(@conf[:db_path])
@mtime = 0
@mtime = File.mtime(@conf[:db_path]) if File.exist?(@conf[:db_path])
@db = SQLite3::Database.new(@conf[:db_path])
bootstrap
@ -93,9 +98,9 @@ class VirtualMachineDB
def to_status(host, host_id)
time = Time.now.to_i
last = @db.execute("SELECT MAX(timestamp) from #{@dataset}").flatten![0]
last ||= 0
last ||= @mtime.to_i
return sync_status(host, host_id) if time > (last + @conf[:sync]) && last != 0
return sync_status(host, host_id) if last == 0 || time > (last + @conf[:sync])
status_str = ''
monitor_ids = []

View File

@ -151,7 +151,8 @@ void HostMonitorManager::update_host(int oid, const std::string &xml)
{
stop_host_monitor(host);
}
else if (old_state == Host::OFFLINE)
else if (old_state == Host::OFFLINE || old_state == Host::ERROR ||
old_state == Host::INIT)
{
start_host_monitor(host);
}