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

25023 Add more loggings for affiliation call and others #3160

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions legal-api/src/legal_api/services/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ def create_affiliation(cls, account: int,
details: dict = None,
flags: any = None):
"""Affiliate a business to an account."""
current_app.logger.info(f'Creating affiliation of {business_registration} for {account}')
auth_url = current_app.config.get('AUTH_SVC_URL')
account_svc_entity_url = f'{auth_url}/entities'
account_svc_affiliate_url = f'{auth_url}/orgs/{account}/affiliations'

token = cls.get_bearer_token()

if not token:
current_app.logger.info('Missing token for affiliation call')
return HTTPStatus.UNAUTHORIZED

# Create an entity record
Expand Down Expand Up @@ -244,6 +246,7 @@ def delete_affiliation(cls, account: int, business_registration: str) -> Dict:

@TODO Update this when account affiliation is changed next sprint.
"""
current_app.logger.info(f'Deleting affiliation of {business_registration} for {account}')
auth_url = current_app.config.get('AUTH_SVC_URL')
account_svc_entity_url = f'{auth_url}/entities'
account_svc_affiliate_url = f'{auth_url}/orgs/{account}/affiliations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
def update_business_profile(business: Business, filing: Filing, filing_type: str = None, flags: Flags = None):
"""Update business profile."""
if flags.is_on('enable-sandbox'):
current_app.logger.info('Skip updating business profile')
return

filing_type = filing_type if filing_type else filing.filing_type
Expand Down Expand Up @@ -99,6 +100,7 @@ def _update_business_profile(business: Business, profile_info: Dict) -> Dict:
def update_affiliation(business: Business, filing: Filing, flags: Flags = None):
"""Create an affiliation for the business and remove the bootstrap."""
try:
current_app.logger.info(f'Updating affiliation for business {business.identifier}')
bootstrap = RegistrationBootstrap.find_by_identifier(filing.temp_reg)

pass_code = ''
Expand Down Expand Up @@ -127,6 +129,7 @@ def update_affiliation(business: Business, filing: Filing, flags: Flags = None):

if rv not in (HTTPStatus.OK, HTTPStatus.CREATED):
deaffiliation = AccountService.delete_affiliation(bootstrap.account, business.identifier)
current_app.logger.error(f'Unable to affiliate business:{business.identifier} for filing:{filing.id}')
sentry_sdk.capture_message(
f'Queue Error: Unable to affiliate business:{business.identifier} for filing:{filing.id}',
level='error'
Expand All @@ -145,6 +148,7 @@ def update_affiliation(business: Business, filing: Filing, flags: Flags = None):
or ('bootstrap_update' in locals() and bootstrap_update != HTTPStatus.OK)):
raise QueueException
except Exception as err: # pylint: disable=broad-except; note out any exception, but don't fail the call
current_app.logger.error(f'Affiliation error for filing:{filing.id}, with err:{err}')
sentry_sdk.capture_message(
f'Queue Error: Affiliation error for filing:{filing.id}, with err:{err}',
level='error'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def consume_nr(business: Business, filing: Filing, filing_type: str = None, flag
"""Update the nr to a consumed state."""
try:
if flags.is_on('enable-sandbox'):
current_app.logger.info('Skip consuming NR')
return

filing_type = filing_type if filing_type else filing.filing_type
Expand Down
3 changes: 2 additions & 1 deletion queue_services/entity-filer/src/entity_filer/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from entity_queue_common.messages import publish_email_message
from entity_queue_common.service import QueueServiceManager
from entity_queue_common.service_utils import FilingException, QueueException, logger
from flask import Flask
from flask import Flask, current_app
from gcp_queue import SimpleCloudEvent, to_queue_message
from legal_api import db
from legal_api.core import Filing as FilingCore
Expand Down Expand Up @@ -182,6 +182,7 @@ def publish_gcp_queue_event(business: Business, filing: Filing):
async def publish_mras_email(filing: Filing):
"""Publish MRAS email message onto the NATS emailer subject."""
if flags.is_on('enable-sandbox'):
current_app.logger.info('Skip publishing MRAS email')
return

if filing.filing_type in [
Expand Down
Loading