Class: OsCtld::UserControl::Commands::CtPostStop
- Inherits:
-
Base
- Object
- Commands::Base
- Base
- OsCtld::UserControl::Commands::CtPostStop
- Includes:
- OsCtl::Lib::Utils::Exception, OsCtl::Lib::Utils::Log
- Defined in:
- lib/osctld/user_control/commands/ct_post_stop.rb
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Commands::Base
#client, #client_handler, #id, #opts
Instance Method Summary collapse
Methods inherited from Base
handle, #initialize, #owns_ct?, run
Methods inherited from Commands::Base
#base_execute, #call_cmd, #call_cmd!, #error, #error!, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!
Constructor Details
This class inherits a constructor from OsCtld::UserControl::Commands::Base
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/osctld/user_control/commands/ct_post_stop.rb', line 13 def execute ct = DB::Containers.find(opts[:id], opts[:pool]) return error('container not found') unless ct return error('access denied') unless owns_ct?(ct) if AppArmor.enabled? # Unload AppArmor profile and destroy namespace ct.apparmor.destroy_namespace ct.apparmor.unload_profile end if opts[:target] == 'reboot' log(:info, ct, 'Reboot requested') ct.run_conf.request_reboot end BpfFs.remove_ct(ct.pool.name, ct.id) run_conf = ct.run_conf ct.stopped(run_conf) # User-defined hook begin Hook.run(ct, :post_stop) ensure # Direct lxc-start has no tty0 wrapper to trigger exit cleanup. Use the # same handler, with exact run identity and once-only ownership, instead # of fulfilling the stop promise before cleanup has actually finished. if run_conf && !Console.handles_run?(ct, run_conf) Container::StopHandler.schedule(ct, run_conf) end end ok rescue HookFailed => e log(:warn, ct, 'Error during post-stop hook') log(:warn, ct, "#{e.class}: #{e.}") log(:warn, ct, denixstorify(e.backtrace).join("\n")) error(e.) end |