Fatal log not killing chef-client run

I want to run a simple check at the beginning of all of our chef-client runs to ensure that our nodes are bootstrapped with a chef environment. It is pretty simple and looks like this:

if node.environment() == "_default"
    log "chef-environment-check" do
        message "Chef environment must be set on all nodes. Please re-bootstrap your node including the --environment parameter."
        level :fatal
    end
end

But when I try to run chef client on a node with no environment set, the run dies at a later block in that very same recipe, (at a block which is also a consequence of having no environment set, but which is also less descriptive).

How / why would it be getting past a fatal log resource??

fatal is just a log level like anything else (one level above error). It doesn’t have anything to do with stopping the run. What you probably want is this:

if node.chef_environment == "_default"
  raise "some message"
end

Ahhh that makes sense. Perfect, thank you!