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

fixes #11987 - fix checking exit code of deployment scripts #2760

Closed
wants to merge 3 commits into from

Conversation

machalekj
Copy link
Contributor

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.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 91e579b must be in the format fixes #redmine_number - brief description.

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
Copy link
Contributor

Also adds deleting hosts which deployment
fails because of non zero exit code.

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.

@machalekj
Copy link
Contributor Author

@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?

@machalekj machalekj changed the title Fix bash command masking deployment script exit code fixes #11987 - fix checking exit code of deployment scripts Sep 29, 2015
@domcleal
Copy link
Contributor

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 Setting[:example].

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 91e579b must be in the format fixes #redmine_number - brief description.
  • 7adb469 must be in the format fixes #redmine_number - brief description.

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

@machalekj
Copy link
Contributor Author

@domcleal Hi, I implemented deleting hosts as optional with default value keeping current state. Hope this can be easily used.

@domcleal
Copy link
Contributor

[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."
Copy link
Member

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.

@dLobatog
Copy link
Member

dLobatog commented Oct 2, 2015

@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!

@machalekj
Copy link
Contributor Author

@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"))
Copy link
Contributor

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.

@domcleal
Copy link
Contributor

[test]

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • ae3afa2 must be in the format fixes #redmine_number - brief description.

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
Copy link
Contributor

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]

@machalekj
Copy link
Contributor Author

Thanks, I just fixed it by removing the merge. That's what I indeed intended.

@machalekj
Copy link
Contributor Author

@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.

@domcleal
Copy link
Contributor

[test]

@machalekj
Copy link
Contributor Author

@domcleal Hm, it's still testing old revision (b6b977a), instead of commit 52d67e3. Should I make some 'dummy' commit/rebuild just to enforce Jenkinks to use new correct revision?

@domcleal
Copy link
Contributor

You'll have to ignore that, it's not really accurate since it's reporting the commit on develop that it's testing rather than the commit from your branch - it merges your branch in during the test. It looks like the test I wrote fails on MySQL. I'll have a closer look!

attributes57:
name: clean_up_failed_deployment
category: Setting::Provisioning
default: false
Copy link
Contributor

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.

machalekj and others added 3 commits October 14, 2015 07:52
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).
@machalekj
Copy link
Contributor Author

@domcleal ok, I fixed the fixture (and updated the its default value). Please test it.

@domcleal
Copy link
Contributor

[test]

@dLobatog
Copy link
Member

I'll squash this on merge. Thanks @machalekj @domcleal !

@dLobatog
Copy link
Member

Merged as c919008, thanks again @machalekj @domcleal !

@dLobatog dLobatog closed this Oct 16, 2015
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.

4 participants