-
Couldn't load subscription status.
- Fork 167
Add a timeout argument to the junos_commit module #97
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
Merged
vnitinv
merged 1 commit into
Juniper:master
from
stacywsmith:issue_96_timeout_arg_for_junos_commit
Jan 5, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@stacywsmith Can we change the logic where we can simply have 30 sec default value @ timeout=dict(required=False, default=0),
hence the code would change to
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.
@vnitinv Hi Nitin the code in my pull request was copied from the implementation of the timeout argument that's currently used for junos_install_config. I believe you may have misinterpreted the behavior of the code.
If the user does not pass the timeout argument, then line 153 will set timeout = 0, line 154 is not true, and dev.timeout will not be set.
If the user passes a timeout value, then line 153 sets timeout to that value (rounded to nearest int). If the value the user passed is greater than 0, line 154 is true and dev.timeout is set to the user supplied value.
Therefore, if a user passes any numeric value greater than 0, the RPC timeout will be set to the user supplied value.
Here's an example from the debugger.
'''
(Epdb) print args
{'comment': None, 'host': 'core1.site1', 'user': 'user', 'timeout': 10, 'confirm': None, 'passwd': 'user123', 'logfile': None, 'port': 830}
(Epdb) n
You're suggested change is similar in behavior, but would allow the user to set the timeout to a negative value. This causes PyEZ to raise a jnpr.junos.exception.LockError exception which in turn causes the Ansible task/module to fail. Worse yet, it leaves the configuration databases locked causing all further attempts to lock the database to fail.
I believe my existing pull request (copied from the junos_install_config implementation) is preferrable.
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 @stacywsmith
Can you check line https://github.com/Juniper/ansible-junos-stdlib/blob/master/library/junos_install_os#L234
to predefine timeout data type. with this code would change to
timeout = intargs['timeout']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.
Are you suggesting changing line 120 from:
''' timeout=dict(required=False, default=0), '''
to:
''' timeout=dict(required=False, type='int', default=0), '''
If so, I'm fine with that change. However, we should also change this line to match:
https://github.com/Juniper/ansible-junos-stdlib/blob/master/library/junos_install_config#L399
Even with this change, lines 153-155 need to be:
'''
timeout = args['timeout']
if timeout > 0:
dev.timeout = timeout
'''
I'm not sure if your suggesting this, but I don't support changing line 120 to:
''' timeout=dict(required=False, type='int', default=30), '''
I believe the default RPC timeout should continue to be set in only one location (in PyEZ), rather than in both PyEZ (and within multiple locations in the Ansible for Junos modules).
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 Stacy,
I just meant it to be