-
Notifications
You must be signed in to change notification settings - Fork 186
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: check status created a machine-id file #3965
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would solve it, but I am not really a fan of some of the parts.
- Have you considered changing the original
client.get_machine_id
to accept acreate
flag, instead of creating a new function with similar name in the utils?
insights-core/insights/client/client.py
Lines 307 to 308 in f547907
def get_machine_id(): return generate_machine_id() - If that would be too complicated, I found out you are only checking if the returned value is not None. Would it make sense to rename it to something like
machine_id_exists()
returning a bool?
I considered that, but there is also a flag to create a new file, independently if it already exists. After this fix, I was considering to create a new ticket to make some effort refactoring this utility because is a bit entangled. Ideally, discerning the functions that use this method into 2, the ones that need by any cost an id, and the ones that doesn't need an id.
Not only, if it exists it returns the value of machine-id |
Changelog
|
@@ -42,10 +44,10 @@ def test_registration_check_ok_reg_then_unreg(get_proxies, _init_session, _): | |||
assert conn.api_registration_check() == '2019-04-10' | |||
|
|||
|
|||
@patch("insights.client.connection.generate_machine_id", return_value='xxxxxx') | |||
@patch("insights.client.connection.False", return_value=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a bad copy-paste
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test me |
Verification pass on this open PR, please refer details: https://issues.redhat.com/browse/CCT-161 |
@xiangce This can be on the next egg release |
This method returns a boolean whether the machine-id file exists or not. This will be used to check the file before call, generate_machine_id to get the machine-id, as this last method will create a new id if it doesn't exist. Resolves: CCT-161 Signed-off-by: ahitacat <[email protected]>
When checking registration status, first check if the machine-id file exists. When checking status it is not needed to generate a machine-id file if it doesn't exists. Resolves: CCT-161 Signed-off-by: ahitacat <[email protected]>
Also create a new test to check a new machine id is created if the file does not exists. Signed-off-by: ahitacat <[email protected]>
* feat: add machine_id_exists method This method returns a boolean whether the machine-id file exists or not. This will be used to check the file before call, generate_machine_id to get the machine-id, as this last method will create a new id if it doesn't exist. Resolves: CCT-161 Signed-off-by: ahitacat <[email protected]> * fix: use machine_id_exists before checking host status When checking registration status, first check if the machine-id file exists. When checking status it is not needed to generate a machine-id file if it doesn't exists. Resolves: CCT-161 Signed-off-by: ahitacat <[email protected]> * fix: Change test that generated id and now use get_machineid Also create a new test to check a new machine id is created if the file does not exists. Signed-off-by: ahitacat <[email protected]> --------- Signed-off-by: ahitacat <[email protected]> (cherry picked from commit 5697ed4)
All Pull Requests:
Check all that apply:
Complete Description of Additions/Changes:
When insights-client checked the status created a machine-id file to make some calls to the console service. That created a residual machine file if it had not access to the service (i.e. system was not registered to rhsm).
This PR refactors a bit the logic of generate_machine_id, and splits in a new function that will only get the machine id
get_machineid()
.Checking status and
generate_machine_id
will use this new function.Test have been changed and a new one has been created.
Resolves: CCT-161