Merge pull request #153 from Azure/bhbrahma/text-file-busy

Log the root causes of text file busy error for custom-script-extension binary
This commit is contained in:
Bhaskar Brahma 2019-10-07 14:23:06 -07:00 коммит произвёл GitHub
Родитель fc5210a6d8 718f98b7b0
Коммит fdda9d0d67
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -50,6 +50,28 @@ write_status() {
fi
}
check_binary_write_lock() {
set +e # disable exit on non-zero return code
local retry_attempts=0
while (( retry_attempts < 10 )); do
lsof_output="$(lsof ${bin})"
if [ "$?" -eq 0 ]; then
echo "${HANDLER_BIN} is open by the following processes: "
echo "${lsof_output}"
((++retry_attempts))
echo "sleeping for 3 seconds before retry, attempt ${retry_attempts} of 10"
sleep 3
else
set -e
return 0 #Success path
fi
done
echo "Timed out waiting for lock on ${HANDLER_BIN}"
echo "File handle is still open by the following processes: "
echo "${lsof_output}"
exit 1
}
if [ "$#" -ne 1 ]; then
echo "Incorrect usage."
echo "Usage: $0 <command>"
@ -69,10 +91,12 @@ if [[ "$cmd" == "enable" ]]; then
# to detach from the handler process tree to avoid getting terminated
# after the 15-minute extension enabling timeout.
write_status
check_binary_write_lock
set -x
nohup "$bin" $@ &
else
# execute the handler process as a child process
check_binary_write_lock
set -x
"$bin" $@
fi

Просмотреть файл

@ -2,7 +2,7 @@
<ExtensionImage xmlns="http://schemas.microsoft.com/windowsazure">
<ProviderNameSpace>Microsoft.Azure.Extensions</ProviderNameSpace>
<Type>CustomScript</Type>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<Label>Microsoft Azure Custom Script Extension for Linux Virtual Machines</Label>
<HostingResources>VmRole</HostingResources>
<MediaLink></MediaLink>