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

portage: Add support for --quiet-build and --quiet-fail #36452

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 29 additions & 1 deletion lib/ansible/modules/packaging/os/portage.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@
default: None
version_added: 2.3

quietbuild:
description:
- Redirect all build output to logs alone, and do not display it
- on stdout (--quiet-build)
required: false
default: False
choices: [ "yes", "no" ]
version_added: 2.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid, this won't make it in 2.6, because it's a bugfix release and the next one accepting features should be 2.7.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I can increase to 2.7, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems I may need to stick with 2.6 or something since CI is failing on 2.7.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be allowed to merge this branch when devel will start accepting features for 2.7. It's feature-freeze now. I'm going to guess that might happen once we get 2.6 branch separated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so 2.7 is correct, and I should just ignore the CI failure till next iteration.


quietfail:
description:
- Suppresses display of the build log on stdout (--quiet-fail)
- Only the die message and the path of the build log will be
- displayed on stdout.
required: false
default: False
choices: [ "yes", "no" ]
version_added: 2.6

requirements: [ gentoolkit ]
author:
- "William L Thomson Jr (@wltjr)"
Expand Down Expand Up @@ -320,6 +339,8 @@ def emerge_packages(module, packages):
'usepkgonly': '--usepkgonly',
'usepkg': '--usepkg',
'keepgoing': '--keep-going',
'quietbuild': '--quiet-build',
'quietfail': '--quiet-fail',
}
for flag, arg in emerge_flags.items():
if p[flag]:
Expand Down Expand Up @@ -490,9 +511,16 @@ def main():
keepgoing=dict(default=False, type='bool'),
jobs=dict(default=None, type='int'),
loadavg=dict(default=None, type='float'),
quietbuild=dict(default=False, type='bool'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about default=None? Otherwise it might override EMERGE_DEFAULT_OPTS values, which would be weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just being consistent. There are only 3 options that are set to None, all others False. Once merged I plan to switch some of these defaults to True. I feel like ansible should always default to quiet across the board, unless overridden.

But you make a good point. It maybe worth dropping all False to None. I think its that way based on the code. Not familiar with conditionals, but I guess None is the same as False? If that is the case then its moot. Either way I believe it only adds these if set to True. If set to False they do not show up. Or should not per how I read the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, None is not False (yes, it's valid Python statement bwt 😃)

Basically, None value is casted to False. But if var check is using a built-in pythonic protocol for casting bool value out of expression given.
So it does bool(val), which internally does var.__bool__() call. And then it uses whatever this method returns for the if clause.

NoneType (type(None)) is always falsy, [] is falsy, 0 is falsy, {} is falsy. 1 is truthy, [0] is truthy, {'k': 'v'} is truly.
The end-user can implement whatever logic they want in their classes for casting their instances into boolean.

That is why it's important to check for val is None or val is not None, sometimes you'll even want val is False. None is often used for default arg value for functions/methods, which then do is None check to ensure the user didn't override them (cause you cannot put mutable defaults in function definitions).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok based on that it seems the conditional to add any flag requires it to be set to True, per the code.

    for flag, arg in emerge_flags.items():
        if p[flag]:
             args.append(arg)

If I set it to None it would not be handled correctly. Or maybe ignored since its not True. Pretty sure that will only evaluate to true, if set to True.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will append flags with True, 1, 1.0, y, n (any string) values. And will skip 0, 0.0, None, False, [], {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So having None vs False is moot for that stuff. Seems only remaining change is the version. I will correct and break CI

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We'll probably need to consider redesigning defaults separately. Out of scope now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module could likely use a few improvements. I am open to such. Not sure how many are using the module. It does not seem very popular, or its meeting alls needs/expectations no clue. Then again not sure many are interested in Gentoo these days...

quietfail=dict(default=False, type='bool'),
),
required_one_of=[['package', 'sync', 'depclean']],
mutually_exclusive=[['nodeps', 'onlydeps'], ['quiet', 'verbose']],
mutually_exclusive=[
['nodeps', 'onlydeps'],
['quiet', 'verbose'],
['quietbuild', 'verbose'],
['quietfail', 'verbose'],
],
supports_check_mode=True,
)

Expand Down