Class: OsCtld::ContainerControl::Commands::Mount::Frontend
- Defined in:
- lib/osctld/container_control/commands/mount.rb
Constant Summary
Constants inherited from Frontend
Instance Attribute Summary
Attributes inherited from Frontend
Instance Method Summary collapse
Methods inherited from Frontend
#cleanup_runner_cgroup, #exec_runner, #fork_runner, #initialize, #reap_failed_runner, #runner_result, #write_runner_failure
Constructor Details
This class inherits a constructor from OsCtld::ContainerControl::Frontend
Instance Method Details
#error_result(message) ⇒ Object (protected)
70 71 72 |
# File 'lib/osctld/container_control/commands/mount.rb', line 70 def error_result() ContainerControl::Result.new(false, message:) end |
#execute(opts) ⇒ true
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/osctld/container_control/commands/mount.rb', line 17 def execute(opts) lease = nil expected_run_conf = ct.inclusively { ct.run_conf } if expected_run_conf && expected_run_conf.init_pid.nil? ct.refresh_init_pid(expected_run_conf:) end ret = nil ct.inclusively do run_conf = ct.run_conf unless ct.running? && run_conf && run_conf.init_pid ret = error_result('container not running or init PID not set') next end lease = run_conf.acquire_init_lease unless lease ret = error_result('container init identity is not available') next end identity = lease.identity identity.authenticate!(cgroup_path: ct.cgroup_path) unless ct.run_conf.equal?(run_conf) && run_conf.init_pid == identity.pid ret = error_result('container run changed while resolving init identity') next end ret = { args: [opts.merge( init_identity: identity, cgroup_path: ct.cgroup_path, root_host_uid: ct.root_host_uid, root_host_gid: ct.root_host_gid )], keep_fds: identity.files, switch_to_system: false } end return ret if ret.is_a?(ContainerControl::Result) ret = fork_runner(**ret) ret.ok? || ret rescue SystemCallError, IOError, Container::RunConfiguration::LifecycleError => e error_result("unable to resolve container init identity: #{e.}") ensure lease&.close end |