Warm available bare metal nodes

https://bugs.launchpad.net/ironic/+bug/2168956

This specification adds opt-in warm available for Nova, Neutron, and networking-generic-switch (NGS) with separate cleaning and provisioning networks. At the end of automated cleaning, Ironic powers off the node, changes to the provisioning network, and boots the agent. An authenticated heartbeat makes the node available and warm.

Deployment reuses the running agent to write the image. It then powers off, changes to the tenant network, and boots the instance. warm_state lets the API and periodic task find warm nodes. In phase 1, a node that loses its agent becomes cold. Phase 2 boots the agent again.

Problem description

A deployment includes two power cycles. One boots the agent on the provisioning network. One boots the instance on the tenant network. The time from available to active includes a power cycle, POST, a PXE or virtual media boot, and agent startup before Ironic writes the image. On large GPU servers, each power cycle can take a large part of the deployment time. The node ran the same agent a short time before, during cleaning.

Customers often clean the whole fleet and then deploy it again. Rebuild avoids cleaning and is the better choice where possible, but sometimes the clean is wanted or required, for example between tenants. In this pattern, the slow step that users see is available to active, multiplied across many nodes.

Fast track cannot use separate cleaning and provisioning networks. Operators with separate cleaning and provisioning networks pay for both power cycles at deployment time.

Actors and use cases:

  • Deployer or admin: runs Ironic with Nova and Neutron, the neutron network interface, NGS, and separate cleaning and provisioning networks. They want faster deployments and they want to keep that isolation.

  • End user or automation: requests a deployment on an available node and wants the shortest possible time to active.

The extra power cycle moves from each deployment request to the end of cleaning, where it runs in parallel across the fleet. A node takes longer to reach available, but less time to go from available to active. The full clean-to-active time of one node does not get shorter.

Proposed change

Overview

Add an opt-in warm-up phase to the end of automated cleaning:

CLEANING: automated cleaning steps complete
  |
  v
power off                                  (always)
boot.clean_up_ramdisk
network.remove_cleaning_network
network.add_provisioning_network
wipe agent token / agent_url
boot.prepare_ramdisk (deploy ramdisk, can pre-generate a new token)
power on                                   warm_state = 'warming'
  |
  | 'wait'
  v
CLEANWAIT  -- wait for an authenticated heartbeat on the provisioning
  |           network (existing clean callback timeout applies)
  |
  +-- heartbeat OK ---> 'resume' --> CLEANING, warm_state = 'warm'
  |                     'done' ----> AVAILABLE
  |
  +-- timeout --------> 'resume' --> CLEANING
                        power off, remove provisioning network,
                        clean up ramdisk, warm_state = None
                        'done' ----> AVAILABLE (cold)
                        phase 2: keep network, warm_state = 'warming'

while AVAILABLE and warm:
  periodic task finds warm nodes through warm_state
    -> heartbeat is stale or power is off: power off, remove
       provisioning network, clean up ramdisk, warm_state = None (cold)
    -> phase 2: boot the agent again instead, warm_state = 'warming'

deploy requested on a warm node:
  warm_state == 'warm', heartbeat is fresh and the agent API answers
    -> skip power off, skip provisioning network re-plug
    -> reuse the running agent to write the image
    -> existing tear_down_agent (power off)
    -> existing switch_to_tenant_network
    -> existing boot_instance

If a deployment starts on a node that is not warm, the deployment uses the normal path that reboots the node. That path does not change.

Scope

The work has two phases. Each phase is useful on its own:

Phase 1:

  • Only automated cleaning that ends in available.

  • Only Nova and Neutron with the neutron network interface, with cleaning and provisioning networks that differ.

  • Only nodes that can power off and that have Ironic manage the agent boot. See Enabling the behavior.

  • Only deploy interfaces based on AgentBaseMixin (direct and custom-agent).

  • No re-warming. A node that loses its agent becomes cold and stays cold until its next cleaning.

Phase 2 keeps all the limits of phase 1, except the last one:

  • Re-warming of a node that loses its agent, with a limit on the number of attempts.

  • No re-warming of a node that an operator changed. See Leaving the warm state.

  • No warm-up of nodes that are available but never warmed.

Enabling the behavior

A new mutable option, [deploy]warm_available, defaults to False. It does not depend on [deploy]fast_track.

Enabling the option does not warm every node. Ironic does not warm a node if one of these conditions is true:

  • The cleaning and provisioning networks are the same.

  • The node has disable_power_off set.

  • [agent]manage_agent_boot is False. Ironic does not control the boot of the agent on the provisioning network.

  • The deploy interface does not implement prepare_warm_available.

When Ironic skips the warm-up, it logs the reason at info level. The node is cold, and the next deployment uses the normal path.

Lookup and heartbeat on warm nodes

Today, the lookup API and the heartbeat handler accept an agent on an available node only when fast track is enabled. The lookup API uses FASTTRACK_LOOKUP_ALLOWED_STATES, and AgentBaseMixin uses FASTTRACK_HEARTBEAT_ALLOWED. Warm available does not depend on fast track, so it does not use these lists.

Instead, both guards also accept an available node when its warm_state is warm. In phase 2, they also accept warming. A node with warm_state set to None gets the current behavior.

The warm_state field

A new nullable, indexed string column, warm_state, is added to the nodes table. It has these values:

  • None: the node is cold. This is the default for all nodes.

  • warming: the agent boots on the provisioning network, and Ironic waits for its first heartbeat. In phase 1, the node is in CLEANWAIT at the end of cleaning. In phase 2, the node can also be available while it re-warms.

  • warm: the node is available and its agent sends heartbeats on the provisioning network.

Cleaning changes

After the last clean step, do_next_clean_step calls the optional prepare_warm_available(task) deploy method before it fires done:

  • If the method returns None, cleaning finishes as it does today.

  • If it returns states.CLEANWAIT, the conductor sets warm_state to warming and fires wait. The node moves from CLEANING to CLEANWAIT. The conductor does not fire done.

For warm-up, tear_down_inband_cleaning powers the node off before it removes the cleaning network. Nodes without warm-up do not change.

AgentBaseMixin.prepare_warm_available then:

  1. calls network.add_provisioning_network.

  2. calls wipe_token_and_url. This removes the agent token and agent URL from cleaning.

  3. adds the usual deploy ramdisk parameters and calls deploy_utils.prepare_agent_boot.

  4. powers the node on and returns states.CLEANWAIT.

On an authenticated heartbeat in CLEANWAIT with warm_state set to warming, AgentBaseMixin.heartbeat sets warm_state to warm and records the provisioning VIFs. finish_warm_available fires resume and done to move the node to available.

Timeout at the end of cleaning

Warm-up moves the node to CLEANWAIT after cleaning. This transition resets provision_updated_at. The node has a full [conductor]clean_callback_timeout to send its first heartbeat. Deployment cannot start because the node is not available.

In phase 1, on timeout, the conductor fires resume, powers off the node, removes the provisioning network, cleans up the ramdisk, wipes the agent token and URL, sets warm_state to None and fires done.

If power off or network removal fails, the node goes to clean failed with last_error set and maintenance on. If only boot.clean_up_ramdisk fails, Ironic logs a warning and continues.

In phase 2, the conductor fires resume and done without cleanup. The node keeps the provisioning network, warm_state stays warming and warm_attempts is set to one. The periodic task then retries it.

Losing warmth

A periodic task runs every [conductor]warm_available_check_interval seconds. It selects available nodes with warm_state set to warm.

Before it locks a node, the task checks if it is stale. A node is stale when its heartbeat is too old or power sync reports it as powered off. The task does not query the BMC.

In phase 1, the task powers off a stale node, removes the provisioning network, cleans up the ramdisk, wipes the agent token and URL, and sets warm_state to None. The node stays available. If power off or network removal fails, the task sets last_error, puts the node into maintenance and adds a warning to the node history.

In phase 2, the task also selects warming nodes. For a stale node, it keeps the provisioning network attached. It powers off the node, wipes the agent token and URL, prepares the agent boot, and powers on the node. It sets warm_state to warming and increments warm_attempts in driver_internal_info.

The node stays available while it re-warms. Lookup and heartbeat accept an available node with warm_state set to warming. A valid heartbeat sets warm_state to warm and resets the counter. A deployment waits while the task holds the node lock for power and boot. It then uses the normal path.

If a warming node does not send a heartbeat before [conductor]clean_callback_timeout, the task retries it. After [deploy]warm_available_max_attempts attempts, it makes the node cold. A power failure sets warm_state to None, sets last_error, and puts the node into maintenance. The task does not retry it.

Note

Some BMCs remove virtual media after about 90 minutes. This does not affect a running agent. If the node reboots, its heartbeats stop. The periodic task makes it cold in phase 1 or prepares new boot media in phase 2.

Leaving the warm state

When one of the following events occurs, Ironic sets warm_state to None. It removes the provisioning network, cleans up the ramdisk and wipes the agent token. The periodic task then ignores the node:

  • a power action through the API.

  • leaving available through manage.

  • a port or portgroup of the node that is created or deleted through the API, or a PATCH of its address, local_link_connection, physical_network, pxe_enabled or portgroup_uuid.

  • changes to the network_interface, boot_interface, deploy_interface or related driver_info of the node.

  • entering maintenance mode.

  • [deploy]warm_available turned off.

VIF attach and detach do not change warm_state. They record the tenant VIF while the node is available. configure_tenant_networks uses it during deployment.

Deployment changes

Ironic reuses the agent only when warm_state is warm, the heartbeat is fresh, the agent API answers, and PXE-enabled ports retain their provisioning_vif_port_id. It keeps the provisioning ports and skips the normal agent boot. Otherwise, deployment uses the normal path. Ironic sets warm_state to None when deployment starts, without the cleanup above.

Alternatives

None.

Data model impact

  • A new nullable, indexed String(15) column warm_state on the nodes table, with a database migration. Existing nodes get NULL.

  • A new warm_state field on the Node object, with a version bump.

State Machine Impact

No new states or verbs. The changes are:

  • After the last clean step, the node can make one more round through CLEANING, wait, CLEANWAIT, resume and back to CLEANING, while it waits for the warm-up heartbeat. Then the existing done event moves it to available. All these transitions exist today.

  • A CLEANWAIT timeout during warm-up leads to available rather than clean failed. In phase 1, the conductor does the cold fallback before it fires done. In phase 2, it keeps the provisioning network and the warming state. There is no new transition.

  • An operator can use abort on a node in CLEANWAIT during warm-up, as with any other CLEANWAIT node. The node goes to clean failed. Today, do_node_clean_abort and cleaning_error_handler call tear_down_cleaning, which removes the cleaning network. During warm-up, the cleaning network is already gone and the provisioning network is attached. When warm_state is warming, these handlers therefore power the node off, call remove_provisioning_network and boot.clean_up_ramdisk, and set warm_state to None instead.

  • With warm-up enabled, a node reaches available later, after the agent boots on the provisioning network.

  • In phase 2, re-warming happens while the node is available. It needs no transition.

REST API impact

A new API microversion adds:

  • a read-only warm_state field to the node resource. It shows in GET /v1/nodes/{node_ident} and in GET /v1/nodes/detail, and the fields parameter can select it.

  • a warm_state query parameter for GET /v1/nodes and GET /v1/nodes/detail, for example ?warm_state=warm.

Older microversions do not show the field and reject the query parameter. The existing node read policies apply. A PATCH request cannot change the field.

Client (CLI) impact

“openstack baremetal” CLI

  • openstack baremetal node show shows warm_state.

  • openstack baremetal node list gets a --warm-state filter.

“openstacksdk”

  • A warm_state attribute on the Node resource.

  • warm_state as a query parameter for nodes().

RPC API impact

None.

Driver API impact

A new optional method is added to DeployInterface:

def prepare_warm_available(self, task):
    """Prepare a cleaned node to wait in the agent on the
    provisioning network.

    :returns: None if not supported or not applicable (cleaning
        finishes as usual), or states.CLEANWAIT if the conductor must
        wait for an agent heartbeat.
    """
    return None

The base implementation returns None, so out-of-tree deploy interfaces behave as they do today. AgentBaseMixin has the implementation described above.

Nova driver impact

None.

Ramdisk impact

None.

Security impact

  • Ironic removes the cleaning network while the node is powered off. A node that did not finish cleaning is never on the provisioning network.

  • The provisioning agent gets a fresh agent token. Ironic wipes the token and agent URL from cleaning before it prepares the new boot, so a token that the boot interface pre-generates for the new boot stays valid.

  • The lookup API and the heartbeat handler accept an agent on an available node only when its warm_state is warm (or warming in phase 2), or when fast track is enabled as today.

  • Nodes with disable_power_off set are never warmed, because the network change needs a powered-off node.

  • Warm nodes run the agent API on the provisioning network for a long time, possibly hours or days, not only during a deployment. Operators must make sure that tenants cannot reach the provisioning network. Use agent TLS ([agent]verify_ca or auto-TLS) where it is available.

Other end user impact

Users see a shorter available to active time on warm nodes. Operators see nodes take longer to finish cleaning, and see warm nodes powered on while available.

Scalability impact

  • Each warm node sends heartbeats for as long as it is available. This is the same load as current fast track, but more nodes can be in this state at the same time. A heartbeat on a warm node only updates agent_last_heartbeat and agent_url.

  • The periodic task selects nodes through an indexed column, so it does not load cold nodes. It does not query BMCs to find stale nodes.

Performance Impact

  • Deployment on a warm node skips one power cycle, POST and agent boot.

  • Cleaning takes one more power cycle and agent boot.

  • Heartbeat handling, lookup and the CLEANWAIT timeout check each get one constant-time check of warm_state.

Other deployer impact

  • New options:

    • [deploy]warm_available, default False, mutable.

    • [deploy]warm_available_heartbeat_timeout, default 300. A warm node whose last heartbeat is older than this is no longer warm. The value must be longer than the agent heartbeat interval, so that a healthy agent does not look stale between two heartbeats.

    • [conductor]warm_available_check_interval, default 60.

    • [deploy]warm_available_max_attempts, default 3, in phase 2. The number of re-warm attempts before a node becomes cold.

  • Warm nodes use power while idle. Enable the feature where lower deployment latency matters more than idle power, for example during a redeployment window.

Developer impact

Deploy interface authors can opt in by implementing prepare_warm_available.

Implementation

Assignee(s)

Primary assignee:

Jakub Jelinek <kuba.jelinek@nscale.com>

Other contributors:

John Garbutt <john.garbutt@nscale.com>

Work Items

Phase 1:

  • Add the warm_state column, the database migration and the Node object field.

  • Add the configuration options and a warm_available_enabled(node) helper. The helper returns False for nodes with disable_power_off set or when [agent]manage_agent_boot is False.

  • Add DeployInterface.prepare_warm_available and implement it in AgentBaseMixin.

  • Before warm-up, compare get_cleaning_network_uuid and get_provisioning_network_uuid for the neutron interface.

  • Change tear_down_inband_cleaning so that it always powers off when warm-up is requested.

  • In do_node_clean_abort and cleaning_error_handler, remove the provisioning network instead of the cleaning network during warm-up.

  • Call the warm-up at the end of do_next_clean_step, and handle the warm-up heartbeat in AgentBaseMixin.heartbeat.

  • Allow lookup and heartbeat on available nodes with warm_state set to warm, separately from the fast track rules.

  • Add the cold fallback to _check_cleanwait_timeouts.

  • Add the _check_warm_available_nodes periodic task.

  • Clear warm_state on API power actions, port and interface changes, maintenance, and provision state changes out of available. Do not clear it on VIF attach or detach.

  • In AgentDeploy.prepare and CustomAgentDeploy.deploy, reuse the agent on warm nodes, with the port guard.

  • Add the API microversion and the query parameter.

  • Add client and openstacksdk support.

  • Add a release note and admin documentation.

Phase 2:

  • Re-warm stale warm and warming nodes in _check_warm_available_nodes, with the attempt counter and [deploy]warm_available_max_attempts.

  • Allow lookup and heartbeat on available nodes with warm_state set to warming.

  • Finish cleaning with a warming node when the warm-up times out.

  • Add a release note and update the admin documentation.

Dependencies

None.

Testing

  • Unit tests for each new branch. This includes the token order with a pre-generated token, the lookup and heartbeat guards with fast track disabled, the skip for disable_power_off, the cold fallback on timeout and its failure path, the periodic task, the events that clear warm_state, a VIF attach that keeps the node warm, the lock race with a deployment, and the port guard at deployment time.

  • API tests for the new field, the query parameter and the microversion.

  • A tempest scenario in an existing multi-tenant networking job with warm available and fast track disabled. It cleans a node and waits until the node is available with warm_state set to warm. The power cycle at the end of cleaning is expected. It then deploys the node. It makes sure that no power cycle happens after the deployment request and before the image write, and that the handoff to the tenant network works.

  • A negative scenario that powers off a warm node out of band. In phase 1, it makes sure that the periodic task makes the node cold. In phase 2, it makes sure that the node becomes warm again or becomes cold after the retry limit.

Upgrades and Backwards Compatibility

The feature is off by default. With it disabled, the cleaning and deployment code paths behave as they do today, and tear_down_inband_cleaning still skips power off for fast-tracked nodes. Deploy interfaces that do not implement the new method are not affected.

The database migration adds a nullable column, so it is safe during a rolling upgrade. The Node object version bump follows the usual pinning rules. Enable the option only after all conductors run the new code. An older conductor that takes over a CLEANWAIT node treats the warm-up heartbeat as a normal clean step heartbeat, and it does not run the periodic task.

Documentation Impact

  • Add an admin guide page for warm available. It describes the network requirements, the security considerations, the idle power cost and the virtual media behavior.

  • Add a link to it from the fast track page, with a note on how the two features differ.

  • Add configuration reference entries for the new options.

  • Add API reference entries for the new field and query parameter.

References

  • ironic/conductor/utils.py: fast_track_able, is_fast_track and wipe_token_and_url

  • ironic/conductor/manager.py: _check_cleanwait_timeouts and periodics.node_periodic

  • ironic/drivers/modules/deploy_utils.py: prepare_inband_cleaning and tear_down_inband_cleaning

  • ironic/drivers/modules/network/neutron.py: _add_network, which rolls back existing ports

  • Fast track admin documentation: https://docs.openstack.org/ironic/latest/admin/fast-track.html