Merge pull request #366 from nitkon/dns_initrd

initrd_builder: Create empty resolv.conf in rootfs
This commit is contained in:
Salvador Fuentes 2019-09-26 12:04:39 -05:00 committed by GitHub
commit 3e4b381248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -391,9 +391,6 @@ create_rootfs_image() {
info "Creating empty machine-id to allow systemd to bind-mount it"
touch "${mount_dir}/etc/machine-id"
info "Creating empty resolv.conf to allow kata-agent to bind-mount it"
touch "${mount_dir}/etc/resolv.conf"
info "Unmounting root partition"
umount "${mount_dir}"
OK "Root partition unmounted"

View File

@ -510,6 +510,15 @@ EOT
[ -x "${init}" ] || [ -L "${init}" ] || die "/sbin/init is not installed in ${ROOTFS_DIR}"
OK "init is installed"
# Create an empty /etc/resolv.conf, to allow agent to bind mount container resolv.conf to Kata VM
dns_file="${ROOTFS_DIR}/etc/resolv.conf"
if [ -L "$dns_file" ]; then
# if /etc/resolv.conf is a link, it cannot be used for bind mount
rm -f "$dns_file"
fi
info "Create /etc/resolv.conf file in rootfs if not exist"
touch "$dns_file"
info "Creating summary file"
create_summary_file "${ROOTFS_DIR}"
}