-
Notifications
You must be signed in to change notification settings - Fork 70
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
Return the rc's based on config varible distill_on_error #568
Conversation
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
linchpin/cli/__init__.py
Outdated
pass | ||
|
||
except Exception as e: | ||
self.ctx.log_state('Error: {0}'.format(e)) |
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 you! ^^
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.
I added this in my PR already, however...that's going to cause a conflict there.
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.
linchpin/shell/__init__.py
Outdated
@@ -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', |
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.
distill has two l's, probably ought to fix that so it is a proper spelling.
1a2d77d
to
63eb2da
Compare
ci-linchpin-messageBus-trigger build #54: FAILURE: https://jenkins-continuous-infra.cloud.rhel8.upshift.engineering.redhat.com/job/ci-linchpin-messageBus-trigger/54/ |
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.
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.
linchpin/shell/__init__.py
Outdated
use_actual_rcs = True | ||
if use_actual_rcs: | ||
if use_actual_rcs and not(distill_on_error): |
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.
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.
680a0e9
to
b41fb39
Compare
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
b41fb39
to
55f8953
Compare
@herlo changes made! |
ci-linchpin-messageBus-trigger build #61: FAILURE: https://jenkins-continuous-infra.cloud.rhel8.upshift.engineering.redhat.com/job/ci-linchpin-messageBus-trigger/61/ |
ci-linchpin-messageBus-trigger build #62: SUCCESS: https://jenkins-continuous-infra.cloud.rhel8.upshift.engineering.redhat.com/job/ci-linchpin-messageBus-trigger/62/ |
linchpin/shell/__init__.py
Outdated
@@ -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()) |
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.
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 |
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 also needs a corresponding example and explanation in the https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/docs/source/examples/workspace/linchpin.conf
@herlo: changes made. |
ci-linchpin-messageBus-trigger build #69: SUCCESS: https://jenkins-continuous-infra.cloud.rhel8.upshift.engineering.redhat.com/job/ci-linchpin-messageBus-trigger/69/ |
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.
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 | ||
|
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 overriding what is in linchpin.constants here? It appears not, so it would be prudent to just comment it out.
linchpin/shell/__init__.py
Outdated
@@ -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')) | |||
|
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.
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.
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.
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.
13ac023
to
cc60cb0
Compare
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
[merge] |
ci-linchpin-messageBus-trigger build #71: FAILURE: https://jenkins-continuous-infra.cloud.rhel8.upshift.engineering.redhat.com/job/ci-linchpin-messageBus-trigger/71/ |
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