Skip to content
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

unit.run fails if a timeout value is passed #225

Closed
thedac opened this issue Apr 12, 2018 · 1 comment
Closed

unit.run fails if a timeout value is passed #225

thedac opened this issue Apr 12, 2018 · 1 comment

Comments

@thedac
Copy link
Contributor

thedac commented Apr 12, 2018

unit.run with timeout=None succeeds:
REMOTE RUN: unit-get private-address timeout=None
REPLY: {'request-id': 7, 'response': {'results': [{'action': {'tag': 'action-009bdeea-ada7-47e8-8586-a876a4b6cf0b', 'receiver': 'unit-ubuntu-0', 'name': 'juju-run', 'parameters': {'command': 'unit-get private-address', 'timeout': 0}}, 'enqueued': '2018-04-12T16:36:26Z', 'started': '0001-01-01T00:00:00Z', 'completed': '0001-01-01T00:00:00Z', 'status': 'pending'}]}}
ACTION: {'model-uuid': '1a035018-71ff-473e-8aab-d1a8d6b6cda7', 'id': '009bdeea-ada7-47e8-8586-a876a4b6cf0b', 'receiver': 'ubuntu/0', 'name': 'juju-run', 'parameters': {'command': 'unit-get private-address', 'timeout': 0}, 'status': 'completed', 'message': '', 'results': {'Code': '0', 'Stderr': '', 'Stdout': '10.5.0.97\n'}, 'enqueued': '2018-04-12T16:36:26Z', 'started': '2018-04-12T16:36:26Z', 'completed': '2018-04-12T16:36:26Z'}

unit.run with timeout = 300 (or any integer) fails with "command cancelled":
300s TIMEOUT
REMOTE RUN: unit-get private-address timeout=300
REPLY: {'request-id': 7, 'response': {'results': [{'action': {'tag': 'action-67eb94dc-f8a0-4333-878e-fbabf77862a5', 'receiver': 'unit-ubuntu-0', 'name': 'juju-run', 'parameters': {'command': 'unit-get private-address', 'timeout': 300}}, 'enqueued': '2018-04-12T16:36:28Z', 'started': '0001-01-01T00:00:00Z', 'completed': '0001-01-01T00:00:00Z', 'status': 'pending'}]}}
RES: <juju.client._definitions.ActionResults object at 0x7fd9802f23c8>
ACTION: {'model-uuid': '1a035018-71ff-473e-8aab-d1a8d6b6cda7', 'id': '67eb94dc-f8a0-4333-878e-fbabf77862a5', 'receiver': 'ubuntu/0', 'name': 'juju-run', 'parameters': {'command': 'unit-get private-address', 'timeout': 300}, 'status': 'failed', 'message': 'command cancelled', 'enqueued': '2018-04-12T16:36:28Z', 'started': '2018-04-12T16:36:28Z', 'completed': '2018-04-12T16:36:28Z'}

I have tested with various timeout values including large ones in case it is in microseconds. But they all show failed immediately.

@gnuoy
Copy link

gnuoy commented Jun 5, 2018

I'm guessing you didn't try nanoseconds because thats what the timeout value is looking for :-)

gnuoy pushed a commit to gnuoy/python-libjuju that referenced this issue Jun 5, 2018
The juju.unit.run docstring does not specify what units the timeout
value should be in. This led to issue juju#225. Having looked into it,
juju is expecting it to be in nanoseconds. I don't think
nanoseconds is particularly intuitive so I have updated the function
to take the timeout in seconds and convert it internally to
nanoseconds.

I appreciate this is a breaking change for anyone currently specifying
the timeout in nanoseconds so I would quite understand if this change
is nack'd in which case I will submit a subsequent pr which simply
updates the doc string. Closes juju#225.
johnsca pushed a commit that referenced this issue Jun 5, 2018
* Convert seconds to nanoseconds for juju.unit.run

The juju.unit.run docstring does not specify what units the timeout
value should be in. This led to issue #225. Having looked into it,
juju is expecting it to be in nanoseconds. I don't think
nanoseconds is particularly intuitive so I have updated the function
to take the timeout in seconds and convert it internally to
nanoseconds.

I appreciate this is a breaking change for anyone currently specifying
the timeout in nanoseconds so I would quite understand if this change
is nack'd in which case I will submit a subsequent pr which simply
updates the doc string. Closes #225.

* Ensure the timeout is an integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants