Skip to content

B #8181: Update running_stime when VM transitions from BOOT to RUNNING - #8182

Open
trukhinyuri wants to merge 1 commit into
OpenNebula:masterfrom
trukhinyuri:fix/im-sync-state-toctou
Open

trukhinyuri wants to merge 1 commit into
OpenNebula:masterfrom
trukhinyuri:fix/im-sync-state-toctou

Conversation

@trukhinyuri

@trukhinyuri trukhinyuri commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #8181.

In LifeCycleManager::trigger_deploy_success() (src/lcm/LifeCycleStates.cc), vm->set_running_stime() is updated in the MIGRATE branch (line 325) but not in the BOOT* branch (lines 353-378). Because running_stime is otherwise set when PROLOG completes (prolog_success_action) or when BOOT_POWEROFF / BOOT_SUSPENDED starts (and not refreshed when recovering from BOOT_FAILURE / BOOT_UNKNOWN), a vmm/deploy or vmm/restore that takes 30s or longer reaches RUNNING with time(0) - vm->get_running_stime() >= 30.

When that happens, the 30s grace window in InformationManager::ignore_state_update() (038e3420ed) no longer applies, so an in-flight SYNC_STATE poll collected just before deploy completion can move the newly started VM straight to POWEROFF.

This change sets vm->set_running_stime(time(0)) in the BOOT* branch of trigger_deploy_success() as well.

Branches to which this PR applies

  • master
  • one-7.0

  • Check this if this PR should not be squashed

… to RUNNING

Commit 038e342 added ignore_state_update() in InformationManager to ignore stale monitoring state updates for 30s after running_stime or running_etime. However, LifeCycleManager::trigger_deploy_success only updated running_stime in the MIGRATE branch and did not update running_stime when transitioning from BOOT* states to RUNNING (leaving running_stime at the timestamp when PROLOG completed and BOOT started, or when an earlier boot failed).

When vmm/deploy or vmm/restore takes 30s or longer (or after recovering from BOOT_FAILURE), time(0) - vm->get_running_stime() is already >= 30s at the moment the VM enters RUNNING, allowing an in-flight SYNC_STATE poll collected before deploy completion to immediately transition the newly RUNNING VM to POWEROFF.

Update vm->set_running_stime(time(0)) in the BOOT* branch of LifeCycleManager::trigger_deploy_success.

Signed-off-by: Iurii Trukhin <yuri@trukhin.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused change correctly addresses the stale state-update race and matches existing lifecycle behavior.

0 open findings

What changed in this PR

Refreshes the VM running timestamp after successful BOOT* deployment, preserving the 30-second stale-monitoring protection.

Changes:

  • Sets running_stime when transitioning from BOOT* to RUNNING.
  • Aligns boot behavior with migration handling.
File Description
src/​lcm/​LifeCycleStates.cc Refreshes the running timestamp after successful deployment.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paczerny paczerny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new assignment also applies to BOOT_UNKNOWN. Restarting from UNKNOWN reuses the existing history record, so replacing its RSTIME erases the running interval before recovery. Showback derives running hours from this timestamp; when running-only billing is enabled, CPU and memory charges also lose that interval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LifeCycleManager::trigger_deploy_success does not update running_stime when transitioning from BOOT* to RUNNING

3 participants