-
Notifications
You must be signed in to change notification settings - Fork 1.7k
nmcli idempotency connection check #11114
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
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
d3048b9 to
d39cfd9
Compare
This comment was marked as outdated.
This comment was marked as outdated.
felixfontein
left a comment
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.
Thanks for your contribution! Could you please add a changelog fragment? Thanks.
Also having tests for this would be helpful.
@felixfontein thanks for replying.. |
53cc0cb to
ca2f9e8
Compare
This comment was marked as outdated.
This comment was marked as outdated.
russoz
left a comment
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.
hi @saibug
Thanks for your contribution! A couple of comments.
| if rc != 0: | ||
| raise NmcliModuleError(err) | ||
|
|
||
| lines = out.strip().split("\n") |
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:
| lines = out.strip().split("\n") | |
| lines = [ll.strip() for ll in out.splitlines()] |
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 take it a step further:
| lines = out.strip().split("\n") | |
| lines = [ll.strip() for ll in out.splitlines() if "GENERAL.STATE" in ll] |
WDYT?
| lines = out.strip().split("\n") | ||
| for line in lines: | ||
| if "GENERAL.STATE" in line: | ||
| state = line.split(":")[-1].strip() |
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.
if we do strip() for every line as suggested above, then the it becomes redundant here:
| state = line.split(":")[-1].strip() | |
| state = line.split(":")[-1] |
| if module.check_mode: | ||
| module.exit_json(changed=False, **result) |
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 conditional is looking a bit odd to me. If I read this right, if the connection is active and no reload was requested, then there is no change whatsoever, right?
If so, then why respond that only if it's check mode? If it's not check mode, is there anything else to do?
| if module.check_mode: | ||
| module.exit_json(changed=False, **result) |
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.
same here - if there is nothing to be done, why return that only when check mode is on?
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 am missing some update to the docs, to let users know what actions are idempotent (and possibly which are not).
I am also missing some update to the tests, to demonstrate the newly implemented idempotency.
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 think many actions already were idempotent (though not all).
SUMMARY
This PR will update the module to be idempotent by:
Ref : #9897
ISSUE TYPE
COMPONENT NAME