Class: OsCtld::Container::Adaptor::CGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/osctld/container/adaptors/cgroup.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #ct

Instance Method Summary collapse

Methods inherited from Base

#initialize, #log_type, register

Constructor Details

This class inherits a constructor from OsCtld::Container::Adaptor::Base

Instance Method Details

#adaptObject



7
8
9
10
# File 'lib/osctld/container/adaptors/cgroup.rb', line 7

def adapt
  send(:"to_cgroup_v#{CGroup.version}")
  config
end

#systemd_distrosObject (protected)



38
39
40
# File 'lib/osctld/container/adaptors/cgroup.rb', line 38

def systemd_distros
  %w[almalinux arch centos debian fedora gentoo opensuse rocky ubuntu]
end

#systemd_optObject (protected)



34
35
36
# File 'lib/osctld/container/adaptors/cgroup.rb', line 34

def systemd_opt
  'systemd.unified_cgroup_hierarchy=0'
end

#to_cgroup_v1Object (protected)



14
15
16
17
18
19
20
21
22
23
# File 'lib/osctld/container/adaptors/cgroup.rb', line 14

def to_cgroup_v1
  return unless systemd_distros.include?(config['distribution'])

  config['init_cmd'] ||= ['/sbin/init']

  return if config['init_cmd'].include?(systemd_opt)

  log(:info, "Adding option #{systemd_opt} to init command")
  config['init_cmd'] << systemd_opt
end

#to_cgroup_v2Object (protected)



25
26
27
28
29
30
31
32
# File 'lib/osctld/container/adaptors/cgroup.rb', line 25

def to_cgroup_v2
  if systemd_distros.include?(config['distribution']) \
     && config['init_cmd'] \
     && config['init_cmd'].include?(systemd_opt)
    log(:info, "Removing option #{systemd_opt} from init command")
    config['init_cmd'].delete(systemd_opt)
  end
end