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

Refactor deployFeed replyCallback functionality to be more reusable #793

Open
IanWoodard opened this issue May 17, 2024 · 0 comments
Open
Assignees

Comments

@IanWoodard
Copy link
Member

For a while we only ever had one usage of replyCallback:

replyCallback: async (pipeline) => {
const pauseCause = getPauseCause(pipeline);
if (pauseCause == null) return [];
const [base, head] = await getBaseAndHeadCommit(pipeline);
const authors = head ? await getAuthors('getsentry', base, head) : [];
// Get unique users from the authors
const uniqueUsers = await getUniqueUsers(authors);
// Pick at most 10 users to cc
const ccUsers = uniqueUsers.slice(0, 10);
const ccString = ccUsers
.map((user) => {
return `<@${user.slackUser}>`;
})
.join(' ');
const failedJob = pipeline.stage.jobs.find(
(job) => job.result.toLowerCase() === 'failed'
);
if (!failedJob) {
// This should never happen, but if it does, we want to know about it
Sentry.captureException(
new Error('Failed to find failed job in failed pipeline')
);
return [];
}
const gocdLogsLink = `https://deploy.getsentry.net/go/tab/build/detail/${pipeline.name}/${pipeline.counter}/${pipeline.stage.name}/${pipeline.stage.counter}/${failedJob.name}`;
const sentryReleaseLink = pipeline.name.includes('s4s')
? `https://sentry-st.sentry.io/releases/backend@${head}/?project=1513938`
: `https://sentry.sentry.io/releases/backend@${head}/?project=1`;
const blocks = [
header(
plaintext(`:double_vertical_bar: ${pipeline.name} has been paused`)
),
section(
markdown(`The deployment pipeline has been paused due to detected issues in ${pauseCause}. Here are the steps you should follow to address the situation:\n
:mag_right: *Step 1: Review the Errors*\n Review the errors in the *<${gocdLogsLink}|GoCD Logs>*.\n
:sentry: *Step 2: Check Sentry Release*\n Check the *<${sentryReleaseLink}|Sentry Release>* for any related issues.\n
:thinking_face: *Step 3: Is a Rollback Necessary?*\nDetermine if a rollback is necessary by reviewing our *<${IS_ROLLBACK_NECESSARY_LINK}|Guidelines>*.\n
:arrow_backward: *Step 4: Rollback Procedure*\nIf a rollback is necessary, use the *<${ROLLBACK_PLAYBOOK_LINK}|GoCD Playbook>* or *<${GOCD_USER_GUIDE_LINK}|GoCD User Guide>* to guide you.\n
:arrow_forward: *Step 5: Unpause the Pipeline*\nWhether or not a rollback was necessary, make sure to unpause the pipeline once it is safe to do so.`)
),
];
if (ccUsers.length > 0) {
blocks.push(
context(
markdown(
`cc'ing the following ${
uniqueUsers.length > 10 ? `10 of ${uniqueUsers.length} ` : ''
}people who have commits in this deploy:\n${ccString}`
)
)
);
}
return blocks;
},
, we are starting to introduce more usages of it (#790). We should refactor the deployFeed to make the flow of finding authors and pinging them in response to a failure more reusable.

@IanWoodard IanWoodard self-assigned this May 17, 2024
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

No branches or pull requests

1 participant