Skip to content

want sled-agent timeout on completion of requests to stop a Propolis VM #4004

Closed

Description

@gjcolombo

Today, requests to stop a running instance must by necessity involve the instance's active Propolis (sled agent sends the stop request to Propolis; the instance is stopped when Propolis says so, at which point sled agent cleans up the Propolis zone and all related objects). If an instance's Propolis is not responding, or there is no active Propolis, there is no obvious way to clean up the instance and recover.

A short-term workaround is to grant some form of API access to sled agent's "unregister instance" API, which forcibly executes the termination path (tearing down the Propolis zone and removing the instance from the sled's instance table) and can get force an instance into a stopped state.

In the long run instance lifecycle management needs to be made more robust to Propolis failure and/or non-responsiveness.

Activity

  1. added
    Sled Agent
    nexus
    on Aug 31, 2023
  2. jordanhendricks commented on Sep 25, 2023

    @jordanhendricks
    Contributor

    Related: #3209

  3. changed the title [-]Instance stop doesn't work if Propolis panics or is unreachable[/-] [+]Want mechanism to forcibly remove an instance's active VMMs irrespective of instance state[/+] on Oct 6, 2023
  4. gjcolombo commented on Oct 6, 2023

    @gjcolombo
    ContributorAuthor

    In #4194, sled agent's "instance unregister" API assumes that it can produce the correct posterior VMM and instance states by emulating a "Propolis destroyed" state transition. (That is, sled agent's "rudely terminate this instance" function computes the next state by pretending that it immediately got a message from the current VMM that says "I am destroyed and my current migration has failed.")

    This is fine today because the unregister API is only used when unwinding start and migrate sagas, where the VMMs that are subject to unregistration have by definition not gotten to do anything interesting yet. It's less fine if Propolis has already begun to run, and especially not fine if we're force-quitting an instance that's a migration target:

    1. Source and target VMMs agree that migration is done
    2. Just before they tell their respective sled agents, Nexus shows up and rudely terminates the source
    3. The emulated "VMM destroyed, migration failed" transition retires the source and the migration, which makes it possible to start the instance again...
    4. ...but the target might actually begin to run while this is happening!

    This seems dangerous. We probably want to adjust the synchronization here to be something more like the following:

    1. Nexus "disowns" a particular VMM, e.g. by replacing its ID in an instance record with a zeroed ID (or some other set of sentinel values that prevents the instance from restarting)
    2. Nexus terminates all of the disowned VMMs
    3. Nexus clears out the sentinels to allow the instance to start again

    This would need to be done in a saga to ensure the whole process runs to completion. More design work's needed here. We just need to do that work before we hook up any external APIs to the existing instance_ensure_unregistered sled agent interface.

  5. davepacheco commented on Jan 26, 2024

    @davepacheco
    Collaborator

    Also related: #4872

  6. added
    known issue
    on Mar 9, 2024
  7. added this to the 8 milestone on Mar 9, 2024
  8. modified the milestones: 8, 9 on Apr 24, 2024
  9. modified the milestones: 9, 10 on Jul 1, 2024
  10. modified the milestones: 10, 11 on Aug 14, 2024
  11. 8 remaining items

  12. added this to the 13 milestone on Nov 26, 2024
  13. hawkw commented on Jan 30, 2025

    @hawkw
    Member

    #6915 and #6913 solved (at least a subset) of problems related to killing instances that are in a stuck state, so now the normal shutdown API in sled-agent should basically be equivalent to force-shutdown as far as we are capable of having such a thing. I think this probably ought to be closed; what do you think @gjcolombo?

  14. gjcolombo commented on Feb 1, 2025

    @gjcolombo
    ContributorAuthor

    Instead, we might consider just making the system resilient to Propolis getting stuck or misbehaving whilst shutting down

    I thought we still needed to deal with this part (i.e., if Propolis is stuck in Starting or Stopping, then a request to stop its instance won't resolve). I think we should have an issue (this one or another one) tracking that behavior, since there's currently no other way to deal with an instance that's wedged waiting for Crucible activation (though that specific case might be resolvable by other means, see oxidecomputer/propolis#841).

  15. hawkw commented on Feb 11, 2025

    @hawkw
    Member

    @gjcolombo sorry I missed your reply from earlier. Just to clarify, is this:

    I thought we still needed to deal with this part (i.e., if Propolis is stuck in Starting or Stopping, then a request to stop its instance won't resolve). I think we should have an issue (this one or another one) tracking that behavior...

    a change in Propolis, or in Omicron?

    As I understand it, Nexus will happily send a stop request to sled-agent for an instance that's Starting, but I believe that the the sled-agent's only way of handling that request is to send a HTTP request to Propolis. As of #6915, the sled-agent should send that request immediately even if it's waiting on an outstanding request to perform some other operation. But, I'm not sure off the top of my head whether Propolis will be able to handle that request if it's waiting for Crucible activation.

    Is my understanding correct? If so, it seems to me that maybe we should close this and go open a Propolis ticket about prioritizing requests to terminate...or, we should give the sled-agent a way to tear down the Propolis zone violently should it fail to handle a shutdown request.

  16. modified the milestones: 13, 14 on Feb 12, 2025
  17. gjcolombo commented on Feb 13, 2025

    @gjcolombo
    ContributorAuthor

    We checked in on this in today's hypervisor huddle. I believe the consensus was that

    1. sled agent should have a timeout (a long timeout, on the order of several minutes, but a timeout) on requests to stop a Propolis VM; if the timeout expires before the VM enters the Destroyed state, sled agent should rudely terminate the Propolis zone and move the instance to failed; and
    2. we should still aim to fix propolis#841 as soon as possible, since this is the primary issue causing instances to get into a state where one would rely on this kind of timeout.
  18. changed the title [-]Want mechanism to forcibly remove an instance's active VMMs irrespective of instance state[/-] [+]want sled-agent timeout on completion of requests to stop a Propolis VM[/+] on Feb 13, 2025
  19. leftwo commented on Feb 13, 2025

    @leftwo
    Contributor

    I believe I found another way to trigger this situation.
    If you expunge a sled with running instances, then those instances are auto-restarted on a new sled.
    That start can race with downstairs repair, and if an instance is started first, it will have an old VCR (that needs repair).
    The instance with the old VCR won't be able to activate because one of the three downstairs is now missing.
    So, no activation, and that means propolis can't act on any repair request that nexus sends it.

  20. added a commit that references this issue on Feb 14, 2025
    09d06f1
  21. hawkw commented on Feb 14, 2025

    @hawkw
    Member

    Okay, I put together a quick pass on the shutdown timeout: #7548

    I still need to actually test that this handles the cases we care about before merging that PR, but I'm pretty sure the timeout should cover the entire shutdown process, starting from when we send the PUT to Propolis with the Stopped state.

  22. added a commit that references this issue on Feb 21, 2025
    290a639
  23. added a commit that references this issue on Feb 24, 2025
    459fca4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Sled Agentknown issuenexus

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions