Create symlink for libvirt save directory

Nova can fill up the partition that /var/lib/libvirt/qemu/save is on
when nova calls `image-create` on an instance.  This occurs because
nova calls libvirt with managedsave which creates a temporary file in
the /var/lib/libvirt/qemu/save location.  Libvirt does not allow the
location of /var/lib/libvirt/qemu/save to be configurable so we have
to manage it ourselves via bindmounts or symlinks.

In this commit we remove the /var/lib/libvirt/qemu/save directory and
create a symlink in it's place, pointing to
`{{ nova_system_home_folder }}/save` instead (which we also create).
This location was chosen as deployers often have more space here for
nova instances.

Change-Id: I5c96f70aa355cc02379fe7e0681416eca53447eb
Partial-Bug: #1585325
This commit is contained in:
Matthew Thode 2016-05-24 13:58:18 -05:00
parent b3c05fa39d
commit 2599006a81
No known key found for this signature in database
GPG Key ID: 64A37BEAAE19A4E8
4 changed files with 36 additions and 0 deletions

View File

@ -52,6 +52,7 @@ nova_system_group_name: nova
nova_system_shell: /bin/bash
nova_system_comment: nova system user
nova_system_home_folder: "/var/lib/{{ nova_system_user_name }}"
nova_libvirt_save_path: "{{ nova_system_home_folder }}/save"
## Manually specified nova UID/GID
# Deployers can specify a UID for the nova user as well as the GID for the
@ -397,6 +398,8 @@ nova_pip_packages:
- nova
- python-cephlibs
nova_qemu_user: libvirt-qemu
nova_qemu_group: kvm
## Tunable overrides
nova_nova_conf_overrides: {}

View File

@ -0,0 +1,8 @@
---
fixes:
- The ``/var/lib/libvirt/qemu/save`` directory is now a
symlink to ``{{ nova_system_home_folder }}/save`` to
resolve an issue where the default location used by the
libvirt managed save command can result with the root
partitions on compute nodes becoming full when
``nova image-create`` is run on large instances.

View File

@ -45,6 +45,30 @@
- nova-apt-packages
- nova-compute-kvm-apt-packages
- name: Check if qemu save directory is a directory
stat:
path: "/var/lib/libvirt/qemu/save"
register: qemu_savedir_stat
- name: Check if qemu save directory is empty
shell:
cmd: 'ls -1A /var/lib/libvirt/qemu/save'
register: qemu_savedir_empty
# We force the link creation if our tests passed, this removes the directory as
# well
- name: Symlink qemu save dir to nova_libvirt_save_path
file:
path: "/var/lib/libvirt/qemu/save"
state: link
owner: "{{ nova_qemu_user }}"
group: "{{ nova_qemu_group }}"
src: "{{ nova_libvirt_save_path }}"
force: True
when:
- qemu_savedir_stat.stat.isdir
- qemu_savedir_empty.stdout_lines | length == 0
- name: Install pip packages (venv)
pip:
name: "{{ item }}"

View File

@ -68,6 +68,7 @@
- { path: "{{ nova_system_home_folder }}/.ssh", mode: "0700" }
- { path: "{{ nova_system_home_folder }}/cache/api" }
- { path: "{{ nova_system_home_folder }}/instances" }
- { path: "{{ nova_libvirt_save_path }}", mode: "0750" }
- { path: "/var/lock/nova" }
- { path: "/var/run/nova" }
tags: