-
Notifications
You must be signed in to change notification settings - Fork 11
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
Improve crosync configure #80
base: main
Are you sure you want to change the base?
Improve crosync configure #80
Conversation
4193538
to
3c4aa36
Compare
4e6f0c7
to
3c4aa36
Compare
aadb812
to
9febaff
Compare
@@ -298,11 +299,16 @@ def cluster_configured( | |||
return ret | |||
|
|||
|
|||
def _convert2dict(file_content_lines): | |||
DUMMY_SEC_NAME_TEMPL = "__{}_list" | |||
KNOWN_SEC_NAMES_WITH_LIST = ("totem.interface", "nodelist.node") |
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.
Predefined the known section names possible with multi items
87ddc98
to
3dba9a8
Compare
output += '{}}}\n'.format(indentation) | ||
else: | ||
output += '{}{}: {}\n'.format(indentation, key, value) | ||
output += _unpack_dict(key, value, indentation) |
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.
Refactor this part to pass the codeclimate checking
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.
Nice touch!
3dba9a8
to
9ad7dc1
Compare
if key in main_dict.keys() and not isinstance(value, dict): | ||
if str(main_dict[key]) != str(value): | ||
applied_changes[current_path] = value | ||
main_dict[key] = value | ||
elif key in main_dict.keys(): | ||
modified_dict, new_changes = _mergedicts(main_dict[key], value, applied_changes, current_path) | ||
main_dict[key] = modified_dict | ||
applied_changes.update(new_changes) |
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.
From observing results, seems no need to update main_dict and applied_changes here.
@arbulu89 Please review this, thank you! |
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.
@liangxin1300
The change looks good (even though it is quite complex hehe, but I understand that this complexity is needed).
I have some some superficial comments, so feel free to change or not.
Really nice job!
salt/states/crmshmod.py
Outdated
corodict[line_items[0][:-1]] = line_items[-1] | ||
initial_path = re.sub("\.{}".format(sec_name), "", initial_path) if "." in initial_path else "" | ||
elif ':' in stripped_line: | ||
key, *values = stripped_line.split(':') |
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.
I don't really like this. I guess you do this packing to filter the IP like values. Is there some better way to find those options? Like some regular expression. It looks pretty strange otherwise (it took me some time to understand what was going on here)
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.
Maybe we could add a comment here to explain the purpose
Regular expression might more prone to errors
salt/states/crmshmod.py
Outdated
initial_path += ".{}".format(sec_name) if initial_path else sec_name | ||
sub_dict, new_index = _convert2dict(file_content_lines[i+1:], initial_path) | ||
if initial_path in KNOWN_SEC_NAMES_WITH_LIST: | ||
dummpy_sec_name = DUMMY_SEC_NAME_TEMPL.format(sec_name) |
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.
I don't really like the DUMMY
term. This value is actually a modified value, right?
Maybe better modified_sec_name
?
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.
Changed
output += '{}}}\n'.format(indentation) | ||
else: | ||
output += '{}{}: {}\n'.format(indentation, key, value) | ||
output += _unpack_dict(key, value, indentation) |
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.
Nice touch!
b43c61d
to
89648b3
Compare
@arbulu89 Thanks for review! |
@liangxin1300 And this code supports corosync3? We can do the next:
|
Not yet.
But in the future, might be after 30 Jun 2022, when 12sp3 end of life, we ha stack could not consider py2 anymore, right?
Agree with you.
Like this 9ce19d9? |
Yes! Thanks |
@liangxin1300 By the way, I don't know why the UT execution has been skipped... Most probably these changes will break the tests. Let me check this |
@liangxin1300 I have re-enabled the test in the CI in: #81 |
ok, I will complete UT code if needed |
9ce19d9
to
022f4a1
Compare
7e5cc40
to
3956bdc
Compare
* Parse multi interface/node as list in the dict * When there is no space between words in corosync.conf, like "totem{" or "ring0_addr:10.10.10.121", corosync still works, but our parse results are wrong
29b95cd
to
fe7fe55
Compare
@arbulu89 The UT codes have passed:) |
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.
@liangxin1300 Great work! I think we are ready to merge
To address these issues
corosync still works, but our parse results are wrong