Merge "Clean-up old systemd prep and allow machinctl to grow"

This commit is contained in:
Zuul 2018-02-12 20:01:24 +00:00 committed by Gerrit Code Review
commit 588f1ba9d1
5 changed files with 113 additions and 87 deletions

View File

@ -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.

View File

@ -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"

View 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.

View File

@ -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 }}"

View File

@ -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`.