-
Notifications
You must be signed in to change notification settings - Fork 231
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
Feature/fix crash on relup warning #559
Feature/fix crash on relup warning #559
Conversation
src/rlx_prv_relup.erl
Outdated
@@ -145,7 +155,14 @@ make_upfrom_script(State, Release, UpFrom) -> | |||
"relup successfully created!"), | |||
{ok, State}; | |||
{ok,_, Module,Warnings} -> | |||
?RLX_ERROR({relup_script_generation_warn, Module, Warnings}); | |||
case WarningsAsErrors of |
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 would suggest sending the warnings_as_errors option to systools:make_relup/4 instead of handling it here. Else, the relup will be generated anyway, even if this option is set.
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 did as you suggested, yet i wasn't expecting for systools:make_relup
to return simply error
when i give it the warnings_as_errors
option instead of {error,Module,Errors}
, intended behaviour?
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.
oh... that's unexpected indeed... this might be a bug. I will discuss it in the team if we should do anything about it. I guess you will have to decide for yourself what to do in the meantime, but a possible solution would be to do as your first implementation, but backup any old relup that might exists and restore it if it has be erroneously overwritten (or just delete the faulty generated relup if there was no file there already). Sorry for the hassle!!
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've tried this and apparently no relup is generated in this case so i guess aside from an unclear message there are no major side effects
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.
Do you mean that systools
does not write the relup if there are warnings, even if warnings_as_errors
is not set?
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.
warnings_as_errors
is not set: relup is generated,systools:make_relup
returns{ok,_, Module,Warnings}
warnings are emittedwarnings_as_errors
is set: relup is not generated,systools:make_relup
returnserror
atom, in this case i would expect to receive{error,Module,Errors}
, since no relup is generated there is no danger of overwriting a previous one
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.
Ok, thanks - then we're talking about the same :) I need to look into the fact that systools:make_relup
returns the error
atom when warnings_as_errors
is set - if it is a bug or not. Haven't had the time to do so yet. What I meant above was that maybe you need to do a workaround in the meantime - i.e. do as your original solution (when you didn't give the warnings_as_error
option to systools, but handled it all in relx), but then add the cleanup if the relup is erroneously written. Unless you're happy with the error
atom until further notice, that is...
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.
FYI: I have written ticket for this issue (the error atom) to be considered at our next sprint planning in the beginning of February.
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.
ah sorry, i see what you mean, that's a good idea, i've updated the pr accordingly, so now relx deletes the relup file if the `warnings_as_errors' option is set and there are warnings.
src/rlx_prv_relup.erl
Outdated
"this case"; | ||
format_error({relup_script_generation_warn, _Module, Warnings}) -> | ||
["Warnings generating relup \n", | ||
rlx_util:indent(2), io_lib:format("~p", [Warnings])]; |
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.
Could use Module:format_warning/1 here instead of io_lib:format
af22f06
to
90d9030
Compare
src/rlx_prv_relup.erl
Outdated
"this case"; | ||
format_error({relup_script_generation_warn, Module, Warnings}) -> | ||
["Warnings generating relup \n", | ||
rlx_util:indent(2), Module:format_warning("~p", [Warnings])]; |
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.
Module:format_warning
takes only one argument - so it should be Module:format_warning(Warnings)
.
90d9030
to
db5e4f1
Compare
Obtained from command line and saved in the state to be used on situations where we want to error out on warnings explicitly.
db5e4f1
to
6ddc7e0
Compare
src/rlx_prv_relup.erl
Outdated
{error,Module,Errors} -> | ||
ec_cmd_log:warn(rlx_state:log(State), | ||
"error with warnings"), |
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.
What do you mean by "error with warnings"?
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.
just forgotten debug messages, i've dropped them
I think this correction looks good now! Two somehow related comments though:
Anyway, that was just some thoughts - no harm done, just some superfluous code... |
Make use of warnings_on_errors option to exit with error or proceed with just a warning.
6ddc7e0
to
59ace4d
Compare
yeah, my guess is that the |
@tsloughter this is ready for review |
Looks good, but I'm a bit confused about the systools |
This is the first step, the next one would be extracting the
Yes, this is an issue we found in |
@lrascao @tsloughter A correction for this will be added in OTP-19.3, mid March. |
Addresses #554