Skip to content

need a way to trigger cleanup and next steps for vanished instances #4872

Closed

Description

@davepacheco

There are various cases where the control plane might discover that Instances that we thought were running are, in fact, not. Examples (from concrete to speculative):

  • when Nexus is notified by Sled Agent (in turn notified from Propolis) that a guest is no longer running (because it was stopped from inside the guest)
  • when a sled reboots, its instances are all gone and this process needs to be applied to each of them (this is restart customer Instances after sled reboot #3633)
  • when we implement support for (ungraceful) sled removal, we'll need to apply this to all of the instances that we thought were on the system that's been removed
  • we probably want some periodic task that asks Sled Agent what instances it's running and compares that to what we think it should be running
  • we may want a periodic task that monitors sleds and, if we find that they seem to be unexpectedly not responding, takes steps to make sure that they're offline (i.e., power cycles them via Ignition) and then applies this process for any instances on them

Relaying some notes from @gjcolombo (my apologies where I've got these details wrong):

  • this code path exists today where we handle the first case above (where Nexus handles a message from Sled Agent saying the instance is no longer running)
  • this code path has some issues and is not well factored use in other contexts like we need here
  • all of this would be reworked by Tracking: Instance Lifecycle Overhaul #3742
  • the "cleanup" referred to here includes: foreign key from instance to vmm table needs to be reaped; networking state needs to be cleaned up; provisioning counters and sled resources need to be cleaned up; etc.
  • the "next steps" referred to here include: looking at some per-instance "fault discipline" (currently the "boot_on_fault" boolean) to determine if we should start the instance running again somewhere else and, if so, doing that

We may view this issue as a dup of #3742 but I wanted to file this separate ticket to reflect more precisely what's needed for sled removal. The implementation may well just be #3742.

Activity

  1. added
    virtualization
    on Jan 23, 2024
  2. gjcolombo commented on Jan 23, 2024

    @gjcolombo
    Contributor

    #4226 is also tangentially related. Today Nexus uses the "Failed" instance state to mean, more or less, "something went wrong during some operation on this instance," and the only recovery action we support is deleting the instance (see #2825). #4226 proposes distinguishing between different values of "something" so that we can recover appropriately: transient error conditions might resolve on retry, but if a sled reports that a VMM is definitely gone then the error is permanent.

    4226 could possibly be resolved without handling cases like "the operator says this sled is gone, so all the living VMMs there should immediately be marked as gone," so these issues aren't duplicates. But I think they're all dancing around a single concept--Nexus should have an idea of a VMM's "health," which I think could start out along these lines:

    • this VMM was healthy the last time we checked on it
    • we weren't able to ascertain whether the VMM was healthy when we last checked on it (e.g. maybe it's running fine and its sled agent is borked?)
    • this VMM is definitely dead (sled agent returned an empty VMM zone list, the operator said the sled was pulled, etc.)

    Then there should be some code path that periodically deals with "definitely-dead" VMMs that are still pointed to by their Instances, as discussed above, and the "rudely remove a sled" API would just need to mark the target VMMs as "definitely stopped, did not gracefully shut down."

  3. added
    known issue
    on Mar 9, 2024
  4. added this to the 8 milestone on Mar 9, 2024
  5. modified the milestones: 8, 9 on Apr 24, 2024
  6. modified the milestones: 9, 10 on Jul 1, 2024
  7. modified the milestones: 10, 11 on Aug 13, 2024
  8. self-assigned this
    on Sep 2, 2024
  9. hawkw commented on Sep 2, 2024

    @hawkw
    Member

    PR #6455 will move instances to InstanceState::Failed when the sled-agent believes that the instance's active VMM is no longer present. This happens when a sled reboots (as well as if the instance's VMM crashes). That PR changes the semantics of the Failed state so that Failed instances are now eligible to be restarted or deleted, and ensures that the sled resources and virtual provisioning resources allocated to such instances are cleaned up by an instance-update saga before the instance is transitioned to Failed.

    Transitions to Failed are triggered by both API requests that attempt to change the state of an instance that's no longer there, and the instance-watcher background task added in #5611 when a sled-agent definitively indicates that it no longer knows about the instance's VMM. So, that checks off

    • we probably want some periodic task that asks Sled Agent what instances it's running and compares that to what we think it should be running

    We don't currently transition instances to Failed in the face of communication errors, as described in

    • we may want a periodic task that monitors sleds and, if we find that they seem to be unexpectedly not responding, takes steps to make sure that they're offline (i.e., power cycles them via Ignition) and then applies this process for any instances on them

    as that kind of health checking is a bit more complex, but we could certainly start transitioning instances to Failed once we start doing sled-level health checks.

    Once #6455 is merged, PR #6499 refactors instance.boot_on_fault into an enum to allow more expressive auto-restart policies, and #6503 adds a background task for automatically restarting Failed instances if the auto-restart policy allows it. By default, instances are not currently allowed to be automatically restarted; we'll probably want to wire up a way for users to specify this policy when creating instances.

  10. davepacheco commented on Sep 3, 2024

    @davepacheco
    CollaboratorAuthor

    @hawkw That all makes sense. So in terms of the main ask in this ticket: when Reconfigurator expunges a sled and wants to clean up all those instances, what do we do? Would it be enough to activate the instance-watcher task? Would that task correctly handle instances whose database state shows a vmm on a sled that is now expunged?

  11. hawkw commented on Sep 3, 2024

    @hawkw
    Member

    @hawkw That all makes sense. So in terms of the main ask in this ticket: when Reconfigurator expunges a sled and wants to clean up all those instances, what do we do? Would it be enough to activate the instance-watcher task? Would that task correctly handle instances whose database state shows a vmm on a sled that is now expunged?

    The instance-watcher task does not presently handle that case. At present, it only marks instances as Failed when the sled-agent for that instance responds with an error indicating that it definitively does not believe it's supposed to have that instance (which is what would happen if the sled rebooted, or if the Propolis went away).

    Right now, the query that the instance-watcher task uses to find sleds to health-check selects only InService sleds:

    .sled_filter(SledFilter::InService)

    However, we could pretty easily remove that, and we could change the task to check the state of the sled before starting a health check, and if the sled has been expunged, just go ahead and mark all its VMMs as Failed instead of actually sending a HTTP request to the sled-agent. I'd be happy to go do that!

  12. davepacheco commented on Sep 24, 2024

    @davepacheco
    CollaboratorAuthor

    Whether or not we consider this done, I think the pieces we were tracking for add/remove sled are done (#6519, #6503) so I'm removing this from the Reconfigurator board.

  13. hawkw commented on Sep 24, 2024

    @hawkw
    Member

    I think that this is done, modulo:

    • we may want a periodic task that monitors sleds and, if we find that they seem to be unexpectedly not responding, takes steps to make sure that they're offline (i.e., power cycles them via Ignition) and then applies this process for any instances on them

    But, that seems like a substantial enough chunk of work that it might be better considered its own project (and perhaps deserves an RFD?). As far as explicit expungement, I'm for marking this one as done and moving forward potential automated reboots of disappeared sleds into its own thing.

  14. hawkw commented on Sep 26, 2024

    @hawkw
    Member

    I'm gonna close this out, I think that that detecting unresponsive sleds seems like it'll be part of the ongoing FMA/health-checking work.

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

Metadata

Metadata

Labels

known issuevirtualization

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions