Add Phase 2 to MR cleanup: reset Jira labels for closed bot MRs - #700
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
PR Summary by QodoAdd phase 2 MR cleanup to reset Jira labels for closed bot MRs
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
7 rules 1.
|
|
@antbob I extended our auto-closing script to do the cleanup on Jiras as well which your team was interested in (see referenced Jira), I made it possible to skip the auto-closing and configure the Gitlab bot name(s) for which to run the clean-up. Let me know if this works for you! |
|
@lbarcziova thats great, thanks! |
| JIRA_LABELS_TO_PRESERVE: typing.ClassVar[set[str]] = { | ||
| JIRA_MR_CLOSED_LABEL, | ||
| "ymir_todo", | ||
| "ymir_retry_needed", | ||
| } |
There was a problem hiding this comment.
wouldn't it make sense to add "ymir_merged" here, so we can be sure it never gets removed?
There was a problem hiding this comment.
makes sense, even though iirc ymir_merged is set from the QE agents which are not yet deployed.
But this made me realise a bigger problem: scenario where RHEL-100 has two bot MRs - MR-A merged, MR-B closed. Phase 2 picks up MR-B and wants to reset RHEL-100's labels. That doesn't look correct. I will think about what would be the best way to avoid this (first, but expensive solution would be to parse all the resolved Jiras from the merged MRs).
48bbe0c to
5ed6b4b
Compare
a5aa05c to
49d77fb
Compare
49d77fb to
cab9d67
Compare
|
@opohorel PTAL, the last commit changes it a bit, the |
opohorel
left a comment
There was a problem hiding this comment.
LGTM, thanks for looking into this!
When a bot MR is closed (rejected or auto-closed by Phase 1), the referenced Jiras still carry outcome labels (ymir_backported, ymir_rebased, etc.) that no longer reflect reality. Phase 2 removes those labels and adds ymir_mr_closed so the issues are eligible for re-processing. - Fetch all closed (not merged) bot MRs, extract Jira keys from commits - Remove ymir_* outcome labels, add ymir_mr_closed to each Jira - Mark processed MRs with ymir_jiras_cleaned_up to skip on future runs - Skip Jiras still referenced by an open MR (active-keys guard) - Deduplicate across MRs within a single run - Add phase toggles (CLOSE_STALE_MRS, RESET_CLOSED_MR_JIRAS) and configurable bot authors (GITLAB_BOT_AUTHORS) for multi-deployment use (e.g. sustaining engineering with rhel-se-jotnar-admin) Resolves: https://redhat.atlassian.net/browse/PACKIT-5080 Assisted-by: Claude Opus 4.6
This was a development/testing aid for Phase 1 that is no longer needed. Remove from the script, Makefile, and documentation. Assisted-by: Claude Opus 4.6
- Use positive accumulation (keys from still-open MRs) instead of set subtraction to compute active_jira_keys, avoiding edge case where a shared key could be dropped from the protection set. - Only add ymir_jiras_cleaned_up sentinel label when all Jira keys were successfully handled, so transient failures are retried on the next run. Assisted-by: Claude Opus 4.6
Phase 2 resets automation labels on Jiras referenced by closed bot MRs. Without this guard, it would also reset labels on Jiras that were successfully fixed by a different (merged) MR — common after MR consolidation. Fetch merged bot MRs within a 180-day lookback window, extract their Jira keys, and add those to the skip set alongside keys from open MRs. Also skip Jiras carrying the ymir_merged label as a second layer of protection. Assisted-by: Claude Opus 4.6
Instead of stripping automation outcome labels (ymir_backported, etc.) and replacing them with ymir_mr_closed, Phase 2 now only adds ymir_mr_closed alongside existing labels. This preserves the historical trace of what Ymir did — the coverage metrics query Jira labels directly (labels IN ymir_backported, ...) and removing them would undercount Jiras that Ymir successfully worked on, even if the MR didn't land. Assisted-by: Claude Opus 4.6
Avoids processing the entire historical backlog of closed bot MRs on first deployment — only recent closures are relevant. Renames the constant to MR_LOOKBACK_DAYS since both phases share it. Assisted-by: Claude Opus 4.6
a916e54 to
cadc9c4
Compare
No description provided.