Skip to content

Commit

Permalink
Report features to master before reporting errors
Browse files Browse the repository at this point in the history
As soon as we report an error to the master, it kills our process.
This in turn prevents us from reporting the features loaded before
the error and getting restarted when those change.
https://github.com/burke/zeus/blob/0cd1c4fad7c214a4a842665922803b7e2bac3347/go/processtree/slavenode.go#L223-L226

Instead, we want to report features before reporting the error but ensure
that we eventually report the error even if feature reporting fails.
  • Loading branch information
andrew-stripe committed Jul 8, 2016
1 parent 0cd1c4f commit 9657f29
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions rubygem/lib/zeus.rb
Expand Up @@ -189,23 +189,25 @@ def report_error_to_master(local, error)

def run_action(socket, identifier, feature_pipe_w)
# Now we run the action and report its success/fail status to the master.
loaded = false
features, err = Zeus::LoadTracking.features_loaded_by do
plan.after_fork unless identifier == :boot
plan.send(identifier)
loaded = true
socket.write "R:OK\0"
end

# the master wants to know about the files that running the
# action caused us to load. If we received an error, report them
# syncronously and along with the error. Otherwise, report them
# in a new thread and start listening for commands.
if err
report_error_to_master(socket, err)
notify_features(feature_pipe_w, features) unless loaded
feature_pipe_w.close
# If we received an error, report features to the master syncronously.
# We need to do this before reporting the error to the master
# otherwise it will kill us before we can report features.
begin
notify_features(feature_pipe_w, features)
feature_pipe_w.close
ensure
report_error_to_master(socket, err)
end
else
# If we booted successfully, report features in a new thread
# so we can immediately begin listening for commands.
socket.write "R:OK\0"
Thread.new { notify_features(feature_pipe_w, features) }
end
end
Expand Down

0 comments on commit 9657f29

Please sign in to comment.