Skip to content

Do not fetch disabled remote plans in tmt run#4749

Open
pkhartsk wants to merge 1 commit intoteemtee:mainfrom
pkhartsk:fix-2968
Open

Do not fetch disabled remote plans in tmt run#4749
pkhartsk wants to merge 1 commit intoteemtee:mainfrom
pkhartsk:fix-2968

Conversation

@pkhartsk
Copy link
Copy Markdown

Fix #2968

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a feature to prevent tmt from resolving imports for plans that are disabled by an adjust rule during a tmt run command. The change adds a check in tmt/base/core.py to skip import resolution if a plan is disabled. A new test case and plan definition validate this behavior. No feedback to provide.

@LecrisUT LecrisUT self-assigned this Mar 25, 2026
@LecrisUT
Copy link
Copy Markdown
Member

LecrisUT commented Mar 25, 2026

/packit test

@happz
Copy link
Copy Markdown
Contributor

happz commented Mar 25, 2026

@pkhartsk one note WRT naming, you seem to be using "imported" and "remote" incorrectly:

  • "Do not fetch disabled remote plans in tmt run" - actually, whether the remote plan is disabled or not is not relevant to your PR, as it skips import resolution if the importing (or "local") plan is disabled. The title should be something like "Do not resolve importing plan when it is disabled".
  • /imported/disabled-by-adjust, summary: Imported plan should be disabled by default, rlPhaseStartTest "Imported plan's import should not be resolved if disabled by adjust" - these are describing importing plan rather than the imported one, as it's the importing plan that's examined and skipped when disabled. In that case there is no imported plan at all.

@pkhartsk
Copy link
Copy Markdown
Author

pkhartsk commented Mar 26, 2026

My bad @happz , didn't realise the wording mattered.

* "Do not fetch disabled remote plans in tmt run" - actually, whether the remote plan is disabled or not is not relevant to your PR, as it skips import resolution if the **importing** (or "local") plan is disabled. The title should be something like "Do not resolve importing plan when it is disabled".

Will change.

* `/imported/disabled-by-adjust`, `summary: Imported plan should be disabled by default`,  `rlPhaseStartTest "Imported plan's import should not be resolved if disabled by adjust"` - these are describing **importing** plan rather than the imported one, as it's the importing plan that's examined and skipped when disabled. In that case there is no imported plan at all.

Would it be better to name it /disabled-by-adjust, "Local plan disabled by adjust should not import remote plan", and "Remote plan should not be fetched if disabled by adjust"?

@LecrisUT
Copy link
Copy Markdown
Member

Would it be better to name it /disabled-by-adjust, "Local plan disabled by adjust should not import remote plan", and "Remote plan should not be fetched if disabled by adjust"?

Oh indeed it seems identical up to the difference of having adjust considered or not. I would say it should be split into /disabled/default and /disabled/by-adjust.

But looking at the tests done for that one, it doesn't seem to do meaningful checks either. At the minimum I would expect it to check for the git cloning (there should be a specific place where the data is cloned to that can be used for the check). The complications is that we have multiple scenarios that we would need to confirm the git cloning is done or not:

  • tmt plans ls
  • tmt plans ls with --shallow or --import-before-name-filter
  • tmt plans show
  • tmt run

and how should the disablement of the parent affect these

Comment on lines +142 to +145
rlPhaseStartTest "Remote plan should not be fetched if disabled by adjust"
rlRun -s "tmt -c distro=fedora-rawhide run --remove --dry plan --name /plans/disabled-by-adjust" 2 "Expect no plans to be found"
rlRun -s "tmt -c distro=fedora-rawhide -c how=full plan show /plans/disabled-by-adjust" 0 "Show plan correctly"
rlPhaseEnd
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can run these with -dd and check rlAssertNotGrep "Run command: git clone" (we will improve it when switching to pytest). And also the debug message you just added.

Currently when no plans are enabled the output is No plans found. let's also check for that one.

@thrix thrix added the area | plan import Support for importing remote plans label Apr 1, 2026
@thrix thrix added this to planning Apr 1, 2026
@github-project-automation github-project-automation bot moved this to backlog in planning Apr 1, 2026
@thrix thrix moved this from backlog to review in planning Apr 1, 2026
@thrix thrix assigned psss and happz Apr 1, 2026
@happz happz added the ci | full test Pull request is ready for the full test execution label Apr 14, 2026
Comment thread tmt/base/core.py
f"Plan {plan.name} is not enabled, skipping imports resolution",
level=3,
)
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if block does not have to be under the try/except block.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Copy link
Copy Markdown
Member

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the approach seems to be good. Added a couple suggestions. Do we want to cover the tmt plan ls and tmt plan show cases here as well? Or we keep the scope to tmt run only?

summary: Local plan disabled by adjust should not import remote plan
plan:
import:
url: https://github.com/teemtee/tmt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using here an inaccessible repository? For example:

Suggested change
url: https://github.com/teemtee/tmt
url: https://localhost/invalid

In this way we would clearly/simply verify that an unexpected git clone was not performed. And it would also reveal that the tmt plan show case is actually failing.

Comment thread tmt/base/core.py
# Do not resolve disabled plans during `tmt run`
if run is not None and not plan.enabled:
plan.debug(
f"Plan {plan.name} is not enabled, skipping imports resolution",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Plan {plan.name} is not enabled, skipping imports resolution",
f"Plan '{plan.name}' is not enabled, skipping plan import during tmt run.",

Comment thread tmt/base/core.py
f"Plan {plan.name} is not enabled, skipping imports resolution",
level=3,
)
continue
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

@psss psss added this to the 1.72 milestone Apr 20, 2026
Comment thread tmt/base/core.py
for plan in unresolved_plans:
try:
# Do not resolve disabled plans during `tmt run`
if run is not None and not plan.enabled:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that in order to fix the tmt plan ls --enabled use case as well, the following would be sufficient?

Suggested change
if run is not None and not plan.enabled:
if (run is not None or Plan._opt('enabled')) and not plan.enabled:

If the fix would be as simple as this (or similar complexity), I'd suggest to fix both use cases in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | plan import Support for importing remote plans ci | full test Pull request is ready for the full test execution

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

Do not fetch disabled remote plans in tmt run

5 participants