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

Return the rc's based on config varible distill_on_error #568

Merged
merged 3 commits into from
May 3, 2018

Conversation

samvarankashyap
Copy link
Collaborator

Returns 0 even if one target provision is successfull when
distill_on_error = True
Returns rc > 0 even if one target provision fails when
distill_on_error = False

Copy link
Contributor

@p3ck p3ck left a comment

Choose a reason for hiding this comment

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

LGTM

pass

except Exception as e:
self.ctx.log_state('Error: {0}'.format(e))
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks you! ^^

Copy link
Contributor

Choose a reason for hiding this comment

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

I added this in my PR already, however...that's going to cause a conflict there.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -91,12 +89,17 @@ def _handle_results(ctx, results, return_code):

# PRINT OUTPUT RESULTS HERE
ctx.log_state(output)
distil_on_error = json.loads(lpcli.get_cfg('lp',
Copy link
Contributor

Choose a reason for hiding this comment

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

distill has two l's, probably ought to fix that so it is a proper spelling.

@adl-bot
Copy link

adl-bot commented May 2, 2018

Copy link
Contributor

@herlo herlo left a comment

Choose a reason for hiding this comment

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

I think there might have been some misunderstanding here. The 'distill_on_error' flag in linchpin.constants is specific for allowing the distiller to push out data to the linchpin.distilled file even if the return_code is not 0.

However, I think the purpose of this fix is to have a separate flag that allows a return_code of 0 if any target is successful. Thus, having a flag called 'return_success_from_targets' or some such would be more applicable here.

use_actual_rcs = True
if use_actual_rcs:
if use_actual_rcs and not(distill_on_error):
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you do have 'use_actual_rcs', but that should come from the linchpin.constants (or overridden by the linchpin.conf) and set to a default. Not hard coded here. Additionally, distill_on_error is a separate function and should occur if and only if that flag is set, it shouldn't be dependent on whether 'use_actual_rcs' is set. This would mean that one is dependent on the other to be true for certain conditions.

@herlo herlo changed the title Return the rc's based on config varible distil_on_error Return the rc's based on config varible distill_on_error May 2, 2018
Returns 0 even if one target provision is successfull when
distill_on_error = True
Returns rc > 0 even if one target provision fails when
distill_on_error = False
@samvarankashyap
Copy link
Collaborator Author

@herlo changes made!

@adl-bot
Copy link

adl-bot commented May 3, 2018

@adl-bot
Copy link

adl-bot commented May 3, 2018

@@ -91,10 +89,12 @@ def _handle_results(ctx, results, return_code):

# PRINT OUTPUT RESULTS HERE
ctx.log_state(output)
use_actual_rcs = json.loads(lpcli.get_cfg('lp',
'use_actual_rcs').lower())
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are using True/False, the proper use of this is to use ast.literaleval(value.title()), https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/cli/__init__.py#L323 is a good example.

@@ -26,6 +26,7 @@ external_providers_path = %(default_config_path)s/linchpin-x
use_rundb_for_actions = False
distill_data = False
distill_on_error = False
use_actual_rcs = False
Copy link
Contributor

Choose a reason for hiding this comment

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

@samvarankashyap
Copy link
Collaborator Author

@herlo: changes made.

@adl-bot
Copy link

adl-bot commented May 3, 2018

Copy link
Contributor

@herlo herlo left a comment

Choose a reason for hiding this comment

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

See comments.

# if enabled True, even if one target provision is successfull linchpin
# returns exit code zero else returns the sum of all the return codes
use_actual_rcs = False

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you overriding what is in linchpin.constants here? It appears not, so it would be prudent to just comment it out.

@@ -91,10 +90,12 @@ def _handle_results(ctx, results, return_code):

# PRINT OUTPUT RESULTS HERE
ctx.log_state(output)
use_actual_rcs = ast.literal_eval(lpcli.get_cfg('lp',
'use_actual_rcs'))

Copy link
Contributor

Choose a reason for hiding this comment

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

as a rule, you should add the .title() function to the item to get the 'True' or 'False' state before it's evaluated by the ast.literal_eval method. Something like this would be appropriate.

uar = lpcli.get_cfg('lp', 'use_actual_rcs'))
use_actual_rcs = ast.literal_eval(uar.title())

In this way, if the value is 'true', or 'false', or any combination thereof, the value will get converted to proper title case, and return the proper boolean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay , I was not aware of the rule . I tried ast.literal_eval(lpcli.get_cfg('lp','use_actual_rcs')) and it worked . Will make the change.

Copy link
Contributor

@herlo herlo left a comment

Choose a reason for hiding this comment

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

LGTM

@samvarankashyap
Copy link
Collaborator Author

[merge]

@adl-bot adl-bot merged commit 2761bc2 into CentOS-PaaS-SIG:develop May 3, 2018
@adl-bot
Copy link

adl-bot commented May 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants