Class: OsCtld::ContainerControl::Commands::Unmount::Runner

Inherits:
Runner
  • Object
show all
Includes:
OsCtl::Lib::Utils::Log
Defined in:
lib/osctld/container_control/commands/unmount.rb

Instance Attribute Summary

Attributes inherited from Runner

#ctid, #log_file, #lxc_home, #stderr, #stdin, #stdout, #user_home

Instance Method Summary collapse

Methods inherited from Runner

#error, #initialize, #lxc_ct, #ok, #setup_exec_env, #setup_exec_run_env, #system_path

Constructor Details

This class inherits a constructor from OsCtld::ContainerControl::Runner

Instance Method Details

#execute(mountpoint) ⇒ Object

Parameters:

  • mountpoint (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/osctld/container_control/commands/unmount.rb', line 22

def execute(mountpoint)
  ct = lxc_ct

  pid = ct.attach do
    next unless Dir.exist?(mountpoint)

    begin
      sys = OsCtl::Lib::Sys.new
      sys.unmount(mountpoint)
    rescue Errno::EINVAL
      # Not mounted, pass
    end
  end

  Process.wait(pid)

  if $?.exitstatus == 0
    ok
  else
    log(:warn, ct, "Unmounter exited with #{$?.exitstatus}")
    error('unmount failed')
  end
end