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

New programming model #849

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

New programming model #849

wants to merge 4 commits into from

Conversation

andystaples
Copy link
Contributor

Issue describing the changes in this PR

Adds support for worker indexing to the functions worker

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
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

@andystaples
Copy link
Contributor Author

@Francisco-Gamino I think this PR is correct. The rebase was awful and doubled the amount of commits, not sure why. Lots still to do here, gotta bundle the module with the worker and figure out how to get the cmdlet available in order to write tests for the new programming model

Copy link
Contributor

@Francisco-Gamino Francisco-Gamino left a comment

Choose a reason for hiding this comment

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

Thank you @andystaples for sending this out! I've left a few comments. Let me know if you have any questions.

src/Microsoft.Azure.Functions.PowerShellWorker.csproj Outdated Show resolved Hide resolved
src/RequestProcessor.cs Outdated Show resolved Hide resolved
src/RequestProcessor.cs Outdated Show resolved Hide resolved
src/RequestProcessor.cs Show resolved Hide resolved
src/RequestProcessor.cs Outdated Show resolved Hide resolved
src/WorkerIndexing/BindingInformation.cs Outdated Show resolved Hide resolved
src/WorkerIndexing/FunctionInformation.cs Outdated Show resolved Hide resolved
src/WorkerIndexing/WorkerIndexingHelper.cs Outdated Show resolved Hide resolved
src/worker.config.json Show resolved Hide resolved
src/WorkerIndexing/WorkerIndexingHelper.cs Outdated Show resolved Hide resolved
src/WorkerIndexing/WorkerIndexingHelper.cs Show resolved Hide resolved
@@ -352,4 +352,10 @@
<data name="DependencySnapshotDoesNotContainAcceptableModuleVersions" xml:space="preserve">
<value>Dependency snapshot '{0}' does not contain acceptable module versions.</value>
</data>
<data name="GetFunctionsMetadataMultipleResultsError" xml:space="preserve">
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please ping the Team channel to get feedback on the new string resources you added?

src/WorkerIndexing/BindingInformation.cs Outdated Show resolved Hide resolved
src/WorkerIndexing/BindingInformation.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

Some minor thoughts from skimming the PR. Looking good!

<!--
<!--
Copy link
Contributor

Choose a reason for hiding this comment

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

nipickt: did anything change in this file? Seems like nothing changed. If so - can we instruct git to "revert this file" so that it doesn't register a change in the PR?

Comment on lines 140 to 146
// Failure that happens during this step is terminating and we will need to return a failure response to
// all subsequent 'FunctionLoadRequest'. Cache the exception so we can reuse it in future calls.
Copy link
Contributor

Choose a reason for hiding this comment

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

A suggestion on wording:

Suggested change
// Failure that happens during this step is terminating and we will need to return a failure response to
// all subsequent 'FunctionLoadRequest'. Cache the exception so we can reuse it in future calls.
// This is a terminating failure: we will need to return a failure response to
// all subsequent 'FunctionLoadRequest'. Cache the exception so we can reuse it in future calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

src/RequestProcessor.cs Show resolved Hide resolved
Comment on lines 369 to 379
// WorkerStatusResponse type says that it is not used but this will create an empty one anyway to return to the host
StreamingMessage response = NewStreamingMessageTemplate(
request.RequestId,
StreamingMessage.ContentOneofCase.FunctionMetadataResponse,
out StatusResult status);

response.FunctionMetadataResponse.FunctionMetadataResults.AddRange(WorkerIndexingHelper.IndexFunctions(request.FunctionsMetadataRequest.FunctionAppDirectory));
Copy link
Contributor

Choose a reason for hiding this comment

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

Without knowing the specifics of the contract between the Host and worker, I can't decipher what the comment at the top of this block is trying to say. Can you please add a bit more context? What exactly "says that it is not used"?, and what is "it" in this context? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea what this comment is about either. My guess - some misguided note I made while working on my first prototype and forgot to remove. I have removed it

{
internal class WorkerIndexingHelper
{
const string GetFunctionsMetadataCmdletName = "AzureFunctions.PowerShell.SDK\\Get-FunctionsMetadata";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this string to the strings-resource file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the way that other places in the code which call cmdlets deal with it. Strings-resources are for customer-facing error/warning messages. I propose creating a separate issue on the worker to track all occurrences and move them to some global constants file.

Comment on lines 20 to 50
List<RpcFunctionMetadata> indexedFunctions = new List<RpcFunctionMetadata>();

InitialSessionState initial = InitialSessionState.CreateDefault();
Runspace runspace = RunspaceFactory.CreateRunspace(initial);
runspace.Open();
System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create();
ps.Runspace = runspace;

ps.AddCommand(GetFunctionsMetadataCmdletName).AddArgument(baseDir);
string outputString = string.Empty;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this block would benefit from a small comment explaining what data your runspace is achieving, and how exactly this is helping the indexing process.

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. This is a much larger issue, actually, and without a better approach, will lead to the AzureFunctions.PowerShell.SDK module never being available to the worker in Azure, even if we bundle it with the worker. I have left a long comment explaining the issue and some proposed solutions.

<value>Multiple results from metadata cmdlet</value>
</data>
<data name="InvalidBindingInfoDirection" xml:space="preserve">
<value>The bindingInfo's Direction is not valid</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we be able to specify which binding name this corresponds to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@andystaples andystaples marked this pull request as ready for review August 26, 2022 20:45
@@ -0,0 +1,54 @@
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the standard copyright/license header to all the new files - just copy it from other files.

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

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.

5 participants