{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/3054","labels_url":"https://api.github.com/repos/chef/chef/issues/3054/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/3054/comments","events_url":"https://api.github.com/repos/chef/chef/issues/3054/events","html_url":"https://github.com/chef/chef/issues/3054","id":60607349,"number":3054,"title":"Chef 12.1 not allowing control of exit codes with exceptions","user":{"login":"carpnick","id":6966179,"avatar_url":"https://avatars.githubusercontent.com/u/6966179?v=3","gravatar_id":"","url":"https://api.github.com/users/carpnick","html_url":"https://github.com/carpnick","followers_url":"https://api.github.com/users/carpnick/followers","following_url":"https://api.github.com/users/carpnick/following{/other_user}","gists_url":"https://api.github.com/users/carpnick/gists{/gist_id}","starred_url":"https://api.github.com/users/carpnick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carpnick/subscriptions","organizations_url":"https://api.github.com/users/carpnick/orgs","repos_url":"https://api.github.com/users/carpnick/repos","events_url":"https://api.github.com/users/carpnick/events{/privacy}","received_events_url":"https://api.github.com/users/carpnick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-11T04:00:02Z","updated_at":"2015-03-12T22:15:35Z","closed_at":null,"body":"\r\n\r\nThis ruby block below in Chef 11.* makes chef-client exit with exit code of 250.  In Chef 12 it exits with  1.  The need from a user perspective, is we need to be able to signal a Continuous Delivery system with exit codes out of Chef.  We were depending directly on the exit code in this example, to wait for WinRM or SSH to start running chef again.  The exit code will let us know what action was performed in Chef.  Reboot, Chef run success, etc.\r\n```\r\nruby_block \"ExitNow\" do\r\n  block do\r\n     puts \"Stopping chef run for an immediate reboot\";       \r\n     exit 250;  \r\n  end\r\n  action :run\r\nend\r\n```\r\n\r\nLooks like Chef 11's implementation of [Converge](https://github.com/chef/chef/blob/11-stable/lib/chef/client.rb#L341) would raise the exception where in Chef 12 it [catches it](https://github.com/chef/chef/blob/12-stable/lib/chef/client.rb#L324) and returns it to the [run method] (https://github.com/chef/chef/blob/12-stable/lib/chef/client.rb#L448) and then [wraps it](https://github.com/chef/chef/blob/12-stable/lib/chef/client.rb#L461).\r\n\r\nI think the potential fix is inside the code where it is wrapping it:\r\n```\r\nif converge_error.class == SystemExit\r\n  raise\r\nend\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/78651695","html_url":"https://github.com/chef/chef/issues/3054#issuecomment-78651695","issue_url":"https://api.github.com/repos/chef/chef/issues/3054","id":78651695,"user":{"login":"carpnick","id":6966179,"avatar_url":"https://avatars.githubusercontent.com/u/6966179?v=3","gravatar_id":"","url":"https://api.github.com/users/carpnick","html_url":"https://github.com/carpnick","followers_url":"https://api.github.com/users/carpnick/followers","following_url":"https://api.github.com/users/carpnick/following{/other_user}","gists_url":"https://api.github.com/users/carpnick/gists{/gist_id}","starred_url":"https://api.github.com/users/carpnick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carpnick/subscriptions","organizations_url":"https://api.github.com/users/carpnick/orgs","repos_url":"https://api.github.com/users/carpnick/repos","events_url":"https://api.github.com/users/carpnick/events{/privacy}","received_events_url":"https://api.github.com/users/carpnick/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T22:15:34Z","updated_at":"2015-03-12T22:15:34Z","body":"Updating the reboot resource immediately solves our problem.  \r\n\r\nHowever, I can see other use cases where a user might want to exit chef mid chef-run and not only because of a reboot to signal another system.  Network unavailable, system out of space, etc.\r\n\r\nBasically - the question being asked here really, is how do I signal other systems outside of a chef-run the status of the chef run?  The easiest use case is to use exit codes.  Others involve reading the output of Chef and parsing.  But the latter options seems clunky and version dependent to me.\r\n"}}