Clean-up old systemd prep and allow machinctl to grow
The machinectl cache is currently set image to 16G by default. If multiple container images are imported into the cache this may be too small by default. This change sets the cache to "64G" by default allowing the cache more room to grow by. This change also disables the quota system once the limit has been set The option `lxc_host_machine_quota_disabled` has been added to disable or enable the quota system as needed. This is done after the default limit has been set so an adequately sized sparce file can be created should it not already exist. > More documentation can be seen here [0] with regard to the set-limit option. Because we support both modern and older systemd, the cache prep tasks for old systemd have been updated so that deployers using earlier versions of systemd can benefit from the ability to grow an existing cache via playbook run. [0] https://www.freedesktop.org/software/systemd/man/machinectl.html#set-limit%20%5BNAME%5D%20BYTES Closes-Bug: #1745361 Change-Id: I85fefc6ce186bb6808ac37a9ea79a50e29671115 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
5085d45d7b
commit
f179f21a66
@ -29,7 +29,10 @@ lxc_architecture_mapping:
|
|||||||
armv7l: armhf
|
armv7l: armhf
|
||||||
|
|
||||||
# Set the volume size in gigabytes for the machine image caches.
|
# Set the volume size in gigabytes for the machine image caches.
|
||||||
lxc_host_machine_volume_size: 16
|
lxc_host_machine_volume_size: "64G"
|
||||||
|
|
||||||
|
# Disable the machinctl quota system.
|
||||||
|
lxc_host_machine_quota_disabled: true
|
||||||
|
|
||||||
# DefaultTasksMax systemd value. It's not recommended to change this value as it
|
# DefaultTasksMax systemd value. It's not recommended to change this value as it
|
||||||
# could prevent new processes from starting on busy containers.
|
# could prevent new processes from starting on busy containers.
|
||||||
|
@ -37,6 +37,13 @@
|
|||||||
name: "systemd-machined.service"
|
name: "systemd-machined.service"
|
||||||
state: "restarted"
|
state: "restarted"
|
||||||
|
|
||||||
|
- name: Start machines mount
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
name: "var-lib-machines.mount"
|
||||||
|
enabled: "yes"
|
||||||
|
state: "started"
|
||||||
|
|
||||||
- name: Restart irqbalance
|
- name: Restart irqbalance
|
||||||
service:
|
service:
|
||||||
name: "irqbalance"
|
name: "irqbalance"
|
||||||
|
20
releasenotes/notes/set-limit-disabled-25998f1f12987c12.yaml
Normal file
20
releasenotes/notes/set-limit-disabled-25998f1f12987c12.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- The variable ``lxc_host_machine_volume_size`` now accepts any valid size
|
||||||
|
modifier acceptable by ``truncate -s`` and ``machinectl set-limit``.
|
||||||
|
prior to this change the option assumed an integer was set for some value
|
||||||
|
in gigabytes. All acceptable values can be seen within the
|
||||||
|
`documentation for machinectl <https://www.freedesktop.org/software/systemd/man/machinectl.html#set-limit%20%5BNAME%5D%20BYTES>`_
|
||||||
|
features:
|
||||||
|
- An option to disable the ``machinectl`` quota system has been added. The
|
||||||
|
variable ``lxc_host_machine_quota_disabled`` is a Boolean with a default of
|
||||||
|
**true**. When this option is set to **true** it will disable the
|
||||||
|
``machinectl`` quota system.
|
||||||
|
other:
|
||||||
|
- The variable ``lxc_host_machine_volume_size`` is used to set the size of
|
||||||
|
the default sparse file as well as define a limit within the ``machinectl``
|
||||||
|
quota system. When the ``machinectl`` quota system is enabled deployers
|
||||||
|
should appropriately set this value to the size of the container volume,
|
||||||
|
even when not using a sparse file.
|
||||||
|
- The container image cache within machinectl has been set to "64G" by
|
||||||
|
default.
|
@ -15,6 +15,16 @@
|
|||||||
|
|
||||||
# NOTE(cloudnull): When modern SystemD is running everywhere this can be
|
# NOTE(cloudnull): When modern SystemD is running everywhere this can be
|
||||||
# collapsed back into the base preparation task file.
|
# collapsed back into the base preparation task file.
|
||||||
|
- name: Set volume size
|
||||||
|
shell: machinectl set-limit {{ lxc_host_machine_volume_size }}
|
||||||
|
changed_when: false
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
|
- name: Disable the machinectl quota system
|
||||||
|
command: "btrfs quota {{ lxc_host_machine_quota_disabled | bool | ternary('disable', 'enable') }} /var/lib/machines"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Remove old image cache
|
- name: Remove old image cache
|
||||||
command: "machinectl remove {{ lxc_container_base_name }}"
|
command: "machinectl remove {{ lxc_container_base_name }}"
|
||||||
register: cache_refresh
|
register: cache_refresh
|
||||||
@ -23,14 +33,6 @@
|
|||||||
when:
|
when:
|
||||||
- lxc_image_cache_refresh | bool
|
- lxc_image_cache_refresh | bool
|
||||||
|
|
||||||
# NOTE(cloudnull): When modern SystemD is running everywhere this can be
|
|
||||||
# collapsed back into the base preparation task file.
|
|
||||||
- name: Set volume size
|
|
||||||
shell: machinectl set-limit {{ lxc_host_machine_volume_size }}G
|
|
||||||
changed_when: false
|
|
||||||
args:
|
|
||||||
executable: /bin/bash
|
|
||||||
|
|
||||||
- name: Ensure image has been pre-staged
|
- name: Ensure image has been pre-staged
|
||||||
async_status:
|
async_status:
|
||||||
jid: "{{ prestage_image.ansible_job_id }}"
|
jid: "{{ prestage_image.ansible_job_id }}"
|
||||||
|
@ -13,98 +13,92 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
# NOTE(cloudnull): This is only used when running SystemD <= 219
|
# NOTE(cloudnull): This is only used when running SystemD <= 219
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
# In later versions of SystemD this is automatically done for us
|
# In later versions of SystemD this is automatically done for us
|
||||||
# by the machinectl cli on first run.
|
# by the machinectl cli on first run. To ensure we're handling the
|
||||||
- name: Create volume
|
# case of a mount point being just offline, we first try and start
|
||||||
|
# the systemd mount unit and then check for the mount points existance.
|
||||||
|
- name: Check machinectl mount point
|
||||||
shell: |
|
shell: |
|
||||||
if [[ "$(ls -lh /var/lib/machines.raw | awk '{print $5}')" != "{{ lxc_host_machine_volume_size }}.0G" ]]; then
|
mount -a || true
|
||||||
if [[ ! -f "/var/lib/machines.raw" ]]; then
|
systemctl start var-lib-machines.mount || true
|
||||||
truncate -s {{ lxc_host_machine_volume_size }}G /var/lib/machines.raw
|
sleep 1
|
||||||
exit 3
|
grep -w '/var/lib/machines' /proc/mounts
|
||||||
fi
|
failed_when: false
|
||||||
fi
|
changed_when: false
|
||||||
register: machines_create
|
register: machinectl_mount
|
||||||
changed_when: machines_create.rc == 3
|
tags:
|
||||||
failed_when: machines_create.rc not in [0, 3]
|
- skip_ansible_lint
|
||||||
args:
|
|
||||||
executable: /bin/bash
|
|
||||||
when:
|
|
||||||
- lxc_image_cache_refresh | bool
|
|
||||||
|
|
||||||
# In later versions of SystemD this is automatically done for us
|
- name: Create systemd sparse file
|
||||||
# by the machinectl cli on first run.
|
shell: "truncate -s '>{{ lxc_host_machine_volume_size }}' /var/lib/machines.raw"
|
||||||
- name: Format the machines file
|
|
||||||
filesystem:
|
|
||||||
fstype: btrfs
|
|
||||||
dev: /var/lib/machines.raw
|
|
||||||
when:
|
|
||||||
- machines_create | changed
|
|
||||||
|
|
||||||
# In later versions of SystemD this is automatically done for us
|
- name: Old systemd machinectl mount
|
||||||
# by the machinectl cli on first run.
|
block:
|
||||||
- name: Create machines mount point
|
# In later versions of SystemD this is automatically done for us
|
||||||
file:
|
# by the machinectl cli on first run.
|
||||||
path: "/var/lib/machines"
|
- name: Format the machines sparse file
|
||||||
state: "directory"
|
filesystem:
|
||||||
recurse: true
|
fstype: btrfs
|
||||||
|
dev: /var/lib/machines.raw
|
||||||
|
|
||||||
# In later versions of SystemD this unit file has been corrected
|
# In later versions of SystemD this is automatically done for us
|
||||||
# and is packaged with systemd proper.
|
# by the machinectl cli on first run.
|
||||||
- name: Move machines mount into place
|
- name: Create machines mount point
|
||||||
copy:
|
file:
|
||||||
src: var-lib-machines.mount
|
path: "/var/lib/machines"
|
||||||
dest: /etc/systemd/system/var-lib-machines.mount
|
state: "directory"
|
||||||
register: mount_unit
|
|
||||||
notify:
|
|
||||||
- Reload systemd units
|
|
||||||
when:
|
|
||||||
- machines_create | changed
|
|
||||||
|
|
||||||
# In later versions of SystemD this is not needed. Referenced in
|
# In later versions of SystemD this unit file has been corrected
|
||||||
# the following ML post resolves the bug.
|
# and is packaged with systemd proper.
|
||||||
# * https://lists.freedesktop.org/archives/systemd-devel/2015-March/029151.html
|
- name: Move machines mount into place
|
||||||
- name: Move machined service into place
|
copy:
|
||||||
template:
|
src: var-lib-machines.mount
|
||||||
src: systemd-machined.service.j2
|
dest: /etc/systemd/system/var-lib-machines.mount
|
||||||
dest: /etc/systemd/system/systemd-machined.service
|
register: mount_unit
|
||||||
register: machined_unit
|
notify:
|
||||||
notify:
|
- Start machines mount
|
||||||
- Reload systemd units
|
|
||||||
- Restart machined
|
|
||||||
when:
|
|
||||||
- machines_create | changed
|
|
||||||
|
|
||||||
# In later versions of SystemD this is not needed. Referenced in
|
# In later versions of SystemD this is not needed. Referenced in
|
||||||
# the following commit resolves the bug.
|
# the following ML post resolves the bug.
|
||||||
# * https://cgit.freedesktop.org/systemd/systemd/commit/src/machine/org.freedesktop.machine1.conf?id=72c3897f77a7352618ea76b880a6764f52d6327b
|
# * https://lists.freedesktop.org/archives/systemd-devel/2015-March/029151.html
|
||||||
- name: Move machine1 dbus config into place
|
- name: Move machined service into place
|
||||||
copy:
|
template:
|
||||||
src: org.freedesktop.machine1.conf
|
src: systemd-machined.service.j2
|
||||||
dest: /etc/dbus-1/system.d/org.freedesktop.machine1.conf
|
dest: /etc/systemd/system/systemd-machined.service
|
||||||
register: machine1_conf
|
register: machined_unit
|
||||||
notify:
|
notify:
|
||||||
- Reload systemd units
|
- Reload systemd units
|
||||||
- Restart dbus
|
- Restart machined
|
||||||
|
|
||||||
|
# In later versions of SystemD this is not needed. Referenced in
|
||||||
|
# the following commit resolves the bug.
|
||||||
|
# * https://cgit.freedesktop.org/systemd/systemd/commit/src/machine/org.freedesktop.machine1.conf?id=72c3897f77a7352618ea76b880a6764f52d6327b
|
||||||
|
- name: Move machine1 dbus config into place
|
||||||
|
copy:
|
||||||
|
src: org.freedesktop.machine1.conf
|
||||||
|
dest: /etc/dbus-1/system.d/org.freedesktop.machine1.conf
|
||||||
|
register: machine1_conf
|
||||||
|
notify:
|
||||||
|
- Reload systemd units
|
||||||
|
- Restart dbus
|
||||||
when:
|
when:
|
||||||
- machines_create | changed
|
- machinectl_mount.rc != 0
|
||||||
|
|
||||||
# Ensure lxc networks are running as they're supposed to
|
# Ensure lxc networks are running as they're supposed to
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
||||||
# Ignore the Ansible warning here about using 'mount' via the shell module
|
# NOTE(cloudnull): Because the machines mount may be a manually created sparse
|
||||||
# instead of using the mount Ansible module.
|
# file we run an online resize to ensure the machines mount is
|
||||||
- name: Mount all
|
# the size we expect.
|
||||||
shell: "mount | grep '/var/lib/machines' || (systemctl start var-lib-machines.mount && exit 3)"
|
- name: Ensure the machines fs is sized correctly
|
||||||
args:
|
command: "btrfs filesystem resize max /var/lib/machines"
|
||||||
warn: no
|
changed_when: false
|
||||||
register: mount_machines
|
|
||||||
changed_when: mount_machines.rc == 3
|
- name: Disable the machinectl quota system
|
||||||
failed_when: mount_machines.rc not in [0, 3]
|
command: "btrfs quota {{ lxc_host_machine_quota_disabled | bool | ternary('disable', 'enable') }} /var/lib/machines"
|
||||||
tags:
|
changed_when: false
|
||||||
- skip_ansible_lint
|
|
||||||
|
|
||||||
# Because of this post and it's related bug(s) this is adding the container
|
# Because of this post and it's related bug(s) this is adding the container
|
||||||
# volumes the old way. The new way would simply be calling `machinectl`.
|
# volumes the old way. The new way would simply be calling `machinectl`.
|
||||||
|
Loading…
Reference in New Issue
Block a user