-
Notifications
You must be signed in to change notification settings - Fork 47
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
Fixing stdout lookup for Juju 2.7 #301
base: master
Are you sure you want to change the base?
Conversation
It was failling because when the code is 1, it didn't returned any Stdout, therefore it fails because of the missing key.
Codecov Report
@@ Coverage Diff @@
## master #301 +/- ##
=========================================
Coverage ? 85.21%
=========================================
Files ? 26
Lines ? 1650
Branches ? 0
=========================================
Hits ? 1406
Misses ? 244
Partials ? 0
Continue to review full report at Codecov.
|
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
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.
There are multiple instances of ['Stdout'] calls. We need to be more comprehensive.
And the core issue is this is no longer true:
:returns: action.data['results'] {'Code': '', 'Stderr': '', 'Stdout': ''}
It might make sense to have a helper function which handles 2.6 and 2.7 action.data.
It could be written to take into account 'Code' and 'Stderr' but it doesn't seem a wrong approach. The change that I detected is that when you do a pgrep or pidof for a service that is stopped, Juju 2.7 doesn't return any 'Stdout' or 'Stderr' because the pgrep or pidof don't return anything, they just exit with error code 1. The change that I'm proposing just handles errors better, by having a default when the key doesn't exist. |
I'd agree with this.
Yes, it requires a more defensive strategy for all of the results.
Based on this, I'd say that the async with run_in_model(model_name) as model:
unit = get_unit_from_name(unit_name, model)
action = await unit.run(command, timeout=timeout)
if action.data.get('results'):
return action.data.get('results')
else:
return {} to: if action.data.get('results'):
res = action.data['results']
return {'Code': res.get('Code', ''), 'Stdout': ...}
else:
return {} BUT, I'm really suspicious of the |
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 the fix
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.
Actually, I just realised this has been superseded, a fix has landed to async_run_on_unit for this issue
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 makes sense to me.
Added stale label as nothing has happened in over 2 years; PR may be closed if no further work is needed. |
…ue/298 Fail early when no units found for external port creation
It was failling because when the code is 1, it didn't returned
any Stdout, therefore it fails because of the missing key.