Skip to content

Do not fetch disabled remote plans in tmt run#4749

Open
pkhartsk wants to merge 2 commits intoteemtee:mainfrom
pkhartsk:fix-2968
Open

Do not fetch disabled remote plans in tmt run#4749
pkhartsk wants to merge 2 commits 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 build

@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 thread tests/plan/import/basic.sh
@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 Outdated
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.

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.

Still relevant. Can re-use the part in /disabled-internal. I don't remember the naming that we agreed on, but an organization like this could work

/importing-disabled:
    plan:
        import:
            url: https://secret.internal
            name: /secret/internal/plan
    /default:
        enabled: false
    /by-adjust:
        enabled: true
        adjust:
            enabled: false
            when: some_context == disable
    /enabled-by-adjust:
        enabled: false
        adjust:
            enabled: false
            when: some_context == enable

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thing is that some tests I wrote rely on this one being importable, since I wanna test with the context being the desired value..

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.

Couldn't catch the failure and make sure it fails in an expected way?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Just to reiterate, plan show should just say something like "couldn't fetch" but fail gracefully, right?

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.

Maybe can do that in a different PR. I expect it to be quite tangential to everything else here, and would probably involve how we handle --shallow there as well. Handling ls could be either way, but would be important to be handled consistently to not disrupt testing-farm.

Comment thread tmt/base/core.py Outdated
# 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.",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This code now also runs during other commands then run, therefore "during tmt run" is no longer adequate.

Comment thread tmt/base/core.py Outdated
@psss psss added this to the 1.72 milestone Apr 20, 2026
Comment thread tmt/base/core.py Outdated
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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Put something akin to this in the latest commit

for plans to give granularity in
deciding which plans should and
should not run/show/ls
rlPhaseEnd


rlPhaseStartTest "Remote plan should not be fetched if disabled by adjust"
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.

Oh boy, what happened with all of the diff in this test?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, removed everything and added mine, will bring them back

Copy link
Copy Markdown
Member

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a style change, and the "what happened with the other tests"

Comment thread tmt/base/core.py
if not resolve_disabled and not plan.enabled:
plan.debug(
f"Plan '{plan.name}' is not enabled, skipping imports resolution",
level=3,
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
level=3,

Let's make it more visible on the first debug level

Comment thread tmt/base/core.py
links: Optional[list['LinkNeedle']] = None,
excludes: Optional[list[str]] = None,
apply_command_line: bool = True,
resolve_disabled: bool = True,
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.

There's quite a bit of double-triple negation here? How about enabled_only?

Comment thread tmt/cli/_root.py
logger = context.obj.logger.clone().apply_verbosity_options(**kwargs)

for plan in context.obj.tree.plans(logger=logger):
for plan in context.obj.tree.plans(logger=logger, resolve_disabled=True):
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.

I think plans_ls would need a similar specification. Let's be more explicit for now to make sure we catch the correct behavior. Would be in favor of inverting the default since it is more conscious consideration how one would handle plans that are disabled.



rlPhaseStartTest "Remote plan should not be fetched if disabled by adjust"
rm -rf '~/.cache/fmf/https:__github.com_teemtee_tmt'
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 will not expand correctly with the sundle quotes, will it?

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