-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
DBTP-1521: Failure to post to slack can cause copilot deployment to fail #86
Conversation
image_builder/notify.py
Outdated
) | ||
self.reference = response["ts"] | ||
except SlackApiError as e: | ||
logger.error(f"Slack API Error: {e.response['error']}") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
image_builder/notify.py
Outdated
from slack_sdk.models import blocks | ||
|
||
from image_builder.progress import Progress | ||
from image_builder.utils.arn_parser import ARN | ||
|
||
logger = logging.getLogger(__name__) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍🏻
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 messageadded 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.