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

Ensure child worker processes are monitored after specialization #7974

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

mathewc
Copy link
Member

@mathewc mathewc commented Dec 9, 2021

Currently, child worker processes are only registered for monitoring when the process is started. That's a problem if the host is started in placeholder mode and later specialized. In that case, the worker channels are NOT restarted, and the child processes are not registered for monitoring by the new specialized host instance.

For testing, I've configured my local functions host to start in placeholder mode. I can see that placeholder worker channels are used. After triggering specialization, I can see the worker channels are specialized. Previously before my fix, the newly restarted/specialized host wouldn't be monitoring the child processes, because the were only registered on process start before. Now the worker process instance handles the HostStartEvent and registers.

Caught this issue in production testing. For a Python Consumption app, after specialization only the main host process is being monitored, not the worker process. That impacts DynamicConcurrency - it's unable to make correct concurrency decisions because it doesn't have a full view of CPU usage. In previous rounds of testing, I was testing with private site extensions, with placeholders disabled.

Will send a PR backporting to v3 as well, once this one is signed off on.

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
  • I have added all required tests (Unit tests, E2E tests)

@@ -69,7 +69,7 @@ public void Configure(string name, ScriptApplicationHostOptions options)
options.IsStandbyConfiguration = true;
}

options.IsFileSystemReadOnly = IsZipDeployment(out bool isScmRunFromPackage);
options.IsFileSystemReadOnly |= IsZipDeployment(out bool isScmRunFromPackage);
Copy link
Member Author

Choose a reason for hiding this comment

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

To test this fix, I had to simulate specialization locally. That requires configuration that ensures placeholder channels are used. For this specific change, the check here requires a RO file system. So I'm making this change to facilitate testability, however it's a logical change to make regardless.

@mathewc mathewc requested a review from pragnagopa December 9, 2021 20:09
await _hostService.StartAsync(CancellationToken.None);

// add general post startup validations here
mockEventManager.Verify(_ => _.Publish(It.IsAny<HostStartEvent>()), Times.Once());
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this StartAsync test so I had a place to add verification for the new event

@mathewc mathewc requested a review from brettsam December 10, 2021 16:16
@pragnagopa pragnagopa requested a review from kshyju December 10, 2021 19:05
Copy link
Member

@pragnagopa pragnagopa left a comment

Choose a reason for hiding this comment

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

Looks good! Added minor comment!

@mathewc mathewc merged commit 6aac496 into dev Dec 10, 2021
@mathewc mathewc deleted the oop-proc-mon-fix branch December 10, 2021 23:15
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