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

Fix IIS recycle regressions #59998

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

BrennanConroy
Copy link
Member

Fixes #58939 and both issues mentioned in #54531, both the empty path issue described in the initial post and the bad shutdown mentioned in #54531 (comment)

These were regressed by #52807

The two regressions were:

  1. If any application in the same app pool (only OutOfProcess supports this) was modified we would end up triggering our shutdown logic even if it wasn't for our app, and additionally we shut down the whole w3wp process instead of just the specific application.
  2. If disallowRotationOnConfigChange was true we would still shutdown the application on config changes.

The third fix wasn't a regression but was simple enough to fix and part of one of the issues linked above so included a fix for it. Our usage of _wcsicmp didn't properly check the path started with "MACHINE/WEBROOT", it would pass for "", or "MAC", "MACHINE/W", etc.

We have the test ConfigurationChangeCanBeIgnoredInProcess which should have caught one of the regressions, but since it was testing for the lack of app shutdown it doesn't have any way to know that nothing happened, fixed the test to have a bit of a delay so it has a better chance of failing in the future if we regress this.

We also have a multiple application test, but it was only running for IISExpress and it didn't have a restart scenario. Moved the test to the common tests so it's run by IIS as well and added a scenario where 1 of the applications restarts but the others don't.

@BrennanConroy BrennanConroy added feature-iis Includes: IIS, ANCM area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Jan 22, 2025
@@ -51,7 +51,7 @@ internal IISTestSiteFixture(Action<IISDeploymentParameters> configure)
//DeploymentParameters.EnvironmentVariables.Add("ASPNETCORE_MODULE_DEBUG", "console");

// This queue does not have websockets enabled currently, adding the module will break all tests using this fixture.
if (!HelixHelper.GetTargetHelixQueue().ToLowerInvariant().Contains("windows.amd64.server2022"))
if (!(HelixHelper.GetTargetHelixQueue() ?? "").ToLowerInvariant().Contains("windows.amd64.server2022"))
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix local websocket tests.

<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
<logFile logFormat="W3C" directory="%TEMP%\IISTests\Logs" />
<traceFailedRequestsLogging directory="%TEMP%\IISTests\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Write logs to temp instead of user directory. If you know, you know.

@BrennanConroy BrennanConroy marked this pull request as ready for review January 22, 2025 22:23
@BrennanConroy BrennanConroy requested a review from Copilot January 28, 2025 22:25

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 19 changed files in this pull request and generated no comments.

Files not reviewed (14)
  • src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationmanager.cpp: Language not supported
  • src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationmanager.h: Language not supported
  • src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/globalmodule.cpp: Language not supported
  • src/Servers/IIS/IntegrationTesting.IIS/src/Http.SubApp.config: Language not supported
  • src/Servers/IIS/IntegrationTesting.IIS/src/Http.config: Language not supported
  • src/Servers/IIS/IIS/test/IISExpress.FunctionalTests/OutOfProcess/MultipleAppTests.cs: Evaluated as low risk
  • src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentParameterExtensions.cs: Evaluated as low risk
  • src/Servers/IIS/IIS/test/Common.FunctionalTests/RequestResponseTests.cs: Evaluated as low risk
  • src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs: Evaluated as low risk
  • src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/EventLogHelpers.cs: Evaluated as low risk
  • src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/IISTestSiteFixture.cs: Evaluated as low risk
  • src/Servers/IIS/IntegrationTesting.IIS/src/IISDeployerBase.cs: Evaluated as low risk
  • src/Servers/IIS/IntegrationTesting.IIS/src/IISExpressDeployer.cs: Evaluated as low risk
  • src/Servers/IIS/IIS/test/Common.FunctionalTests/MultiApplicationTests.cs: Evaluated as low risk
Comments suppressed due to low confidence (2)

src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs:259

  • Ensure that the change to select the last site element is covered by tests.
.Elements("site").Last();

src/Servers/IIS/IntegrationTesting.IIS/src/IISDeployer.cs:34

  • The variable _siteId is incremented without any checks or resets. This could potentially lead to an overflow if the application runs for a very long time and many sites are created. Consider adding a check to reset or handle the overflow scenario.
private int _siteId = 2;
@@ -161,18 +161,18 @@ public static string InProcessStarted(IISDeploymentResult deploymentResult)

public static string OutOfProcessStarted(IISDeploymentResult deploymentResult)
{
return $"Application '/LM/W3SVC/1/ROOT' started process '\\d+' successfully and process '\\d+' is listening on port '\\d+'.";
return $"Application '/LM/W3SVC/\\d+/ROOT' started process '\\d+' successfully and process '\\d+' is listening on port '\\d+'.";
Copy link
Member

@captainsafia captainsafia Jan 29, 2025

Choose a reason for hiding this comment

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

Why are we loosening from strictly matching on 1 to any digit here? I see there are other updates related to multi-site handling in this PR. Does that address the regression or is it a new feature?

Copy link
Member Author

Choose a reason for hiding this comment

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

Multi-site handling was added to add test coverage for the regression. Technically we might be able to pass in the site id to these methods so it's not using regex.

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

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

Cursory LGTM!

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 feature-iis Includes: IIS, ANCM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: ANCM: Unexpected application shutdown
3 participants