Skip to content

fix(compute): an update must not take a machine out of its install boot - #533

Open
gmelikov wants to merge 1 commit into
masterfrom
misc2
Open

fix(compute): an update must not take a machine out of its install boot#533
gmelikov wants to merge 1 commit into
masterfrom
misc2

Conversation

@gmelikov

@gmelikov gmelikov commented Jul 27, 2026

Copy link
Copy Markdown
Member

A new machine is created in network boot so Seed OS can flash it. Any update that reached it before it reported back — an element re-rendering the node it belongs to, for instance — fell through to the default hd0 and rebuilt the domain off a disk nothing had written yet: the VM lived seven seconds, came back with an empty 196 KB image and never booted.

Keep the network boot while the machine is still installing (the target asks for it and no actual guest machine exists yet); the image-changed path is unchanged.

Summary by Sourcery

Ensure pool builder keeps machines in network boot while Seed OS installation is in progress and only switches to network boot when the guest image actually changes.

Bug Fixes:

  • Prevent updates from switching installing machines off network boot before Seed OS has completed flashing the disk.

Tests:

  • Add unit tests covering boot mode behavior during machine installation, for installed machines, and when the guest image changes.

A new machine is created in network boot so Seed OS can flash it. Any
update that reached it before it reported back — an element re-rendering
the node it belongs to, for instance — fell through to the default hd0
and rebuilt the domain off a disk nothing had written yet: the VM lived
seven seconds, came back with an empty 196 KB image and never booted.

Keep the network boot while the machine is still installing (the target
asks for it and no actual guest machine exists yet); the image-changed
path is unchanged.
@gmelikov
gmelikov requested a review from a team as a code owner July 27, 2026 12:53
@sourcery-ai

sourcery-ai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Ensure that machine updates preserve network boot for machines still in Seed OS installation and add unit tests around boot-mode behavior in PoolBuilderService.

Flow diagram for boot mode selection in _actualize_machine_derivatives_on_create_update

flowchart TD
    A[_actualize_machine_derivatives_on_create_update] --> B[check _is_core_machine]
    B -->|is core| C[keep current boot/port]
    B -->|not core| D[unpack machine_guest_pair to guest_target, guest_actual]

    D --> E{guest_actual is None
and guest_target.boot == nc.BootAlternative.network}
    E -->|yes| F[set boot = nc.BootAlternative.network.value]
    F --> G[set port = models.Port.from_boot_network]
    E -->|no| H{guest_actual and
guest_actual.image != resolved_image}
    H -->|yes| I[set boot = nc.BootAlternative.network.value]
    I --> J[set port for boot network]
    H -->|no| C

    G --> K[end]
    J --> K
    C --> K
Loading

File-Level Changes

Change Details Files
Preserve network boot for machines still installing when handling create/update in PoolBuilderService.
  • Capture both guest_target and guest_actual from machine_guest_pair instead of discarding guest_target.
  • Add a conditional branch that detects an installing machine (guest_actual is None and guest_target.boot is network) and forces boot to network and port to the boot network.
  • Change the image-changed logic to run only when guest_actual exists and its image differs from the resolved image, using elif so it does not override the installing-machine branch.
exordos_core/compute/builders/pool.py
Add unit tests to validate boot mode decisions during machine updates.
  • Introduce helpers to construct fake machine and guest objects and to drive _actualize_machine_derivatives_on_create_update under mocks.
  • Test that an update keeps a still-installing machine on network boot when Seed OS has not reported back.
  • Test that an installed machine remains on disk boot (hd0) when its image is unchanged on update.
  • Test that a machine is switched back to network boot when its image has changed on update.
exordos_core/tests/unit/compute/test_pool_builder_boot.py

Possibly linked issues

  • #N/A: PR adjusts PoolBuilder boot logic for machines still installing, preventing early-update reboots described in issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - I've left some high level feedback:

  • In _actualize_machine_derivatives_on_create_update, the new branch assumes guest_target is always non-None; if machine_guest_pair can ever have a None target, this will raise, so consider guarding guest_target before accessing guest_target.boot or bailing out early in that case.
  • The builder fixture instantiates PoolBuilderService via __new__ without running __init__, which can easily break if future logic in _actualize_machine_derivatives_on_create_update depends on initialized attributes; consider constructing a real instance and stubbing dependencies instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `_actualize_machine_derivatives_on_create_update`, the new branch assumes `guest_target` is always non-None; if `machine_guest_pair` can ever have a `None` target, this will raise, so consider guarding `guest_target` before accessing `guest_target.boot` or bailing out early in that case.
- The `builder` fixture instantiates `PoolBuilderService` via `__new__` without running `__init__`, which can easily break if future logic in `_actualize_machine_derivatives_on_create_update` depends on initialized attributes; consider constructing a real instance and stubbing dependencies instead.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@akremenetsky

akremenetsky commented Jul 28, 2026

Copy link
Copy Markdown
Member

Closes #271 partly. It doesn't cover the legacy case and nodes with custom images without agents.
Please don't merge until fixes for these cases. Otherwise we cannot resize such nodes.

@phantomii phantomii 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.

Could we also assert that the boot-network port is used while the machine is still installing? The current test verifies the boot mode, but not the port that makes that mode usable.

@phantomii phantomii 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.

Please add coverage for the boot-network port while the machine is still installing.

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.

4 participants