Skip to content

Make DEFAULT_OS_SEARCH_QUERY configurable #18697

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dosas
Copy link
Collaborator

@dosas dosas commented Jun 12, 2025

Problem Statement

DEFAULT_OS_SEARCH_QUERY is not configurable via settings

Solution

Make it configurable via settings

Tests to run

tests/foreman/api/test_provisioning_puppet.py::test_positive_puppet_bootstrap

@dosas dosas requested review from ogajduse and Gauravtalreja1 June 12, 2025 14:27
@dosas dosas requested review from a team as code owners June 12, 2025 14:27
@dosas dosas added CherryPick PR needs CherryPick to previous branches 6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z labels Jun 12, 2025
@dosas dosas force-pushed the upstream/default-os-search-query branch from c27668c to 9397a9d Compare June 12, 2025 14:28
@Satellite-QE
Copy link
Collaborator

Can one of the admins verify this patch?

@lhellebr
Copy link
Contributor

lhellebr commented Jun 16, 2025

I think this is OK but somewhat inconsistent with a lot of other constants that also should be a setting but are constants. And is server.yaml the right place? Any thoughts on this? Meanwhile, I will run PRT.

Validator(
'server.default_os_search_query',
is_type_of=str,
must_exist=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that the parameter is forbidden from existing and the run will fail in any case (because if it isn't in the config file, we also provide default value):

dynaconf.validator.ValidationError: server.default_os_search_query cannot exists in env main

Copy link
Contributor

@lhellebr lhellebr left a comment

Choose a reason for hiding this comment

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

My comment for must_exist is a blocker.

@dosas dosas force-pushed the upstream/default-os-search-query branch from 9397a9d to 45ae89a Compare June 17, 2025 05:48
@dosas dosas requested a review from lhellebr June 17, 2025 06:01
@lhellebr
Copy link
Contributor

@dosas , now you require that parameter in config. I think what you originally wanted to do was to make it optional with default value (and I think that's a good approach). If I understand Dynaconf correctly, you can achieve that by not specifying any value to must_exist

@dosas dosas force-pushed the upstream/default-os-search-query branch from 45ae89a to a28a552 Compare June 24, 2025 06:35
@dosas
Copy link
Collaborator Author

dosas commented Jun 24, 2025

@dosas , now you require that parameter in config. I think what you originally wanted to do was to make it optional with default value (and I think that's a good approach). If I understand Dynaconf correctly, you can achieve that by not specifying any value to must_exist

Thanks.

@dosas
Copy link
Collaborator Author

dosas commented Jun 26, 2025

@lhellebr Is there anything left for approval?

@lhellebr
Copy link
Contributor

@dosas I have started a PRT job for you.
Also, I'm giving you my ACK code-wise (i.e., pending green PRT results).
I will be out of office for a few days so someone else will have to pick this up - they'd have to anyway, this needs at least one more reviewer.

Copy link
Contributor

@lhellebr lhellebr left a comment

Choose a reason for hiding this comment

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

Actually, adding one comment where I don't like hardcoded versions so ACK pending PRT and that comment.

@@ -65,3 +65,4 @@ SERVER:
COMMAND_TIMEOUT: 300000
# Time to wait for establishing the ssh connection, in seconds
CONNECTION_TIMEOUT: 60
DEFAULT_OS_SEARCH_QUERY: 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why major="6" OR major="7" OR major="8" OR major="9"? What about 10? What about potential future versions? Why for 6..9?

Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we want to open this can of worms? #10481

@dosas is simply moving the search string from constants to config.

If I understand what all those fixtures are trying to do, it is that they're trying to retrieve an operatingsystem entity from the API - the same type, family, and version that the server is installed on. Correct?

If I were to suggest a solution, I'd say that sat_object.os_version.major could help us identify the major version of the OS, and we could base the search string on that.

Or could we use the default_os fixture instead of these custom fixtures that are being modified as a part of this PR?

Validator(
'server.default_os_search_query',
is_type_of=str,
default='name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")',
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z CherryPick PR needs CherryPick to previous branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants