Skip to content

Conversation

@gavin-aguiar
Copy link
Contributor

Description

Added a console logger so that customers can directly see the error message while deploying a function app.

Sample output:
**
image

**

Fixes #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

@codecov
Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0b21dc0) 85.28% compared to head (72aeef0) 85.47%.
Report is 3 commits behind head on dev.

❗ Current head 72aeef0 differs from pull request most recent head 8319dac. Consider uploading reports for the commit 8319dac to get more accurate results

Additional details and impacted files
@@ Coverage Diff @@ ## dev #1388 +/- ## ========================================== + Coverage 85.28% 85.47% +0.18%  ========================================== Files 35 35 Lines 1971 1969 -2 Branches 371 370 -1 ========================================== + Hits 1681 1683 +2  + Misses 217 213 -4  Partials 73 73 
Flag Coverage Δ
unittests 85.42% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gavin-aguiar gavin-aguiar marked this pull request as draft January 3, 2024 16:52
@gavin-aguiar gavin-aguiar marked this pull request as ready for review January 5, 2024 16:54
Returns:
T, T : V2 programming model
T, F : V2 programming model but with invalid file name
F, T : File path does not exist but filename is valid.
Copy link
Member

Choose a reason for hiding this comment

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

There is a special case if someone actually sets it in the app setting, which could be this case and not a V1 programming model. We might want to ensure that in the future releases (TODO: Add another check if the setting was set or not and make the call based on it)

Copy link
Contributor

Choose a reason for hiding this comment

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

Added a check if the app setting has been set. If it has, return T F scenario. In dispatcher changed the logs slightly for this case

Comment on lines 159 to 161
debug_logs='Error in load_function. '
f'Sys Path: {sys.path}, Sys Module: {sys.modules},'
'python-packages Path exists: '
Copy link
Member

Choose a reason for hiding this comment

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

Are you planning to add the exception message for our analysis?

Copy link
Member

Choose a reason for hiding this comment

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

Same comment below.

return func(*args, **kwargs)
except expt_type as e:
if debug_logs is not None:
logger.error(debug_logs)
Copy link
Member

Choose a reason for hiding this comment

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

To simplify - You can add the exception to debug_logs itself.

Exception('Invalid Script file name %s',
script_file_name)))))
else:
logger.error('App setting %s detected but file path %s does '
Copy link
Member

Choose a reason for hiding this comment

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

For this case - how did we detect the app setting explicitly set? Because the current issue is using the default and that'll always return this case.

Also - should this be error_logger?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the False False case, so their script file name was invalid. This means it was changed, not the default

# Fallback to legacy model
logger.info("%s does not exist. "
"Switching to host indexing.", script_file_name)
if v2_file_exist and file_name_valid:
Copy link
Member

Choose a reason for hiding this comment

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

This whole if-else setup needs to be thoroughly tested.

Copy link
Member

Choose a reason for hiding this comment

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

 def _dispatch_response(self, request, function_path, v2_file_exist, file_name_valid): conditions = [ (v2_file_exist, file_name_valid, self._handle_valid_v2), (not v2_file_exist, file_name_valid, self._handle_valid_v1), (v2_file_exist, not file_name_valid, self._handle_invalid_v2), (not v2_file_exist, not file_name_valid, self._handle_invalid_app), ] for condition in conditions: if all(condition[:-1]): return condition[-1](request.request_id, function_path) # Default response or error handling return self._handle_default(request.request_id, function_path) 

strategy design pattern may be overpowering, but a dispatch map here make code more maintainable.

# Handles special case where App Setting is set to incorrect file name
# for V2 programming model
if app_setting_set and not path_exists and valid_file_name:
return True, False
Copy link
Member

Choose a reason for hiding this comment

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

move this check at top to cut overhead when failing fast

@gavin-aguiar gavin-aguiar deleted the gaaguiar/console_logging_fix branch February 2, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment