Skip to content

Label and notify of upcoming close for stale MRs (Step 2 part 1)

Chad Woolley requested to merge 5525-process-stale-mrs into master

What does this MR do?

Run a script to:

  1. Label all stale MRs with the stale - to be closed label
  2. Make a comment on the MR saying the MR will be closed and the associated branch deleted within 7 days unless the stale - to be closed label is removed.

Tasks

  • Write script
  • Ensure it preserves existing labels
  • Ensure it can be re-run idempotently without double-creating notes.
  • Ensure we don't exceed the rate limit: https://docs.gitlab.com/ee/user/gitlab_com/index.html#haproxy-api-throttle
    • Use CURL to check current ratelimit quotas: curl -i "https://gitlab.com/api/v4/version?private_token=$PRIVATE_TOKEN" | grep ratelimit
  • Run the script against the www-gitlab-com repo
  • Capture the script output to a text file, and save it on this issue under Script Run Logs below.
  • Send the slack notification to the #handbook, #website, and #whats-happening-at-gitlab channels.

MR Note Text

This Merge Request has not been updated in over 30 days, and has been labeled ~"stale - to be closed" ([see entire list](#{mr_labels_url})). In 7 more days, it will be closed, and its branch will be deleted.

**To keep this Merge Request open and prevent its branch from being deleted, remove the ~"stale - to be closed" label within 7 days**.

The branches have been archived in the [`www-gitlab-com-archive-20200410-pre-cleanup`](https://gitlab.com/gitlab-com/www-gitlab-com-archive-20200410-pre-cleanup) project prior to deletion.

**If you want to access the branch after it has been deleted, do the following**:
1. Go to the [`www-gitlab-com-archive-20200410-pre-cleanup`](https://gitlab.com/gitlab-com/www-gitlab-com-archive-20200410-pre-cleanup) project
1. [Clone the repository](https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html#clone-a-repository) and check out the branch locally.  You have two options here:
    * Clone it to a new repo, if you just want to access commits on the branch locally, or
    * Add it as a remote to an existing clone of the `www-gitlab-com` repo, if you want to re-push the branch to recreate it there.

Slack Notification Text

Slack message in #handbook

Hi team,

On 2020-04-20 we are planning on doing a cleanup of the https://gitlab.com/gitlab-com/www-gitlab-com repo to close stale MRs (no activity in last 30 days).  The MRs' branches and other stale branches will be deleted soon after.

This is a second heads-up for team members about this upcoming action.

All MRs which are scheduled to be closed have already had the `~"stale - to be closed"` label applied, and a comment/note added notifying about the upcoming closure.   You should have received a notification/email if you were following the MR.

You can also view all your own stale open MRs by adding your GitLab username to the end of this URL and entering it into your browser: https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests?state=opened&label_name%5B%5D=stale%20-%20to%20be%20closed&author_username=

If you want to keep a Merge Request open and prevent its branch from being deleted, remove the `~"stale - to be closed"` label within 7 days

Stale branches can be viewed here: https://gitlab.com/gitlab-com/www-gitlab-com/-/branches/stale

If you have any questions or concerns please reach out on this issue: https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/5525

Dev Notes

  • Unfortunately, we will have to use the Rest API ~~and retrieve every MR in the project (currently ~46,000) to accomplish this, which will be slow because it has to retrieve the full content of every MR.~~ This is because the alternatives to avoid this are not available (**UPDATE: This will not actually be slow, because we can pass the state filter to the REST merge_requests endpoint**):
  • Example CURL command: curl "https://gitlab.com/api/v4/projects/18061960/merge_requests?private_token=$PRIVATE_TOKEN&state=opened&view=simple&per_page=1" | jq

Related issues

Relates #5525 (closed)

/label ~"group::static site editor" ~backstage

Edited by Chad Woolley

Merge request reports