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

fix: Use tuned files instead of using it as a module #220

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

richm
Copy link
Collaborator

@richm richm commented Aug 9, 2024

The previous version of the kernel_settings role used tuned as
a python library, and had a kernel_settings module which was a
wrapper around this code. However, tuned version 2.23 has changed
its internal API and it is no longer possible to use it as a python
library. Instead, the kernel_settings role has been refactored to
read/write tuned config files, and let the tuned daemon manage
the settings.

In addition, tuned 2.23 changed the location of the profile directory,
so the kernel_settings role will now determine the location of the
profile directory depending on the tuned version.

The old kernel_settings module is removed, along with all of the
python unit testing code.

A new kernel_settings_get_config module has been created which will
simply parse and return the given config file as a dict.

Signed-off-by: Rich Megginson rmeggins@redhat.com

try:
import configobj

HAS_CONFIGOBJ = True

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'HAS_CONFIGOBJ' is not used.

HAS_CONFIGOBJ = True
except ImportError:
HAS_CONFIGOBJ = False

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'HAS_CONFIGOBJ' is not used.
The previous version of the kernel_settings role used `tuned` as
a python library, and had a `kernel_settings` module which was a
wrapper around this code.  However, `tuned` version 2.23 has changed
its internal API and it is no longer possible to use it as a python
library.  Instead, the kernel_settings role has been refactored to
read/write `tuned` config files, and let the `tuned` daemon manage
the settings.

In addition, `tuned` 2.23 changed the location of the profile directory,
so the kernel_settings role will now determine the location of the
profile directory depending on the `tuned` version.

The old `kernel_settings` module is removed, along with all of the
python unit testing code.

A new `kernel_settings_get_config` module has been created which will
simply parse and return the given config file as a `dict`.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm
Copy link
Collaborator Author

richm commented Aug 9, 2024

[citest]

@richm richm requested a review from spetrosi August 9, 2024 15:17
tasks/main.yml Show resolved Hide resolved
tasks/main.yml Outdated Show resolved Hide resolved

- name: Set profile_mode to manual
copy:
content: >
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
content: >
content: manual

is it the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to ensure the file ends with a newline - not sure if content: manual will ensure that

- name: Set profile_mode to manual
copy:
content: >
manual
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
manual

- name: sysctl
new: "{{ kernel_settings_sysctl | difference([__kernel_settings_previous_replaced]) | list
if kernel_settings_sysctl != __kernel_settings_state_empty
else [] }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why __sysctl_old is set to dict {} and new is set to list []?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tuned-adm profile {{ __kernel_settings_active_profile | quote }}
when:
- not __kernel_settings_register_profile is changed
- not __kernel_settings_register_mode is changed
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the above task, there is or between these two checks, here they both should be changed to restart apply tuned?

Copy link
Collaborator Author

@richm richm Aug 9, 2024

Choose a reason for hiding this comment

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

Restarting tuned will also apply the changes made by the template task
tuned must be restarted in order to apply the profile_mode or active_profile changes
If tuned has been restarted due to the above, we can skip doing the tuned-adm profile

@richm
Copy link
Collaborator Author

richm commented Aug 9, 2024

[citest]

@richm richm merged commit 2218b1c into linux-system-roles:main Aug 9, 2024
31 of 33 checks passed
@richm richm deleted the use-tuned-but-not-module branch August 9, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants