RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1781664 - Variables definitions are not propagated to included profiles.
Summary: Variables definitions are not propagated to included profiles.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: tuned
Version: 7.7
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Jaroslav Škarvada
QA Contact: Robin Hack
URL:
Whiteboard:
Depends On:
Blocks: 1757052 1780577 1788102
TreeView+ depends on / blocked
 
Reported: 2019-12-10 11:24 UTC by Jiří Mencák
Modified: 2022-12-22 21:49 UTC (History)
6 users (show)

Fixed In Version: tuned-2.11.0-9.el7
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 1788102 (view as bug list)
Environment:
Last Closed: 2020-09-29 19:36:52 UTC
Target Upstream Version:
Embargoed:
thozza: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github redhat-performance tuned pull 239 0 None closed profiles: Make sure variables are defined before use 2020-07-27 11:37:23 UTC
Red Hat Issue Tracker RHELPLAN-53494 0 None None None 2022-12-22 21:49:31 UTC
Red Hat Product Errata RHBA-2020:3884 0 None None None 2020-09-29 19:37:18 UTC

Description Jiří Mencák 2019-12-10 11:24:48 UTC
Description of problem:
Assume there is a profile 'child' that defines a variable 'isolated_cores' and includes profile 'parent'.  Variable 'isolated_cores' will not be visible in profile 'parent'.

Version-Release number of selected component (if applicable):
tuned-2.11.0-5.el7.noarch

How reproducible:
Always

Steps to Reproduce:
# On a freshly installed 7.7 system

[root@b7 ~]# mkdir -p /etc/tuned/child
[root@b7 ~]# echo >/etc/tuned/child/tuned.conf<<'EOF'
> [main]
> summary=Isolated cores child
> include = parent
> 
> [variables]
> isolated_cores=1
> EOF

[root@b7 ~]# mkdir -p /etc/tuned/parent
[root@b7 ~]# cat >/etc/tuned/parent/tuned.conf<<'EOF'
> [main]
> summary=Isolated cores parent
>
> [variables]
> isolated_cores_assert_check = \\${isolated_cores}
> # Fail if isolated_cores are not set
> assert1=${f:assertion_non_equal:isolated_cores defined:${isolated_cores}:${isolated_cores_assert_check}}
> EOF

[root@b7 ~]# systemctl stop tuned
[root@b7 ~]# echo child >/etc/tuned/active_profile
[root@b7 ~]# tuned --debug
2019-12-10 06:11:51,832 INFO     tuned.daemon.application: dynamic tuning is globally disabled
2019-12-10 06:11:51,836 DEBUG    tuned.daemon.daemon: initializing daemon
2019-12-10 06:11:51,836 INFO     tuned.daemon.daemon: using sleep interval of 1 second(s)
2019-12-10 06:11:51,837 INFO     tuned.profiles.loader: loading profile: child
2019-12-10 06:11:51,838 DEBUG    tuned.profiles.functions.repository: creating function assertion_non_equal
2019-12-10 06:11:51,838 DEBUG    tuned.utils.plugin_loader: loading module tuned.profiles.functions.function_assertion_non_equal
2019-12-10 06:11:51,839 ERROR    tuned.profiles.functions.function_assertion_non_equal: assertion 'isolated_cores defined' failed: '${isolated_cores}' == '${isolated_cores}'
2019-12-10 06:11:51,839 ERROR    tuned.daemon.daemon: Cannot set initial profile. No tunings will be enabled: Cannot load profile(s) 'child': Assertion 'isolated_cores defined' failed.
2019-12-10 06:11:51,841 INFO     tuned.daemon.controller: starting controller

Expected behaviour (isolated_cores variable is visible in the included parent profile):
[root@b7 parent]# tuned --debug
2019-12-10 06:13:23,239 INFO     tuned.daemon.application: dynamic tuning is globally disabled
2019-12-10 06:13:23,243 DEBUG    tuned.daemon.daemon: initializing daemon
2019-12-10 06:13:23,243 INFO     tuned.daemon.daemon: using sleep interval of 1 second(s)
2019-12-10 06:13:23,244 INFO     tuned.profiles.loader: loading profile: child
2019-12-10 06:13:23,246 DEBUG    tuned.profiles.functions.repository: creating function assertion_non_equal
2019-12-10 06:13:23,246 DEBUG    tuned.utils.plugin_loader: loading module tuned.profiles.functions.function_assertion_non_equal
2019-12-10 06:13:23,248 INFO     tuned.daemon.controller: starting controller
2019-12-10 06:13:23,248 INFO     tuned.daemon.daemon: starting tuning
2019-12-10 06:13:23,248 DEBUG    tuned.hardware.inventory: starting monitor observer
2019-12-10 06:13:23,249 INFO     tuned.daemon.daemon: static tuning from profile 'child' applied

Comment 3 Jaroslav Škarvada 2019-12-11 09:43:28 UTC
Hi,

what you are doing is:

parent                 ->     child
referencing variable          defining variable isolated_cores
isolated_cores
that doesn't exist

I.e. you are referencing undefined variable, you need to do it the opposite way:

parent                 ->     child
isolated_cores=1              reference/use variable_cores

It's not only about variables, all inheritance in Tuned works (and worked) this way.

Comment 4 Jiří Mencák 2019-12-11 10:18:04 UTC
(In reply to Jaroslav Škarvada from comment #3)
> Hi,
> 
> what you are doing is:
> 
> parent                 ->     child
> referencing variable          defining variable isolated_cores
> isolated_cores
> that doesn't exist
> 
> I.e. you are referencing undefined variable, you need to do it the opposite
> way:
> 
> parent                 ->     child
> isolated_cores=1              reference/use variable_cores
> 
> It's not only about variables, all inheritance in Tuned works (and worked)
> this way.

Thanks, Jaroslav!  I can see what you're saying and what you describe works.  I
was thinking about the "include" directive more in the sense of C-like #include
or a shell-like "source".  But looking at:
https://github.com/redhat-performance/tuned/blob/master/doc/manual/modules/performance/con_inheritance-between-tuned-profiles.adoc
basically confirms what you're saying even though a bit more detail about variable
scopes would be appreciated in the docs.  I still believe that a way of defining
the variables I describe would be useful to avoid the need for hard-coding these
into parent configuration files.  Would an RFE for something like [global-variables]
make sense?

Comment 5 Ondřej Lysoněk 2019-12-12 15:33:08 UTC
Hi Jirko,

before discussing an RFE, let's talk about your specific use case. I think we might be able to find a solution without adding any new features.

My guess is that what you really want to do is create a new profile that will hardcode a value of isolated_cores, so that you can use e.g. the cpu-partitioning profile without having to modify /etc/tuned/cpu-partitioning-variables.conf. You can achieve that by creating a profile and a variables file as follows:

$ cat /etc/tuned/foo/tuned.conf
[main]
include=cpu-partitioning

[variables]
include=/etc/tuned/foo-variables.conf

$ cat /etc/tuned/foo-variables.conf
isolated_cores=1

Then simply applying the 'foo' profile should work.

It works by overriding the 'include' in the '[variables]' section, making sure that the assertions in cpu-partitioning are evaluated only after isolated_cores is defined. The realtime profiles use the same approach.

To make your example from comment#0 work, you can simply define 'isolated_cores' in the parent profile (to an arbitrary value; perhaps an empty string). (I think we could add 'isolated_cores=' to our profiles that use isolated_cores.)

$ cat /etc/tuned/parent/tuned.conf
[main]
summary=Isolated cores parent

[variables]
isolated_cores=
isolated_cores_assert_check = \\${isolated_cores}
# Fail if isolated_cores are not set
assert1=${f:assertion_non_equal:isolated_cores defined:${isolated_cores}:${isolated_cores_assert_check}}


Does this solve your problem? If not, can you talk about your use case?

Comment 6 Jiří Mencák 2019-12-12 20:19:51 UTC
Hi Ondro, thanks for looking into this!

(In reply to Ondřej Lysoněk from comment #5)
> My guess is that what you really want to do is create a new profile that
> will hardcode a value of isolated_cores, so that you can use e.g. the
> cpu-partitioning profile without having to modify
> /etc/tuned/cpu-partitioning-variables.conf.
Exactly.  A child profile wants to include a parent profile + specify
variables for the parent profile.

> $ cat /etc/tuned/foo/tuned.conf
> [main]
> include=cpu-partitioning
> 
> [variables]
> include=/etc/tuned/foo-variables.conf
> 
> $ cat /etc/tuned/foo-variables.conf
> isolated_cores=1
> 
> Then simply applying the 'foo' profile should work.
It does work and thanks for the tip.  However, consider tuned is running
inside a container and you cannot (or you do not want to) directly modify
/etc/tuned/foo-variables.conf in the container.  Then you are out of luck.

> To make your example from comment#0 work, you can simply define
> 'isolated_cores' in the parent profile (to an arbitrary value; perhaps an
> empty string). (I think we could add 'isolated_cores=' to our profiles that
> use isolated_cores.)
> 
> $ cat /etc/tuned/parent/tuned.conf
> [main]
> summary=Isolated cores parent
> 
> [variables]
> isolated_cores=
> isolated_cores_assert_check = \\${isolated_cores}
> # Fail if isolated_cores are not set
> assert1=${f:assertion_non_equal:isolated_cores
> defined:${isolated_cores}:${isolated_cores_assert_check}}
So this is a lot closer to what I'm looking for and this also (nearly)
works.  Semantically, you declare a global variable in the parent profile.
However, after this declaration the assertion doesn't seem to work any 
more -- the test always passes.

What works for me is this:

[main]
summary=Isolated cores parent

[variables]
isolated_cores=
# Fail if isolated_cores are not set
assert1=${f:assertion_non_equal:isolated_cores defined:${isolated_cores}:}

However, this assertion doesn't work for me when you're using the "include" keyword
in the [variables] section, so this likely needs another BZ for the assertion_non_equal
function or the way variable values are expanded.
 
> Does this solve your problem? If not, can you talk about your use case?
I believe we're getting very close to having a solution, thanks again for looking!

Comment 7 Ondřej Lysoněk 2019-12-13 09:43:22 UTC
(In reply to jmencak from comment #6)
> > $ cat /etc/tuned/foo/tuned.conf
> > [main]
> > include=cpu-partitioning
> > 
> > [variables]
> > include=/etc/tuned/foo-variables.conf
> > 
> > $ cat /etc/tuned/foo-variables.conf
> > isolated_cores=1
> > 
> > Then simply applying the 'foo' profile should work.
> It does work and thanks for the tip.  However, consider tuned is running
> inside a container and you cannot (or you do not want to) directly modify
> /etc/tuned/foo-variables.conf in the container.  Then you are out of luck.

You would not have to modify foo-variables.conf. You could simply ship the file, along with the profile itself, with 'isolated_cores' preset to '1', couldn't you? What is the difference for you between having 'isolated_cores=1' in foo-variables.conf vs. in the profile itself?

Comment 8 Jiří Mencák 2019-12-13 10:28:37 UTC
(In reply to Ondřej Lysoněk from comment #7)
> > > Then simply applying the 'foo' profile should work.
> > It does work and thanks for the tip.  However, consider tuned is running
> > inside a container and you cannot (or you do not want to) directly modify
> > /etc/tuned/foo-variables.conf in the container.  Then you are out of luck.
> 
> You would not have to modify foo-variables.conf. You could simply ship the
> file, along with the profile itself, with 'isolated_cores' preset to '1',
> couldn't you? What is the difference for you between having
> 'isolated_cores=1' in foo-variables.conf vs. in the profile itself?

So the difference is you'd need to create that file at build time when you're
creating the image for the container vs. specifying the value for the container
at runtime.  The child "profile itself" where you'd define the variables lives
as a object outside of the container (Kubernetes custom resource) and is being
passed to the container with the variable (e.g. isolated_cores=1) set at runtime.
Users can directly modify that child profile and the associated variables.
I try to keep the API (the Kubernetes custom resource) for specifying the profiles
for the container as simple as possible.  Any changes to the API basically mean
you have to live with it and support it.  At the moment, the API to "pass profiles"
into the container is just the tuned profile itself (tuned.conf).  No scripts,
no configuration files (e.g. with isolated_cores=1) can be passed/written into
the container as files.

If the issues with the assertions I raised in comment6 are addressed and the
existing cpu-partitioning/realtime profiles modified to expose the variables
globally, this solves the problem I'm facing now.

Comment 9 Ondřej Lysoněk 2019-12-16 11:15:57 UTC
I see. Thanks for the explanation.

Would it work for you if we modified our profiles as follows?
https://github.com/olysonek/tuned/commit/d7bb97ff36f63dce0e96418a2db2a3d08976d188

With that patch in place, you should be able to set isolated_cores directly in the profile (tuned.conf). The assertions should also work now.

[main]
include=cpu-partitioning

[variables]
isolated_cores=3

Comment 10 Jiří Mencák 2019-12-16 13:18:17 UTC
(In reply to Ondřej Lysoněk from comment #9)
> Would it work for you if we modified our profiles as follows?
> https://github.com/olysonek/tuned/commit/
> d7bb97ff36f63dce0e96418a2db2a3d08976d188
> 
> With that patch in place, you should be able to set isolated_cores directly
> in the profile (tuned.conf). The assertions should also work now.
> 
> [main]
> include=cpu-partitioning
> 
> [variables]
> isolated_cores=3

I see, so to me this is beginning to look like all the variables are actually global
and being propagated to the parent profile, only the expansion behaviour in the parent's
[variables] section is a bit "unexpected".  So the commit you mention solves the issue,
and even the associated "no_balance_cores" variable of the cpu-partitioning profile
can be passed from a "child" to "parent" profile.  However, I'm not convinced this is the
right way of fixing the issue.  Nevertheless, I believe we need a solution...

I believe the variable expansion in tuned needs to be documented or (even better) revised
in the tuned code itself..  Do we need a new BZ for this or can it be tracked by this BZ?

Comment 11 Jaroslav Škarvada 2020-01-06 12:38:55 UTC
(In reply to Ondřej Lysoněk from comment #9)
> I see. Thanks for the explanation.
> 
> Would it work for you if we modified our profiles as follows?
> https://github.com/olysonek/tuned/commit/
> d7bb97ff36f63dce0e96418a2db2a3d08976d188
> 
> With that patch in place, you should be able to set isolated_cores directly
> in the profile (tuned.conf). The assertions should also work now.
> 
> [main]
> include=cpu-partitioning
> 
> [variables]
> isolated_cores=3

Similar approach will be required for realtime profiles.

Comment 12 Ondřej Lysoněk 2020-01-06 15:15:15 UTC
Jarda and I agreed that what I proposed is a good enough solution, so I finished the fix. Upstream PR:
https://github.com/redhat-performance/tuned/pull/239

(In reply to jmencak from comment #10)
> So the commit you mention solves
> the issue,
> and even the associated "no_balance_cores" variable of the cpu-partitioning
> profile
> can be passed from a "child" to "parent" profile.

Actually I don't think that no_balance_cores worked properly with the previous version of the patch. The current version should handle it though.

Comment 22 errata-xmlrpc 2020-09-29 19:36:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (tuned bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:3884


Note You need to log in before you can comment on or make changes to this bug.