-
Notifications
You must be signed in to change notification settings - Fork 987
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
fixes #11987 - fix checking exit code of deployment scripts #2760
Conversation
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
My only hesitation about doing this is that it might make it harder to debug what's gone on, since the VM will get destroyed too. |
@domcleal: The original exception in this case was: "Provision script had a non zero exit, removing instance" - but removing wasn't done. In my case removing badly deployed instances would make it easier to re-run the failed deployment via API. What about making this deletion optional? |
Ah interesting, that makes sense then. Optional would be great if you'd be interested in doing it - perhaps a global setting would be enough for debugging purposes - a new entry under app/models/setting/provisioning.rb can be easily accessed as |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
@domcleal Hi, I implemented deleting hosts as optional with default value keeping current state. Hope this can be easily used. |
[test] |
@@ -82,6 +82,10 @@ def setSSHProvision | |||
Host.find(id).built | |||
respond_to?(:initialize_puppetca,true) && initialize_puppetca && delAutosign if puppetca? | |||
else | |||
if Setting[:clean_up_failed_deployment] | |||
logger.info "Deleting host #{name} because of non zero exit code of deployment script." |
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.
Nitpick, if you could include the name of the script that'd help users when they debug what's going on.
@machalekj Nice fix, 👍 from my side. Could you write a test to make sure this feature still works in the future? It's already mostly untested and changes could break it without us noticing as it is right now. Thank you! |
@elobato Hi, I am sorry I won't be able (at least without some hints). I am not yet familiar with Rails and simulating SSH service is a bit too much to start learning it. Or is there any test that creates real host which I could use as an example? |
if Setting[:clean_up_failed_deployment] | ||
logger.info "Deleting host #{name} because of non zero exit code of deployment script." | ||
Host.find(id).destroy | ||
end | ||
raise ::Foreman::Exception.new(N_("Provision script had a non zero exit, removing instance")) |
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.
The "removing instance" comment here is peculiar, I wonder if it changed in the past. Could you remove that part? We should to rely on the log message you added to say whether it did, or didn't remove the VM.
[test] |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project. More guidelines are available on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
Having the merge commit is probably what the bot's complaining about - but I can probably remove that on merge if you're having trouble with it, don't worry. [test] |
Thanks, I just fixed it by removing the merge. That's what I indeed intended. |
@domcleal Can you please re-run tests? The revision which was actually used for test was wrong one (without my patch), which I immediately replaced by correct one. |
[test] |
You'll have to ignore that, it's not really accurate since it's reporting the commit on |
attributes57: | ||
name: clean_up_failed_deployment | ||
category: Setting::Provisioning | ||
default: 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.
I think I remember now. This should have been quoted, "false"
for it to pass on MySQL.
This commit fixes checking exit codes returned from provisioning templates, which were ignored because of sending results through pipe to command tee. Also adds optional host deleting if deployment fails because of non zero exit code. This can be configured by setting clean_up_failed_deployment (default true).
@domcleal ok, I fixed the fixture (and updated the its default value). Please test it. |
[test] |
I'll squash this on merge. Thanks @machalekj @domcleal ! |
Merged as c919008, thanks again @machalekj @domcleal ! |
This commit fixes checking exit codes returned from provisioning templates, which were ignored
because of sending results through pipe to command tee. Also adds deleting hosts which deployment
fails because of non zero exit code.