Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment defined in plan is ignored when importing a plan #2446

Closed
LecrisUT opened this issue Oct 31, 2023 · 2 comments · Fixed by #2452
Closed

Environment defined in plan is ignored when importing a plan #2446

LecrisUT opened this issue Oct 31, 2023 · 2 comments · Fixed by #2452
Assignees
Labels
bug Something isn't working
Milestone

Comments

@LecrisUT
Copy link
Contributor

LecrisUT commented Oct 31, 2023

Description (added by @thrix)

Looks like environment defined in the plan is ignored when importing a plan:

❯ cat import.fmf
plan:
  import:
    url: https://gitlab.com/testing-farm/tests
    name: /testing-farm/sanity
environment:
  SCRIPT: echo huhu
❯ tmt run -avvv provision -h local
....
    report
        how: display
        order: 50
            pass /testing-farm/script
                output.txt: /var/home/mvadkert/.local/share/tmt/run-423/import/execute/data/guest/default-0/testing-farm/script-1/output.txt
                content:
                    NAME="Fedora Linux"
                    VERSION="38 (Container Image)"
                    ID=fedora
....

It ignored the SCRIPT env variable.

Original report

Executor: scikit-build/scikit-build-core#518
Imported plan: packit/tmt-plans#7

Could it be a clash with testing-farm's setting of environment, i.e. the -e @tmt-environment-plans-rpminspect.yaml in

$ /usr/bin/tmt --root .distro -c arch=x86_64 -c distro=fedora-rawhide -c initiator=packit -c trigger=commit run --all --verbose --id /var/ARTIFACTS/work-rpminspectb7tmges9 -e @tmt-environment-plans-rpminspect.yaml provision --how connect --guest 18.117.129.38 --key /etc/citool.d/id_rsa_artemis --port 22 plan --name '^/plans/rpminspect$'

Looking at the code, it shouldn't:

tmt/tmt/base.py

Lines 1668 to 1683 in 7552550

@property
def environment(self) -> EnvironmentType:
""" Return combined environment from plan data and command line """
if self.my_run:
combined = self._environment.copy()
# Command line variables take precedence
combined.update(self.my_run.environment)
# Include path to the plan data directory
combined["TMT_PLAN_DATA"] = str(self.data_directory)
# And tree path if possible
if self.worktree:
combined["TMT_TREE"] = str(self.worktree)
# And tmt version
combined["TMT_VERSION"] = tmt.__version__
return combined
return self._environment

But the log.txt file indicates otherwise 🤔

Or myabe it involves:

tmt/tmt/base.py

Lines 1558 to 1565 in 7552550

self._environment = tmt.utils.environment_from_spec(
raw_fmf_environment_files=node.get("environment-file") or [],
raw_fmf_environment=node.get('environment', {}),
raw_cli_environment_files=self.opt('environment-file') or [],
raw_cli_environment=self.opt('environment'),
file_root=Path(node.root) if node.root else None,
key_address=node.name,
logger=self._logger)

@thrix
Copy link
Collaborator

thrix commented Nov 3, 2023

@LecrisUT could you bit expand more what is exactly the problem here pls?

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Nov 3, 2023

Hi @thrix. Basically, if we call a tmt plan with:

# /plans/rpminspect
plan:
  import:
    url: https://github.com/LecrisUT/tmt-plans
    ref: doc/rpminspect
    name: /plans/rpminspect
environment:
  RPMINSPECT_EXCLUDE: disttag

The configuration in environment is not picked up when it is being executed on testing-farm

@thrix thrix changed the title Editing imported plan does not work on testing-farm Environment defined in plan is ignored when importing a plan Nov 3, 2023
@thrix thrix added this to the 1.31 milestone Nov 3, 2023
@thrix thrix self-assigned this Nov 3, 2023
@thrix thrix added the bug Something isn't working label Nov 3, 2023
thrix added a commit to thrix/tmt that referenced this issue Nov 3, 2023
The `environemnt` is a property of the `Plan` class that modifies
the plan environment stored in the `_environment` dictionary.

If we call `update` on the dictionary it does not really modify the
`_environment` dictionary.

I believe we need to modify the `_environment` dictionary

Resolves teemtee#2446

Signed-off-by: Miroslav Vadkerti <[email protected]>
@thrix thrix modified the milestones: 1.31, 1.30 Nov 3, 2023
thrix added a commit to thrix/tmt that referenced this issue Nov 28, 2023
The environment from the importing plan was ignored.

As agreed, let's make the `environment` a cached property and inherit
the importing plan environment automatically.

Resolves teemtee#2446

Signed-off-by: Miroslav Vadkerti <[email protected]>
thrix added a commit to thrix/tmt that referenced this issue Nov 28, 2023
The environment from the importing plan was ignored.

As agreed, let's make the `environment` a cached property and inherit
the importing plan environment automatically.

Resolves teemtee#2446

Signed-off-by: Miroslav Vadkerti <[email protected]>
psss pushed a commit to thrix/tmt that referenced this issue Dec 5, 2023
The environment from the importing plan was ignored.

As agreed, let's make the `environment` a cached property and inherit
the importing plan environment automatically.

Resolves teemtee#2446

Signed-off-by: Miroslav Vadkerti <[email protected]>
@psss psss closed this as completed in 0b4f4a7 Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants