consumer, scheduler: support testing dist-git PRs (#104) #143
No reviewers
Labels
No labels
Closed As
Duplicate
Closed As
Fixed
Closed As
Invalid
easyfix
enhancement
ai-review-please
Backlog Status
Needs Review
Backlog Status
Ready
chore
documentation
points
01
points
02
points
03
points
05
points
08
points
13
Priority
Critical
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
quality/fedora_openqa!143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "schedule-distgit-prs"
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?
This makes it possible to request openQA tests for dist-git PRs.
Anyone (for now) can comment "/openqa test" on a dist-git PR,
and if the consumer is configured to listen on the appropriate
topics, it should schedule update tests (always the full set, for
now) on the scratch build associated with the PR. If the scratch
build is complete when the comment is added, the tests should be
scheduled immediately; if not, the tests will be scheduled when
we get a message indicating a scratch build has completed for the
PR. We also automatically test any subsequent scratch builds for
the same PR when they complete.
As part of this, we move the openqa_hostname and openqa_baseurl
definitions from consumer config to fedora_openqa config. They
are always the same for all consumers in real-world use, so it
doesn't really make sense to require them to be set for every
consumer.
Signed-off-by: Adam Williamson awilliam@redhat.com
AI Code Review
Detailed Code Review
The PR introduces functionality to automatically trigger and report on openQA tests for dist-git pull requests, which is a significant workflow enhancement. Moving the openQA URLs to a centralized configuration is a good refactor. However, there are a few potential issues related to dictionary key handling, robust string matching, and URL construction that should be addressed to ensure stability. Specifically, dictionary accesses like
comment["comment"]on potentially varied Pagure payloads should be done carefully to avoid KeyError, and splitting arbitrary URLs or checking for specific branches requires more robust error handling.📂 File Reviews
📄 `src/fedora_openqa/consumer.py` - Introduces logic for scheduling openQA jobs based on Pagure PR comments and flags, and includes a new reporter for pushing results back to dist-git.
comment["comment"]. If a comment dictionary doesn't contain the 'comment' key, this will raise a KeyError..get("comment")instead of direct bracket access.comment["comment"]in_consume_pr_flaglist comprehension..get("comment")in theany()generator expression.Minor [Logic]: The logic
not f" {branch} " in flag["username"]might be brittle if Pagure/Packit changes how they format usernames in scratch build flags.Minor [Bug]:
_version_from_branchis defined outside a class but acceptsselfas the first argument, behaving like a method. However, it's called as_version_from_branch(self, body).selfand just passlogger(orself.logger), or move it inside the class as a method.📄 `src/fedora_openqa/schedule.py` - Updates the `jobs_from_update` function to correctly parse task IDs from PR strings.
update.startswith("PR-")could fail ifupdateis a list, since strings havestartswithbut lists do not. The checkisinstance(update, list) or update.startswith("PR-")works because Python short-circuits, but ifupdateis neither a list nor a string, it will throw an AttributeError.updateis a string before callingstartswith.✅ Summary
KeyErrorrisks by using.get("comment")instead of["comment"]on Pagure comment objects._version_from_branchto either be a proper class method or pass the logger directly, rather than passingselfto a standalone function.update.startswith("PR-")inschedule.pyis protected by a string type check to preventAttributeError.🤖 AI Code Review | Generated with ai-code-review | Model:
gemini-3.1-pro-preview⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.
ae3aac2bd3a488ba9912a488ba9912869b8518d8Fixed some of the AI review stuff.
AI Code Review
Detailed Code Review
The PR introduces functionality to trigger openQA tests for dist-git PRs using a comment command (
/openqa test). The implementation correctly relocatesopenqa_hostnameandopenqa_baseurlto the globalfedora_openqaconfig. The logic correctly handles both immediate triggering and queuing for asynchronous build completions. However, the security model around who can trigger tests remains completely open, posing a denial of service or resource exhaustion risk. There are also potential edge cases with string manipulations, API responses, and exception handling.✅ Summary
/openqa testcommand could lead to resource exhaustion if malicious or accidental users trigger builds continuously.requests.post), which can fail silently except for a log message.IndexError.overviewurl.BUILDstrings into a helper function to avoid repeated brittlesplitoperations.requestslibrary.🤖 AI Code Review | Generated with ai-code-review | Model:
gemini-3.1-pro-preview⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.
869b8518d8f5aac5ca5eAdded retries and timeout to the requests stuff, and used urlencode for overviewurl.
AI Code Review
Detailed Code Review
The author implemented the logic to schedule openQA tests for dist-git PRs based on incoming fedmsg (Pagure) comments and flag updates, migrating configuration parameters for shared usage. Retries and basic URL encoding were applied. The logic accurately monitors '/openqa test' PR comments, retrieves scratch build tasks, schedules the appropriate openQA tests, and reports success, failure, or error back to the dist-git PR flag. Overall, the approach is architecturally sound and integrates neatly into the established consumer frameworks.
However, a logic issue exists when fetching properties from nested dictionaries where defaults are expected to be an empty string but are missing
.getfallback in secondary indexing (e.g.,pridconstruction). There is also a missing input validation for branch format matching in the mainline checker, but since it is handled softly it mostly just returns an empty string. The PR ID parsing splits on '-' with maxsplit 2, which could fail if the repository string itself has extra hyphens in unexpected structures.✅ Summary
pridconstruction in_consume_pr_commentand_consume_pr_flagagainstpr.get("project", {})being None, asget()defaults to{}but might returnNoneif the key exists with a null value.ValueErrorinbuild.replace("-NOREPORT", "").split("-", 2)if theBUILDstring unexpectedly does not contain exactly two hyphens after substitution.🤖 AI Code Review | Generated with ai-code-review | Model:
gemini-3.1-pro-preview⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.
I love the smell of "exceptions on unexpected payload structures" in the morning. Makes me feel alive.
@lruzicka wdyt?
f5aac5ca5e177e6093e4cleaned up the tests a bit with some of my beloved parametrization.
c1ac713c2506dd07fe0206dd07fe0276c9942bef76c9942befee4a4f5f18ee4a4f5f1809be49a7faI've done some fixes to this for current Rawhide, and to fix the test on GNOME (there was a needle tag mismatch). More tests running now.
09be49a7fae7df0f5214AI Code Review
Detailed Code Review
The PR introduces functional additions to trigger openQA testing for dist-git PRs via message bus consumption. The author has proactively addressed several stability concerns, such as configuring a requests session with robust retry logic and correctly isolating configuration. However, the implementation is currently vulnerable to message processing hangs due to a missing HTTP timeout on a secondary API call, and there are a couple of fragile data extraction patterns from the Pagure message payload that could lead to unhandled exceptions (and thus consumer crashes) under edge cases.
📂 File Reviews
📄 `src/fedora_openqa/consumer.py` - Introduces logic to consume PR comments and flag updates, scheduling openQA tests for dist-git PRs.
SESSION.get()call to Bodhi for critpath components is missing atimeout. If the Bodhi service hangs or becomes unresponsive, the fedora-messaging consumer will block indefinitely, preventing the consumption of any further messages.SESSIONrequests in this file.pr.get("comments", [{}])[-1]is vulnerable to anIndexError. If the Pagure API payload includes an explicitly empty list ("comments": []),pr.get()will return[], and[-1]will raise anIndexError, causing the consumer to crash for that message._consume_pr_flag, the fallback forpr.get("comments")is an empty dictionary ({}). While iterating over an empty dictionary is safe, if the field ever contained a populated dictionary, iterating over it would yield string keys, leading to anAttributeErrorwhencomment.get("comment", "")is called. It is safer and more semantically correct to default to an empty list.{}to[]._jobs_from_flag, if the flag payload explicitly sets theusernametoNone,flag.get("username", "")will returnNone(not""). The subsequentinoperator string check will raise aTypeError.inoperator.✅ Summary
🤖 AI Code Review | Generated with ai-code-review | Model:
gemini-3.1-pro-preview⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.
e7df0f5214ac5a56f41bTimeout added. The other things aren't worth worrying about in context.