Skip to content

Support attaching to an existing request queue in HTTP.SYS #14182

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

Merged

Conversation

bkatms
Copy link
Contributor

@bkatms bkatms commented Sep 20, 2019

Support attaching to an existing request queue in HTTP.SYS ( #5866). This is an addendum to
https://github.com/aspnet/AspNetCore/issues/13461”.

This is criticial (P0) functionality required by Office 365 in support of our new ASP.Net Core 3.X architecture for data access to Substrate Storage. This is the storage that is mission critical for Office 365.

@dnfclas
Copy link

dnfclas commented Sep 20, 2019

CLA assistant check
All CLA requirements met.

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

Thanks, getting this rebased does help.

There are some open issues from #5866 that we hadn't figured out how to address yet. Most of these are centered around ensuring each listener on a queue is using the same configuration. For things like timeouts it's at most a warning that the config is out of sync, but for auth and PathBase it can affect how requests are processed.

  • PathBase will need a fallback mode when attached to existing queues where it can't look things up by index.
  • For auth we might want to query the queue settings to see if they match and fail otherwise
  • I'm not sure if we can query for the timeout settings.
  • Some options can be changed after the server starts such as UrlPrefixes. We need to make sure those code paths are disabled (and throw?) if this instance did not create the queue.
  • Do we need to surface an API that says if this instance did attach or create?

I'll pull your branch and see what I can work on in your off hours. Want to give me push access to your fork?

@analogrelay
Copy link
Contributor

FYI @Tratcher check in with me before merging. As this is feature work we'll require special approval for 3.1 (shouldn't be a problem).

@Tratcher Tratcher changed the title #5866 Support attaching to an existing request queue in HTTP.SYS Sep 20, 2019
@Tratcher Tratcher self-assigned this Sep 20, 2019
@Tratcher
Copy link
Member

Didn't make any progress on this today other than squashing and relocating my old branch to make it easier to reference: 2c48243

@Tratcher
Copy link
Member

Made some progress, I pulled in the missing parts from the prior branch including tests and some misc fixes. I'll start on the actual review tomorrow.

@davidfowl davidfowl added the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Sep 24, 2019
@Tratcher Tratcher force-pushed the bkress/httpsysexistingq branch from 27a8b65 to bf83d2c Compare September 24, 2019 19:53
@Tratcher
Copy link
Member

Tratcher commented Sep 27, 2019

I think that's everything for now.

  • I've dealt with PathBase. It can't query prefixes configured elsewhere but can do a match against ones you provide in the app.
  • For auth you must make sure your schemes are in sync or it's not going to work well. We can discuss guardrails in the future if people have issues.
  • Many settings are marked as not applicable in Attach mode.
  • If using CreateOrAttach, there is a log statement indicating if it attached but there's no API to show the results in the app. This isn't a priority for 3.1 since our driving customer doesn't plan to use CreateOrAttach. In the future consider surfacing this as a server feature? I'm not sure what scenarios would require knowing the difference (HotAdd maybe?).
  • Suppressed default urls when attached to an existing queue. This is going to case a 5.x merge conflict because Justin recently refactored that code path in master.

@halter73 @bkatms please review.

@analogrelay
Copy link
Contributor

analogrelay commented Sep 27, 2019

paging @davidfowl @rynowak for API review (not sure who else wants to be involved or if a GitHub team has been set up yet).

@bkatms
Copy link
Contributor Author

bkatms commented Sep 27, 2019

The changes look fine to me. Thank you.

@bkatms
Copy link
Contributor Author

bkatms commented Sep 27, 2019

Note relative to "Created" - my understanding is that HTTP.SYS will automatically delete a queue if there are no active references to it by any process.

In our case we will have a management process create and configure the queues and pass then name into our ASP.NET Core process - this is similar to how IIS works when it starts W3WP.exe. We will either directly spawn (security context inheritance) or set the ACLs appropriately - TBD. In any case we plan on handling that part.

Let me know when you have a drop for me to begin testing on.

Cheers!

@@ -32,6 +32,9 @@ internal AuthenticationManager()
{
}

/// <summary>
/// When attaching to an existing queue this setting must match the one used to create the queue.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be a remark rather than summary.

Copy link
Member

Choose a reason for hiding this comment

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

Remarks aren't visible in most situations.

out requestQueueHandle);
}

if (flags == HttpApiTypes.HTTP_CREATE_REQUEST_QUEUE_FLAG.OpenExisting && statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_FILE_NOT_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this technically check CreateOrAttach and OpenExisting?

Copy link
Member

@Tratcher Tratcher Sep 30, 2019

Choose a reason for hiding this comment

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

That's why I'm checking the flags and not the RequestQueueMode enum.

Edit: Nevermind, I answered the wrong question. No, you want this detailed error for both Attach and CreateOrAttach. You tried to attach to a thing by name and it wasn't there. For CreateOrAttach that should only happen with a strange race condition.

Copy link
Contributor

Choose a reason for hiding this comment

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

For CreateOrAttach that should only happen with a strange race condition.

Yeah, the strange race condition is what I was referring to.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's really worth guarding against that race condition, since to do so would require some sort of looping.

@Tratcher Tratcher force-pushed the bkress/httpsysexistingq branch from 8c8e0ad to 9dc1ec6 Compare October 1, 2019 15:26
@Tratcher Tratcher changed the base branch from release/3.1 to release/3.1-preview1 October 1, 2019 15:26
@analogrelay
Copy link
Contributor

@davidfowl this needs to be merged Very Soon. What if anything do you want to do for API review here?

@davidfowl
Copy link
Member

davidfowl commented Oct 1, 2019

For auth you must make sure your schemes are in sync or it's not going to work well. We can discuss guardrails in the future if people have issues.

Many settings are marked as not applicable in Attach mode.

What’s the failure mode here?

@Tratcher
Copy link
Member

Tratcher commented Oct 1, 2019

For auth you must make sure your schemes are in sync or it's not going to work well. We can discuss guardrails in the future if people have issues.

Many settings are marked as not applicable in Attach mode.

What’s the failure mode here?

The managed layer enforces AllowAnonymous and adds challenges based on what's configured. Worst case you end up requiring more auth than the underlying queue supports and the client gets rejected with 401s.

@bkatms
Copy link
Contributor Author

bkatms commented Oct 1, 2019 via email

@Tratcher
Copy link
Member

Tratcher commented Oct 1, 2019

@anurse this is ready to merge.

@analogrelay analogrelay merged commit 51ae61b into dotnet:release/3.1-preview1 Oct 1, 2019
@pranavkm pranavkm removed the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Mar 22, 2021
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants