Reliably use modified repodata for get_new_repoclosure #14

Merged
adamwill merged 1 commit from fix-new-repoclosure into main 2026-03-22 04:59:57 +00:00
Owner

I noticed that https://openqa.fedoraproject.org/tests/4471016
passed when it should not have: it should have caught that the
new gstreamer1-plugins-good package had a dependency issue. I was
able to reproduce this locally. Some debugging indicated that,
in get_new_repoclosure, the base repository that should have been
modified was not behaving as if it was modified.

I think we've been relying on DNF's cache, here. We only actually
used the modified repodata directly in get_modified_repoclosure.
In get_new_repoclosure we were configuring the repo with the same
name, but with its original unmodified path. I think we expected
that DNF would cache the modified metadata and re-use it. This
obviously worked at some point (because we have had correct
failures in get_new_repoclosure), but it's obviously fragile.

Let's improve it by creating the temporary directory where we
store the modified repodata in main() and passing it to both
get_modified_repoclosure() and get_new_repoclosure(); this way
get_new_repoclosure() can access and use the actual modified
repodata. In my local testing, this fixes the bug and we now
correctly find the dependency error.

Signed-off-by: Adam Williamson awilliam@redhat.com

I noticed that https://openqa.fedoraproject.org/tests/4471016 passed when it should not have: it should have caught that the new gstreamer1-plugins-good package had a dependency issue. I was able to reproduce this locally. Some debugging indicated that, in get_new_repoclosure, the base repository that should have been modified was not behaving as if it was modified. I think we've been relying on DNF's cache, here. We only actually used the modified repodata directly in get_modified_repoclosure. In get_new_repoclosure we were configuring the repo with the same name, but with its original unmodified path. I think we expected that DNF would cache the modified metadata and re-use it. This obviously worked at some point (because we *have* had correct failures in get_new_repoclosure), but it's obviously fragile. Let's improve it by creating the temporary directory where we store the modified repodata in main() and passing it to both get_modified_repoclosure() and get_new_repoclosure(); this way get_new_repoclosure() can access and use the actual modified repodata. In my local testing, this fixes the bug and we now correctly find the dependency error. Signed-off-by: Adam Williamson <awilliam@redhat.com>
Reliably use modified repodata for get_new_repoclosure
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m26s
AI Code Review / ai-review (pull_request_target) Successful in 20s
AI Code Review / remove-label (pull_request_target) Successful in 2s
c2b6ce2a72
I noticed that https://openqa.fedoraproject.org/tests/4471016
passed when it should not have: it should have caught that the
new gstreamer1-plugins-good package had a dependency issue. I was
able to reproduce this locally. Some debugging indicated that,
in get_new_repoclosure, the base repository that should have been
modified was not behaving as if it was modified.

I think we've been relying on DNF's cache, here. We only actually
used the modified repodata directly in get_modified_repoclosure.
In get_new_repoclosure we were configuring the repo with the same
name, but with its original unmodified path. I think we expected
that DNF would cache the modified metadata and re-use it. This
obviously worked at some point (because we *have* had correct
failures in get_new_repoclosure), but it's obviously fragile.

Let's improve it by creating the temporary directory where we
store the modified repodata in main() and passing it to both
get_modified_repoclosure() and get_new_repoclosure(); this way
get_new_repoclosure() can access and use the actual modified
repodata. In my local testing, this fixes the bug and we now
correctly find the dependency error.

Signed-off-by: Adam Williamson <awilliam@redhat.com>

AI Code Review

📋 MR Summary

Fixes a bug where get_new_repoclosure relied on DNF caching to use modified repodata by explicitly sharing the temporary directory containing the modified metadata.

  • Key Changes:
    • Extracted the creation of the temporary directory for modified repodata to main().
    • Updated get_modified_repoclosure to accept the shared temporary directory rather than creating its own.
    • Modified get_new_repoclosure to explicitly use the modified repository directory paths via --repofrompath.
  • Impact: rmdepcheck.py, tests/test_rmdepcheck.py
  • Risk Level: 🟢 Low - The changes mostly involve refactoring where a temporary directory is created and passing it around explicitly to ensure DNF resolves the modified paths, which is structurally safe and localized.

Detailed Code Review

The implementation correctly identifies and fixes the fragility of relying on DNF's cache. By hoisting the creation of the temporary directory up to main(), both get_modified_repoclosure and get_new_repoclosure can reliably access the exact same modified repodata on disk. The refactoring is clean and correctly updates the respective CLI arguments for DNF.

One minor concern regarding the unit tests: in test_get_new_repoclosure, an empty temporary directory is passed. Since get_modified_repoclosure isn't called prior to populate it, DNF might receive a path to a directory that lacks actual repodata, which could lead to unexpected behavior if DNF strictly validates the --repofrompath location. Ensure the test environment properly handles or mocks this scenario.

📂 File Reviews

📄 `tests/test_rmdepcheck.py` - Updates test functions to pass a temporary directory to the modified functions.
  • Minor [Testing]: In test_get_new_repoclosure, tempdir is empty because get_modified_repoclosure is never called to populate it. Passing an unpopulated directory to get_new_repoclosure might cause DNF to fail or emit warnings if it attempts to resolve --repofrompath and cannot find a repodata subdirectory.
    • Suggestion: If DNF actually runs in these tests (and isn't mocked), you may need to either mock the DNF call or ensure that the required repodata structure exists in the tempdir before calling get_new_repoclosure.

Summary

  • Overall Assessment: The logic perfectly matches the intended fix, reliably forcing DNF to use the modified metadata path. No critical issues were found.
  • Minor Suggestions:
    • Verify that test_get_new_repoclosure successfully executes in CI without DNF failing due to missing repodata inside the empty tempdir.

🤖 AI Code Review | Generated with ai-code-review
Platform: Forgejo | AI Provider: gemini | Model: gemini-3-pro-preview

## AI Code Review ### 📋 MR Summary Fixes a bug where `get_new_repoclosure` relied on DNF caching to use modified repodata by explicitly sharing the temporary directory containing the modified metadata. - **Key Changes:** - Extracted the creation of the temporary directory for modified repodata to `main()`. - Updated `get_modified_repoclosure` to accept the shared temporary directory rather than creating its own. - Modified `get_new_repoclosure` to explicitly use the modified repository directory paths via `--repofrompath`. - **Impact:** rmdepcheck.py, tests/test_rmdepcheck.py - **Risk Level:** 🟢 Low - The changes mostly involve refactoring where a temporary directory is created and passing it around explicitly to ensure DNF resolves the modified paths, which is structurally safe and localized. ### Detailed Code Review The implementation correctly identifies and fixes the fragility of relying on DNF's cache. By hoisting the creation of the temporary directory up to `main()`, both `get_modified_repoclosure` and `get_new_repoclosure` can reliably access the exact same modified repodata on disk. The refactoring is clean and correctly updates the respective CLI arguments for DNF. One minor concern regarding the unit tests: in `test_get_new_repoclosure`, an empty temporary directory is passed. Since `get_modified_repoclosure` isn't called prior to populate it, DNF might receive a path to a directory that lacks actual `repodata`, which could lead to unexpected behavior if DNF strictly validates the `--repofrompath` location. Ensure the test environment properly handles or mocks this scenario. #### 📂 File Reviews <details> <summary><strong>📄 `tests/test_rmdepcheck.py`</strong> - Updates test functions to pass a temporary directory to the modified functions.</summary> - **Minor** [Testing]: In `test_get_new_repoclosure`, `tempdir` is empty because `get_modified_repoclosure` is never called to populate it. Passing an unpopulated directory to `get_new_repoclosure` might cause DNF to fail or emit warnings if it attempts to resolve `--repofrompath` and cannot find a `repodata` subdirectory. - *Suggestion:* If DNF actually runs in these tests (and isn't mocked), you may need to either mock the DNF call or ensure that the required repodata structure exists in the `tempdir` before calling `get_new_repoclosure`. </details> ### ✅ Summary - **Overall Assessment:** The logic perfectly matches the intended fix, reliably forcing DNF to use the modified metadata path. No critical issues were found. - **Minor Suggestions:** - Verify that `test_get_new_repoclosure` successfully executes in CI without DNF failing due to missing `repodata` inside the empty `tempdir`. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) **Platform:** Forgejo | **AI Provider:** gemini | **Model:** gemini-3-pro-preview
adamwill force-pushed fix-new-repoclosure from c2b6ce2a72
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m26s
AI Code Review / ai-review (pull_request_target) Successful in 20s
AI Code Review / remove-label (pull_request_target) Successful in 2s
to 373b91865d
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m27s
2026-03-21 06:40:20 +00:00
Compare
Author
Owner

Tweaked. I should probably make test_get_new_repoclosure actually test this case properly, too, though.

Tweaked. I should probably make `test_get_new_repoclosure` actually test this case properly, too, though.
adamwill force-pushed fix-new-repoclosure from 373b91865d
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m27s
to 30c5b6a8f7
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m52s
2026-03-22 04:39:13 +00:00
Compare
adamwill force-pushed fix-new-repoclosure from 30c5b6a8f7
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m52s
to 4f8278c938
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m31s
2026-03-22 04:44:24 +00:00
Compare
adamwill force-pushed fix-new-repoclosure from 4f8278c938
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m31s
to 3e75b7f184
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m33s
2026-03-22 04:47:31 +00:00
Compare
adamwill force-pushed fix-new-repoclosure from 3e75b7f184
Some checks failed
CI via Tox / tox (pull_request) Failing after 1m33s
to b8b5612f50
All checks were successful
CI via Tox / tox (pull_request) Successful in 1m35s
AI Code Review / ai-review (pull_request_target) Successful in 14s
AI Code Review / remove-label (pull_request_target) Successful in 2s
2026-03-22 04:54:20 +00:00
Compare

AI Code Review

📋 MR Summary

This MR fixes an issue where get_new_repoclosure was not using modified repodata by explicitly creating a temporary directory for the modified repodata in main() and passing its path to both get_modified_repoclosure and get_new_repoclosure.

  • Key Changes:
    • Removed the creation of a temporary directory from inside get_modified_repoclosure and moved it up to the main() function.
    • Updated get_modified_repoclosure to accept the mreposdir argument and use it for storing modified repository metadata.
    • Modified get_new_repoclosure to accept the mrepos and mreposdir arguments and append them to the dnf repoclosure command parameters.
    • Updated test suite with new mock repository configurations and new expected test outputs.
  • Impact: rmdepcheck.py, tests/test_rmdepcheck.py, tests/testdata/*
  • Risk Level: 🟡 Medium - Modifies core dependency resolution parameters by passing a new shared directory for modified repodata. If the directory cleanup is mishandled or paths mismatch, it may lead to false positives or IO errors. However, using the standard tempfile.TemporaryDirectory with a context manager minimizes file descriptor and resource leaks.

Detailed Code Review

The structural change of lifting the temporary directory creation to main() is sensible. It establishes a clear, shared source of truth (the modified repodata) that prevents relying on unpredictable DNF caching behavior. The unit tests are properly updated to account for the new function signatures, and a new test package (222) ensures the new logic explicitly fails as intended when testing removed baseline dependencies. The use of a context manager (with tempfile.TemporaryDirectory() as mreposdir:) ensures appropriate teardown. The changes appear correct and align with the described intent.

Summary

  • Overall Assessment: The changes directly address the DNF caching fragility by explicitly sharing the modified metadata. The logic appears sound, and test coverage is comprehensive. No critical issues identified.
  • Minor Suggestions:
    • Verify that DNF cache expiration won't unexpectedly overwrite the explicitly supplied repository paths in extreme edge cases, although --repofrompath generally overrides default configurations correctly.

🤖 AI Code Review | Generated with ai-code-review
Platform: Forgejo | AI Provider: gemini | Model: gemini-3-pro-preview

## AI Code Review ### 📋 MR Summary This MR fixes an issue where `get_new_repoclosure` was not using modified repodata by explicitly creating a temporary directory for the modified repodata in `main()` and passing its path to both `get_modified_repoclosure` and `get_new_repoclosure`. - **Key Changes:** - Removed the creation of a temporary directory from inside `get_modified_repoclosure` and moved it up to the `main()` function. - Updated `get_modified_repoclosure` to accept the `mreposdir` argument and use it for storing modified repository metadata. - Modified `get_new_repoclosure` to accept the `mrepos` and `mreposdir` arguments and append them to the `dnf repoclosure` command parameters. - Updated test suite with new mock repository configurations and new expected test outputs. - **Impact:** rmdepcheck.py, tests/test_rmdepcheck.py, tests/testdata/* - **Risk Level:** 🟡 Medium - Modifies core dependency resolution parameters by passing a new shared directory for modified repodata. If the directory cleanup is mishandled or paths mismatch, it may lead to false positives or IO errors. However, using the standard `tempfile.TemporaryDirectory` with a context manager minimizes file descriptor and resource leaks. ### Detailed Code Review The structural change of lifting the temporary directory creation to `main()` is sensible. It establishes a clear, shared source of truth (the modified repodata) that prevents relying on unpredictable DNF caching behavior. The unit tests are properly updated to account for the new function signatures, and a new test package (`222`) ensures the new logic explicitly fails as intended when testing removed baseline dependencies. The use of a context manager (`with tempfile.TemporaryDirectory() as mreposdir:`) ensures appropriate teardown. The changes appear correct and align with the described intent. ### ✅ Summary - **Overall Assessment:** The changes directly address the DNF caching fragility by explicitly sharing the modified metadata. The logic appears sound, and test coverage is comprehensive. No critical issues identified. - **Minor Suggestions:** - Verify that DNF cache expiration won't unexpectedly overwrite the explicitly supplied repository paths in extreme edge cases, although `--repofrompath` generally overrides default configurations correctly. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) **Platform:** Forgejo | **AI Provider:** gemini | **Model:** gemini-3-pro-preview
adamwill deleted branch fix-new-repoclosure 2026-03-22 04:59:58 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quality/rmdepcheck!14
No description provided.