mirror of https://github.com/mongodb/mongo
SERVER-83283 Modify copybara script to send slack message on failure (#17021)
GitOrigin-RevId: 95cb69586f2d7f5930c8f22ea8ec6b6617a94080
This commit is contained in:
parent
07870b62ff
commit
a5b4c7acdc
|
|
@ -8,6 +8,7 @@ from typing import Optional
|
||||||
from github import GithubIntegration
|
from github import GithubIntegration
|
||||||
|
|
||||||
from buildscripts.util.read_config import read_config_file
|
from buildscripts.util.read_config import read_config_file
|
||||||
|
from evergreen.api import RetryingEvergreenApi
|
||||||
|
|
||||||
|
|
||||||
def run_command(command): # noqa: D406,D407
|
def run_command(command): # noqa: D406,D407
|
||||||
|
|
@ -73,6 +74,24 @@ def get_installation_access_token(app_id: int, private_key: str,
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def send_failure_message_to_slack(expansions):
|
||||||
|
"""
|
||||||
|
Send a failure message to a specific Slack channel when the Copybara task fails.
|
||||||
|
|
||||||
|
:param expansions: Dictionary containing various expansion data.
|
||||||
|
"""
|
||||||
|
current_version_id = expansions.get("version_id", None)
|
||||||
|
error_msg = (
|
||||||
|
"Evergreen task '* Copybara Sync Between Repos' failed\n"
|
||||||
|
f"For more details: <https://spruce.mongodb.com/version/{current_version_id}|here>.")
|
||||||
|
|
||||||
|
evg_api = RetryingEvergreenApi.get_api(config_file=".evergreen.yml")
|
||||||
|
evg_api.send_slack_message(
|
||||||
|
target="#sdp-triager",
|
||||||
|
msg=error_msg,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Clone the Copybara repo, build its Docker image, and set up and run migrations."""
|
"""Clone the Copybara repo, build its Docker image, and set up and run migrations."""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
@ -131,7 +150,8 @@ def main():
|
||||||
for acceptable_message in acceptable_error_messages):
|
for acceptable_message in acceptable_error_messages):
|
||||||
return
|
return
|
||||||
|
|
||||||
raise
|
# Send a failure message to #sdp-triager if the Copybara sync task fails.
|
||||||
|
send_failure_message_to_slack(expansions)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -5339,6 +5339,7 @@ tasks:
|
||||||
- *git_get_project
|
- *git_get_project
|
||||||
- *set_task_expansion_macros
|
- *set_task_expansion_macros
|
||||||
- *set_up_virtualenv
|
- *set_up_virtualenv
|
||||||
|
- func: "configure evergreen api credentials"
|
||||||
- command: expansions.write
|
- command: expansions.write
|
||||||
params:
|
params:
|
||||||
file: src/expansions.yml
|
file: src/expansions.yml
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
click ~= 7.0
|
click ~= 7.0
|
||||||
dataclasses; python_version < "3.7"
|
dataclasses; python_version < "3.7"
|
||||||
GitPython ~= 3.1.7
|
GitPython ~= 3.1.7
|
||||||
pydantic ~= 1.7.3
|
pydantic ~= 1.8.2
|
||||||
structlog ~= 19.2.0
|
structlog ~= 19.2.0
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
PyKMIP == 0.4.0 # It's now 0.8.0. We're far enough back to have API conflicts.
|
PyKMIP == 0.4.0 # It's now 0.8.0. We're far enough back to have API conflicts.
|
||||||
evergreen.py == 2.1.0
|
evergreen.py == 3.1.0
|
||||||
jinja2 <= 2.11.3
|
jinja2 <= 2.11.3
|
||||||
MarkupSafe == 1.1.0 # See SERVER-57036, this is a transitive dependency of jinja2
|
MarkupSafe == 1.1.0 # See SERVER-57036, this is a transitive dependency of jinja2
|
||||||
mock <= 4.0.3
|
mock <= 4.0.3
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue