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

DBTP-1521: Failure to post to slack can cause copilot deployment to fail #86

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

tony-griffin
Copy link
Contributor

@tony-griffin tony-griffin commented Jan 7, 2025

Addresses ticket: DBTP-1521

  • Added try/except block around the Slack client message methods.

  • logging passed into Notify class as a dependency with a default logger.

  • Use Logging instance to log a SlackAPIError type with error message

  • added Exception type error handling as per Ant’s suggestion

  • refactored error handling tests to not use the test class level patches for clarity

  • @JohnStainsby tested that the error handling was working by changing the value of the Slack parameter from AWS Parameter Store. This meant the Slack client would not have the correct value for the Slack channel which should trigger an error during the deployment process.

  • Expected error messages were seen in the build logs for the deploy Codebuild action. Error messages did not cause the deploy of the application image to fail this time, as expected.

@tony-griffin tony-griffin requested a review from a team January 7, 2025 17:06
)
self.reference = response["ts"]
except SlackApiError as e:
logger.error(f"Slack API Error: {e.response['error']}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth future-proofing this by adding a second except block for just Exception to stop the deployment failing due to any non-Slack API errors. e.g. if the SLACK_CHANNEL_ID hasn't been set or something.

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

from slack_sdk.models import blocks

from image_builder.progress import Progress
from image_builder.utils.arn_parser import ARN

logger = logging.getLogger(__name__)

Copy link
Contributor

Choose a reason for hiding this comment

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

No longer need this as it's being created on line 30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed 👍🏻

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.

3 participants