Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[propolis] address cancel-safety issues with InstanceSerialConsoleHelper::recv #435

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Jun 14, 2023

TODO:

  • Expand on documentation.
  • Tests

See #434 and inline comments.

Created using spr 1.3.4
@sunshowers sunshowers marked this pull request as draft June 14, 2023 23:51
@pfmooney pfmooney requested a review from lifning June 14, 2023 23:51
@sunshowers
Copy link
Contributor Author

So sadly this means that while a migration is happening, the other select branches (and therefore progress) will be completely blocked. There is likely a way to write recv() such that other select branches aren't blocked. Going to give that a shot.

@lifning
Copy link

lifning commented Jun 15, 2023

So sadly this means that while a migration is happening, the other select branches (and therefore progress) will be completely blocked. There is likely a way to write recv() such that other select branches aren't blocked. Going to give that a shot.

I think it's actually okay to block the other select branch in this case - if a Text frame has been sent, it means the rest of the migration has completed already, and we shouldn't send characters any more until the InstanceSerialConsoleHelper's had its ws_stream replaced with the connection to the destination instance.

Copy link

@lifning lifning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP looks good so far. I'm currently imagining that tests might look like one demonstrating that putting a future that effectively does x = ws.recv().process() => { ... } in the select! causes the message to be lost outright, and one where x = ws.recv() => { x.process() ... } doesn't, where to avoid flaking we can force the cancellations to be predictable by having the 'destination server' be some mock that'll accept the client.instance_serial() call's connection and stall until we explicitly tell it to finish the handshake.

/// # Cancel safety
///
/// This method is cancel-safe and can be safely used in a `select!`
/// loop. However, to , and that portion is not cancel-safe.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this should say something like However, [InstanceSerialConsoleMessage::process] must be awaited to retrieve the inner [WSMessage], and that portion is not cancel-safe.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Created using spr 1.3.4
@sunshowers sunshowers changed the title [WIP] [propolis] address cancel-safety issues with InstanceSerialConsoleHelper::recv [propolis] address cancel-safety issues with InstanceSerialConsoleHelper::recv Jun 16, 2023
@sunshowers sunshowers merged commit 85d901d into master Jun 16, 2023
@sunshowers sunshowers deleted the sunshowers/spr/wip-propolis-address-cancel-safety-issues-with-instanceserialconsolehelperrecv branch June 16, 2023 17:02
sunshowers added a commit that referenced this pull request Jun 21, 2023
We regressed on this in #435. Ensure that it's Send, and statically
assert it.
sunshowers added a commit that referenced this pull request Jun 21, 2023
In #435 we moved all connection management to inside the
`InstanceSerialConsoleHelper`. For testing purposes in omicron we need
to expose something that can build a console helper out of any stream.

(We were already using this code for tests in propolis, but omicron has
its own tests.)
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.

2 participants