Do not fetch disabled remote plans in tmt run#4749
Do not fetch disabled remote plans in tmt run#4749pkhartsk wants to merge 2 commits intoteemtee:mainfrom
tmt run#4749Conversation
There was a problem hiding this comment.
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.
|
/packit build |
|
@pkhartsk one note WRT naming, you seem to be using "imported" and "remote" incorrectly:
|
|
My bad @happz , didn't realise the wording mattered.
Will change.
Would it be better to name it |
Oh indeed it seems identical up to the difference of having 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:
and how should the disablement of the parent affect these |
psss
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
What about using here an inaccessible repository? For example:
| 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.
There was a problem hiding this comment.
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 == enableThere was a problem hiding this comment.
Thing is that some tests I wrote rely on this one being importable, since I wanna test with the context being the desired value..
There was a problem hiding this comment.
Couldn't catch the failure and make sure it fails in an expected way?
There was a problem hiding this comment.
Just to reiterate, plan show should just say something like "couldn't fetch" but fail gracefully, right?
There was a problem hiding this comment.
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.
| # 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", |
There was a problem hiding this comment.
| f"Plan {plan.name} is not enabled, skipping imports resolution", | |
| f"Plan '{plan.name}' is not enabled, skipping plan import during tmt run.", |
There was a problem hiding this comment.
This code now also runs during other commands then run, therefore "during tmt run" is no longer adequate.
| for plan in unresolved_plans: | ||
| try: | ||
| # Do not resolve disabled plans during `tmt run` | ||
| if run is not None and not plan.enabled: |
There was a problem hiding this comment.
Seems that in order to fix the tmt plan ls --enabled use case as well, the following would be sufficient?
| 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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Oh boy, what happened with all of the diff in this test?
There was a problem hiding this comment.
Right, removed everything and added mine, will bring them back
LecrisUT
left a comment
There was a problem hiding this comment.
Overall LGTM, just a style change, and the "what happened with the other tests"
| if not resolve_disabled and not plan.enabled: | ||
| plan.debug( | ||
| f"Plan '{plan.name}' is not enabled, skipping imports resolution", | ||
| level=3, |
There was a problem hiding this comment.
| level=3, |
Let's make it more visible on the first debug level
| links: Optional[list['LinkNeedle']] = None, | ||
| excludes: Optional[list[str]] = None, | ||
| apply_command_line: bool = True, | ||
| resolve_disabled: bool = True, |
There was a problem hiding this comment.
There's quite a bit of double-triple negation here? How about enabled_only?
| 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): |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
this will not expand correctly with the sundle quotes, will it?
Fix #2968
Pull Request Checklist