Open tash opened 4 years ago
modules/seed.py _check_install calls os.rename which won't work under certain circumstances when source and destination are on different filesystems: https://github.com/saltstack/salt/blob/d0cad3e5a35ba80f18413820227dea4f3d6234d3/salt/modules/seed.py#L168-L173 A fix should be fairly easy:
shutil.move(cfg_files['privkey'], os.path.join(
mpt, pki_dir.lstrip('/'), 'minion.pem'))
shutil.move(cfg_files['pubkey'], os.path.join(
mpt, pki_dir.lstrip('/'), 'minion.pub'))
shutil.move(cfg_files['config'], os.path.join(mpt, 'etc/salt/minion'))
res = True
@tash Thanks for the report!
Looks like a pretty reasonable fix, too. Are you interested in writing the tests/fix for this? If not, that's totally fine.
For whoever does address this:
There's some code already in tests/unit/modules/test_seed.py
that could either be modified to apply to this case, or used as a starting point here. In an ideal world we could write functional tests that would actually test the movement, but I'm pretty sure our existing CI pipeline doesn't have multiple mounts to break with the cross-device link.
I think it would be reasonable to just mock os.rename
and have it raise OSerror
(just to make sure it's not called).
Description of Issue
When creating a VM with virt.init, the seeding fails on the given system:
Logging:
Setup
libvirt-bash-completion-4.5.0-10.el7_6.2.x86_64 libvirt-client-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-nwfilter-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-lxc-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-disk-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-4.5.0-10.el7_6.2.x86_64 libvirt-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-kvm-4.5.0-10.el7_6.2.x86_64 libvirt-libs-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-network-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-qemu-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-gluster-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-scsi-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-logical-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-iscsi-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-secret-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-nodedev-4.5.0-10.el7_6.2.x86_64 libvirt-glib-1.0.0-1.el7.x86_64 libvirt-python-4.5.0-1.el7.x86_64 libvirt-daemon-driver-storage-core-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-config-network-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-mpath-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-storage-rbd-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-interface-4.5.0-10.el7_6.2.x86_64
qemu-kvm-common-ev-2.10.0-21.el7_5.7.1.x86_64 qemu-kvm-tools-ev-2.10.0-21.el7_5.7.1.x86_64 libvirt-daemon-kvm-4.5.0-10.el7_6.2.x86_64 libvirt-daemon-driver-qemu-4.5.0-10.el7_6.2.x86_64 qemu-kvm-ev-2.10.0-21.el7_5.7.1.x86_64 qemu-img-ev-2.10.0-21.el7_5.7.1.x86_64 ipxe-roms-qemu-20170123-1.git4e85b27.el7_4.1.noarch
libguestfs-1.38.2-12.el7.x86_64 libguestfs-tools-c-1.38.2-12.el7.x86_64 libguestfs-tools-1.38.2-12.el7.noarch perl-Sys-Guestfs-1.38.2-12.el7.x86_64 libguestfs-bash-completion-1.38.2-12.el7.noarch
Steps to Reproduce Issue
Call is made locally on the Hypervisor (test02):
salt-call -l debug virt.init gitlab 2 4096 start=False image=/central/vm/test/openSUSE-Leap-15.1-JeOS.x86_64-15.1.0-kvm-and-xen-Snapshot9.114.qcow2
Versions Report