Skip to content

Conversation

AnatoliB
Copy link
Contributor

This is for the v2.x branch only.

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.

LGTM

@AnatoliB
Copy link
Contributor Author

@Francisco-Gamino In order to make the error message more discoverable, I changed the implementation:

  • On worker start, check the version and log the message, but don't exit the worker process.
  • Fail each subsequent function load or function invocation request with the same error.

@@ -307,4 +307,7 @@
<data name="CommandNotFoundException_Exception" xml:space="preserve">
<value>CommandNotFoundException detected (exception).</value>
</data>
<data name="InvalidFunctionsWorkerRuntimeVersion" xml:space="preserve">
<value>Invalid PowerShell version specified in the {0} environment variable: {1}. This version is not supported on Azure Functions Runtime v2.</value>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eamonoreilly Please review the message


internal static string GetErrorMessage(string requestedVersion)
{
if (!string.IsNullOrWhiteSpace(requestedVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this change will only get merged to the v2/ps6 branch. However, would it make sense to also check FUNCTIONS_EXTENSION_VERSION to make sure we are running on V2? I am ok if we add this later in a separate PR given the time constrain.

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'm not convinced we should do that here. One of the advantages of having separate branches for v2 and v3 is that we can make assumptions and reduce code complexity, eliminate some mental overhead, and reduce potential reasons for this code to break, like this:

  • It would introduce a dependency on the FUNCTIONS_EXTENSION_VERSION format, including all the possible variations, now and in the future. If anything changes, we'll need to remember about this dependency and have an upgrade plan.
  • This check would try to validate a build-time condition during runtime. This may lead to interesting results. Imagine someone actually made a mistake and included the worker intended for Runtime v2 into the v3 host build. If this check prevents function invocations, this mistake will cause a wide outage. But, if it does not prevent function invocations, who is going to notice it?
  • In any case, this check would happen after the deployment, which is way too late. Furthermore, the users will be the first who notice the mistake, not the Functions engineers.

As long as we control the references to the PowerShell worker from the Functions host, I would treat the Functions Runtime version as a safe pre-condition, so we don't have to even think about issues like this.

I agree this check could notify us of the situation when someone makes a mistake on the Functions host and refers a wrong version. But, if we do need a check like this, it should be on the Functions host build/test process, so that this mistake is never deployed to begin with.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Thanks you for the detailed explanation.

@Francisco-Gamino
Copy link
Contributor

The code change looks good. One comment about checking for the host version 2 in addition to the runtime version.

@AnatoliB AnatoliB merged commit 5d2ef26 into Azure:v2.x Feb 20, 2020
@AnatoliB AnatoliB deleted the prohibit-ps7-attempts-2 branch February 21, 2020 01:40
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