Class: Kontena::Callbacks::ClearCurrentMasterAfterTerminate

Inherits:
Kontena::Callback show all
Defined in:
lib/kontena/callbacks/master/01_clear_current_master_after_terminate.rb

Instance Attribute Summary

Attributes inherited from Kontena::Callback

#command

Instance Method Summary collapse

Methods inherited from Kontena::Callback

callbacks, #initialize, matches_commands, run_callbacks

Constructor Details

This class inherits a constructor from Kontena::Callback

Instance Method Details

#afterObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/kontena/callbacks/master/01_clear_current_master_after_terminate.rb', line 7

def after
  extend Kontena::Cli::Common
  return unless command.exit_code == 0
  return unless config.current_master

  logger.debug { "Removing current master from config" }
  config.servers.delete_at(config.find_server_index(config.current_master.name))
  config.current_server = nil
  config.write
end