Pengpeng Sun has proposed merging ~pengpengs/cloud-init:fix/ds-identify-dscheck-OVF-is-cdrom-oversized into cloud-init:master.
Commit message: Add a cdrom size checker for OVF ds to ds-identify With a large size ISO file attached to iso dev, ds-identify might grep it entirely if iso dev is ISO9660, it takes very long time to start OS. This change addes a checker to grep the ISO size, consider ISO is too large if the size is greater than 99999KB. This change also moves ovf vmware guest customization checker to be ahead of cdrom ovf checker, so no need grep entire ISO if vmware guest customization is enabled. Requested reviews: cloud-init commiters (cloud-init-dev) For more details, see: https://code.launchpad.net/~pengpengs/cloud-init/+git/cloud-init/+merge/368959 -- Your team cloud-init commiters is requested to review the proposed merge of ~pengpengs/cloud-init:fix/ds-identify-dscheck-OVF-is-cdrom-oversized into cloud-init:master.
diff --git a/tools/ds-identify b/tools/ds-identify index e16708f..12a36bb 100755 --- a/tools/ds-identify +++ b/tools/ds-identify @@ -84,6 +84,7 @@ PATH_ETC_CI_CFG="${PATH_ETC_CI_CFG:-${PATH_ETC_CLOUD}/cloud.cfg}" PATH_ETC_CI_CFG_D="${PATH_ETC_CI_CFG_D:-${PATH_ETC_CI_CFG}.d}" PATH_RUN_CI="${PATH_RUN_CI:-${PATH_RUN}/cloud-init}" PATH_RUN_CI_CFG=${PATH_RUN_CI_CFG:-${PATH_RUN_CI}/cloud.cfg} +PATH_RUN_CI_CDROM=${PATH_RUN_CI_CDROM:-${PATH_RUN_CI}/cdrom} PATH_RUN_DI_RESULT=${PATH_RUN_DI_RESULT:-${PATH_RUN_CI}/.ds-identify.result} DI_LOG="${DI_LOG:-${PATH_RUN_CI}/ds-identify.log}" @@ -746,6 +747,32 @@ ovf_vmware_transport_guestinfo() { return 0 } +is_cdrom_oversized() { + local dev="$1" + local mountPath="${PATH_RUN_CI_CDROM}$dev" + local ret=0 out="" + # check if cdrom has been mounted, the result is different + # between linux distroes. If not, create a directory under + # /run/cloud-init/cdrom and then mount cdrom with it. + out=$(cat /etc/mtab | grep $dev) || { + [ -d "$mountPath" ] || mkdir --parents "$mountPath" + mount "$dev" "$mountPath" + } + # grep cdrom size with block-size set to 1K, consider cdrom + # is oversized if result reaches 6 digit which means cdrom + # size > 99999K + out=$(df --block-size=1K "$dev" | grep --perl-regexp --only-matching "$dev\s+\d{6}") + ret=$? + # check if the directory under /run/cloud-init/cdrom exists. + # if yes, unmount and delete it + [ -d "$mountPath" ] && umount "$mountPath" && rm -rf "${PATH_RUN_CI_CDROM}" + if [ $ret -eq 0 ]; then + debug 1 "$dev is oversized" + return 0 + fi + return 1 +} + is_cdrom_ovf() { local dev="$1" label="$2" # skip devices that don't look like cdrom paths. @@ -766,6 +793,9 @@ is_cdrom_ovf() { config-2|CONFIG-2|rd_rdfe_stable*|cidata|CIDATA) return 1;; esac + # skip iso dev which size is too large + is_cdrom_oversized "$dev" && return 1 + local idstr="http://schemas.dmtf.org/ovf/environment/1" grep --quiet --ignore-case "$idstr" "${PATH_ROOT}$dev" } @@ -780,6 +810,8 @@ dscheck_OVF() { ovf_vmware_transport_guestinfo && return "${DS_FOUND}" + ovf_vmware_guest_customization && return "${DS_FOUND}" + # DI_ISO9660_DEVS is <device>=label,<device>=label2 # like /dev/sr0=OVF-TRANSPORT,/dev/other=with spaces if [ "${DI_ISO9660_DEVS#${UNAVAILABLE}:}" = "${DI_ISO9660_DEVS}" ]; then @@ -791,10 +823,6 @@ dscheck_OVF() { done fi - if ovf_vmware_guest_customization; then - return ${DS_FOUND} - fi - return ${DS_NOT_FOUND} }
_______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp