Skip to content

503 error when snapshotting disks attached to stopped instances #3289

Closed

Description

@askfongjojo

I think I have seen the 503 before but mistaken that as a control plane issue:

$ oxide snapshot create --name loadgen-snap-stoppedvm --disk loadgen --description "disk attached to vm" --project try
error
Error Response: status: 503 Service Unavailable; headers: {"content-type": "application/json", "x-request-id": "7c2b9888-1d8f-43c7-8dd7-8bec8167ca8f", "content-length": "133", "date": "Sun, 04 Jun 2023 06:29:02 GMT"}; value: Error { error_code: Some("ServiceNotAvailable"), message: "Service Unavailable", request_id: "7c2b9888-1d8f-43c7-8dd7-8bec8167ca8f" }

(Once I started up the VM, I was able to create snapshots for both of the disks attached to this vm on rack2.)

If snapshot is prohibited on disks attached to stopped instances, we should probably prevent the snapshot action with a more explicit error. A 503 response would imply that the service is only temporarily unavailable and user may retry the action.

If snapshots should be allowed on disks, then it is a functional issue.

Activity

  1. added this to the FCS milestone on Jun 4, 2023
  2. jmpesp commented on Jun 5, 2023

    @jmpesp
    Contributor

    In this case, it's a functional issue. Taking a snapshot of an attached disk is allowed.

  3. added
    known issue
    on Jul 6, 2023
  4. jmpesp commented on Jul 7, 2023

    @jmpesp
    Contributor

    Here's the bug in the snapshot create saga:

    match db_disk.state().into() {
    external::DiskState::Detached => {
    info!(log, "setting state of {} to maintenance", params.disk_id);
    osagactx
    .datastore()
    .disk_update_runtime(
    &opctx,
    &authz_disk,
    &db_disk.runtime().maintenance(),
    )
    .await
    .map_err(ActionError::action_failed)?;
    }
    external::DiskState::Finalizing => {
    // This saga is a sub-saga of the finalize saga if the user has
    // specified an optional snapshot should be taken. No state change
    // is required.
    info!(log, "disk {} in state finalizing", params.disk_id);
    }
    _ => {
    // Return a 503 indicating that the user should retry
    return Err(ActionError::action_failed(
    Error::ServiceUnavailable {
    internal_message: format!(
    "disk is in state {:?}",
    db_disk.state(),
    ),
    },
    ));
    }
    }

    The disk state here is expected to be Detached, but if the disk is attached to a stopped instance this match will return 503. The part of Nexus that checks whether or not the Pantry should be used to take a snapshot says to use the Pantry if the instance is stopped:

    match instance_state {
    // If there's a propolis running, use that
    InstanceState::Running |
    // Rebooting doesn't deactivate the volume
    InstanceState::Rebooting
    => false,
    // If there's definitely no propolis running, then use the
    // pantry
    InstanceState::Stopped | InstanceState::Destroyed => true,
    // If there *may* be a propolis running, then fail: we can't
    // know if that propolis has activated the Volume or not, or if
    // it's in the process of deactivating.
    _ => {
    return Err(
    Error::invalid_request(
    &format!("cannot snapshot attached disk for instance in state {}", instance_state)
    )
    );
    }

    There needs to be more work here: at the minimum, the disk's state changes to Maintenance as part of this saga, and this has to work with (read: block) the instance from starting. This may not be a candidate for FCS though, due to the workaround of starting the instance existing?

  5. askfongjojo commented on Jul 8, 2023

    @askfongjojo
    Author

    Thanks for root-causing/sizing this. Let's re-target this to MVP give the effort and impact involved. I'll document this known issue in the release notes because users will likely want to create clean snapshots on stopped instances (so that things such as temporary files locks created by running applications won't be part of the snapshot).

  6. modified the milestones: FCS, MVP, 1.0.1 on Jul 8, 2023
  7. askfongjojo commented on Jul 25, 2023

    @askfongjojo
    Author

    Want to note that a customer indicated that they would like to see a fix for this issue sooner for the same reason I mentioned above (i.e. their best practice is to create snapshots on stopped instances).

  8. modified the milestones: MVP, 1.0.2 on Aug 14, 2023
  9. 2 remaining items

  10. modified the milestones: 1.0.3, 3 on Sep 1, 2023
  11. modified the milestones: 3, 4 on Oct 17, 2023
  12. modified the milestones: 4, 5 on Nov 14, 2023
  13. modified the milestones: 5, 6 on Dec 5, 2023
  14. modified the milestones: 6, MVP+1 on Jan 19, 2024
  15. added a commit that references this issue on Mar 7, 2024
    630e5e9
  16. modified the milestones: MVP+1, 8 on Mar 9, 2024
  17. added a commit that references this issue on Apr 3, 2024
    35dfd9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

known issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions