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

api: use singleflight for /info endpoint #45847

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jun 29, 2023

Prevent potential suggestion when many concurrent requests happen on the /info endpoint. It's worth noting that with this change, requests to the endpoint while another request is still in flight will share the results, hence might be slightly incorrect (for example, the output includes SystemTime, which may now be incorrect).

Assuming that under normal circumstances, requests will still happen fast enough to not be shared, this may not be a problem, but we could decide to update specific fields to not be shared.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah changed the title [rfc] api: use singleflight for /info endpoint api: use singleflight for /info endpoint Jun 30, 2023
@thaJeztah thaJeztah marked this pull request as ready for review June 30, 2023 00:01
Comment on lines 69 to 70
version := httputils.VersionFromContext(ctx)
if versions.LessThan(version, "1.25") {
Copy link
Member Author

Choose a reason for hiding this comment

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

Hm.. so thinking about this; if info (as returned above) is gonna be shared, and it's a pointer, then I guess the steps below wouldn't really work (as they would now modify all requests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed this by using the API version as key for the single-flight

@thaJeztah thaJeztah force-pushed the sysinfo_singleflight branch 2 times, most recently from af0f982 to ececb80 Compare July 3, 2023 11:56
@thaJeztah
Copy link
Member Author

@vvoland #45873 also looks good to you? That's the first commit of this PR 😅

Prevent potential suggestion when many concurrent requests happen on
the /info endpoint. It's worth noting that with this change,
requests to the endpoint while another request is still in flight
will share the results, hence might be slightly incorrect (for example,
the output includes SystemTime, which may now be incorrect).

Assuming that under normal circumstances, requests will still
happen fast enough to not be shared, this may not be a problem,
but we could decide to update specific fields to not be shared.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

Rebased; this now only contains the singleflight changes

@thaJeztah
Copy link
Member Author

For reviewers; this one is easiest to review with "whitespace" hidden in the diff; use this link to hide whitespace in the diff; https://github.com/moby/moby/pull/45847/files?w=1

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

Still LGTM

@thaJeztah thaJeztah added this to the 25.0.0 milestone Jul 4, 2023
@thaJeztah
Copy link
Member Author

Let me bring this one in; we discussed this PR in a maintainers call;

  • w.r.t. the SystemTime field being "shared", we concluded that that time was always "time of sample", so even if that time was shared between two concurrent requests, there never was a guarantee for that time to be "moment of response being returned"
  • the same applies to other information; the info endpoint always returns a "snapshot in time" of the state (containers may start/stop during the request), so no concerns about inconsistency there.

@thaJeztah thaJeztah merged commit 4ee0cf6 into moby:master Jul 4, 2023
102 checks passed
@thaJeztah thaJeztah deleted the sysinfo_singleflight branch July 4, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants