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

bug: Backport 4.27: Update function directory in load request to use /home/site/wwwroot #1481

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions azure_functions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,11 @@ def load_function_metadata(self, function_app_directory, caller_info):
function_path = os.path.join(function_app_directory,
script_file_name)

# For V1, the function path will not exist and
# return None.
self._function_metadata_result = (
self.index_functions(function_path)) \
self.index_functions(function_path,
function_app_directory)) \
if os.path.exists(function_path) else None

async def _handle__functions_metadata_request(self, request):
Expand Down Expand Up @@ -400,8 +403,9 @@ async def _handle__function_load_request(self, request):

logger.info(
'Received WorkerLoadRequest, request ID %s, function_id: %s,'
'function_name: %s',
self.request_id, function_id, function_name)
'function_name: %s, function_app_directory : %s',
self.request_id, function_id, function_name,
function_app_directory)

programming_model = "V2"
try:
Expand Down Expand Up @@ -672,15 +676,16 @@ async def _handle__function_environment_reload_request(self, request):
request_id=self.request_id,
function_environment_reload_response=failure_response)

def index_functions(self, function_path: str):
def index_functions(self, function_path: str, function_dir: str):
indexed_functions = loader.index_function_app(function_path)
logger.info('Indexed function app and found %s functions',
len(indexed_functions))

if indexed_functions:
fx_metadata_results = loader.process_indexed_function(
self._functions,
indexed_functions)
indexed_functions,
function_dir)

indexed_function_logs: List[str] = []
for func in indexed_functions:
Expand Down
4 changes: 2 additions & 2 deletions azure_functions_worker/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def build_variable_interval_retry(retry, max_retry_count, retry_strategy):


def process_indexed_function(functions_registry: functions.Registry,
indexed_functions):
indexed_functions, function_dir):
fx_metadata_results = []
for indexed_function in indexed_functions:
function_info = functions_registry.add_indexed_function(
Expand All @@ -134,7 +134,7 @@ def process_indexed_function(functions_registry: functions.Registry,
name=function_info.name,
function_id=function_info.function_id,
managed_dependency_enabled=False, # only enabled for PowerShell
directory=function_info.directory,
directory=function_dir,
script_file=indexed_function.function_script_file,
entry_point=function_info.name,
is_proxy=False, # not supported in V4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import time
from datetime import datetime

import azure.functions as func

Expand Down Expand Up @@ -29,3 +31,11 @@ def default_template(req: func.HttpRequest) -> func.HttpResponse:
" personalized response.",
status_code=200
)


@bp.route(route="http_func")
def http_func(req: func.HttpRequest) -> func.HttpResponse:
time.sleep(1)

current_time = datetime.now().strftime("%H:%M:%S")
return func.HttpResponse(f"{current_time}")
8 changes: 8 additions & 0 deletions tests/endtoend/test_worker_process_count_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ class TestWorkerProcessCountStein(TestWorkerProcessCount):
def get_script_dir(cls):
return testutils.E2E_TESTS_FOLDER / 'http_functions' /\
'http_functions_stein'


class TestWorkerProcessCountWithBlueprintStein(TestWorkerProcessCount):

@classmethod
def get_script_dir(cls):
return testutils.E2E_TESTS_FOLDER / 'blueprint_functions' /\
'functions_in_blueprint_only'
Loading