[fedora-scm-requests] - Migrate scm-request related stuff in toddlers to support the new forge #13370
Labels
No labels
after freeze
automation
backlog
blocked
change-ack
change-nak
change-noreleng
changes
Closed As
Can't Fix
Closed As
Duplicate
Closed As
Fixed
Closed As
Fixed with Explanation
Closed As
Get back later
Closed As
Grooming
Closed As
Insufficient data
Closed As
Invalid
Closed As
It's all good
Closed As
taiga
Closed As
upstream
day-to-day
dev
docs
easyfix
epel
f26
f27
f28
f29
f30
f31
f32
f33
f34
f35
f36
f37
f38
f39
f40
f41
f42
f43
f44
f45
fedora
groomed
high-gain
high-trouble
in-progress
in-review
investigation
legal
low-gain
low-trouble
mass rebuild
medium-gain
medium-trouble
meeting
mini-initiative
new_artifact
ops
pdc_retirement
rawhide
RCA
review
script
sidetarget
sprint-0
sprint-1
sprint-2
sprint-3
sprint-4
sprint-5
unfrozen
waiting on external
Backlog Status
Needs Review
Backlog Status
Ready
chore
documentation
points
01
points
02
points
03
points
05
points
08
points
13
Priority
High
Priority
Low
Priority
Medium
Sprint Status
Blocked
Sprint Status
Done
Sprint Status
In Progress
Sprint Status
Review
Sprint Status
To Do
Technical Debt
Work Item
Bug
Work Item
Epic
Work Item
Spike
Work Item
Task
Work Item
User Story
No milestone
No project
No assignees
8 participants
Notifications
Due date
No due date set.
Blocks
#13108 Migration of fedora-scm-requests to Forgejo
releng/tickets
Reference
releng/tickets#13370
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Create a set of actions that will react on ticket creation/status change try to reuse code from toddlers where possible.
Is there a strong reason that this needs to be reimplemented using Forgejo Actions? Storing a distgit admin token in Forgejo Actions seems risky, especially if the runners are shared with other projects on Forge (or access to the repo with the secrets isn't very tightly controlled). And if you're not careful, the Github/Forgejo Actions templating system makes it easy to run arbitrary code when handling user inputs (including issue titles, descriptions, and comments).
The runners are not really shared; each organization has its own. But it is a valid concern. The only reason for the implementation in actions is to drop toddlers' dependency.
I've been looking into this and I'd be grateful for input from more knowledgeable people about what the best way to do this is. Below is my current understanding and the options we have but I'm very likely missing/misunderstanding one or more things.
CC: @gotmax23 @jnsamyak @kevin
Option A: Forgejo Actions
Re-implement the processing logic as a Forgejo Actions workflow.
Pros:
Cons:
fedora-scm-requestscan modify the workflow file. A malicious or compromised committer could add code that misuses the token.Option B: Extend Toddlers
Continue using the existing toddler infrastructure, adapted for Forgejo.
Pros:
Cons:
forgejo.pyutility module parallel to the existingpagure.py.Option C: Hybrid Approach
Use a minimal Forgejo Action that only triggers the toddler, without holding sensitive secrets.
TRIGGER_TOKENfor this integration:fedora-scm-requestssettings.Pros:
scm_request_processor.pystays as-is.TRIGGER_TOKEN, but that can only trigger processing, nothing else.Cons:
It sure can. It's just not enabled by default (which I think we should change). See: https://docs.fedoraproject.org/en-US/forge-documentation/webhook_to_fedora_messaging/
definitely IMHO releng org should enable this at the org level.
IMHO, I think we should just choose the option B for now and then after that look at perhaps moving to Option A if we want later.
Besides that, if the Forgejo Action is not configured properly (it's relatively easy to misconfigure due to the way the templating system in GHA/Forgejo Actions workflow configuration files work), an untrusted user who creates a ticket in the repository could inject code to exfiltrate the distgit API token or do other malicious things using the repo-scoped Forgejo API token that is also made available to steps in the workflow.
Also, I'd say provisioning a runner container and making a separate workflow run for each SCM request ticket is probably computationally more expensive than using the toddlers setup.
I recommend looking at https://docs.zizmor.sh/ to help with securing Actions workflow. Since the Forgejo actions are very close to GitHub I think it should work.
@patrikp wrote in #13370 (comment):
If we take this approach, and update the existing toddlers code base to point to new queue topics.
If we stick with similar payload, how much work are we talking about?
As per the request, I'll try to work on this sprint.
@humaton good question, with your investigation in mind, @patrikp could you help with that?
Here is the investigation I was able to do. It's by no means complete but should hopefully provide some more context about what changes are needed.
Toddlers repository URL:
https://forge.fedoraproject.org/apps/toddlers
The
fedora-scm-requeststracker currently lives on Pagure and there are two toddlers plugins that process tickets from it automatically:scm_request_processor.py— handles new repo and branch requestsunretire_packages.py— handles package unretirement (I will ignore this for the rest of this comment but it'd be nice if @amedvede was aware that changes will be needed there too)The
scm_request_processor.pyplugin listens for Pagure messages via fedora-messaging, fetches ticket data from Pagure, validates requests, does the actual work, then closes the ticket with a comment. It already maintains two separate connections (pagure_iofor tickets anddist_gitfor src.fp.o) so the architecture supports multiple connections and dist-git isn't moving (yet), so we just need to swap the ticket-side connection to Forgejo.Here's roughly what will need to change:
New code:
toddlers/utils/forgejo.pypagure.pystructureget_issue(),close_issue(),add_comment_to_issue(),get_project_contributors()toddlers/exceptions/forgejo_error.pypagure_error.pytests/utils/test_forgejo.py(at the very least a "nice to have")Existing files to modify:
toddlers/plugins/scm_request_processor.pytoddlers/utils/__init__.pyforgejoto importstoddlers/exceptions/__init__.pyForgejoErrorto importstests/plugins/test_scm_request_processor.pyToddlers config file:
This is as far as I've been able to get so far, hopefully it is at least somewhat helpful in terms of the "bigger picture".
Now, as for "how much work" we're talking about, I am not entirely sure. In what metric? If it's points, I'd say either 3 or 5.
[fedora-scm-requests] - Create forgejo workflow for processing ticketsto [fedora-scm-requests] - Migrate scm-request related stuff in toddlers to support the new forgeI'm not sure how to use that investigation into actionable items. I did give the code base a look, and I think in order to move scm-request using toddlers, we should follow wherw toddlerswill listens via webhook→fedora-messaging talks Forgejo for issue chattere and keeps the existing Pagure helper only for creating repos/branches.
I'm going to proceed the work with this, unless there is a strong No.
The toddlers change looks good. That would just mean to replace pagure calls with forgejo ones for pagure.io interactions, which shouldn't be that difficult.
I'm giving +1 to this solution and having the
toddlers.utils.forgejoin place will help with the dist-git move to forgejo as well in the future.@jnsamyak wrote in #13370 (comment):
Sounds about right, we should enable the webhook as a first thing to see any difference in the data that forge is sending. I suspect that some of the logic in toddlers.utils.pagure could be simplified.
Okay, so for an unretirement toddler, I think the same trick we used for scm_request. Stop listening to Pagure issue messages; listen to Forge forgejo.issues instead. Talk to Forgejo for comments/closes/labels; leave dist-git, koji, bodhi, and bugzilla alone.
Concrete bits:
I think I can leave the actual unretired working bits as they are (clone, revert, retire commit, koji/bodhi/bugzilla). I'll make these changes in the same PR.
CC: @amedvede @humaton @zlopez^
Sounds like a good plan @jnsamyak. I'll take a look at the changes you made (I believe its this PR apps/toddlers#429). So the fedora-messaging message structure will look the same, and we only need to create a Forgejo webhook to create a message based on a repo action?
That's the plan