From 5982e487749e4264ca0c550eaf02d4a5b90e44f1 Mon Sep 17 00:00:00 2001 From: Nitesh Konkar Date: Mon, 23 Sep 2019 18:46:02 +0530 Subject: [PATCH] lib.sh: Fix curl error when using curl+yq When you curl versions.yaml file and pipe into yq, sometimes the piped program closes the read pipe before the previous program is finished leading to "curl: (23) Failed writing body (1337 != 1371)". As a workaround we pipe the stream through double "tac", an intermediary program that always reads the whole page before feeding it to the next program. Fixes: #363 Signed-off-by: Nitesh Konkar --- scripts/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 14be92cb3d..218eef5515 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -289,7 +289,7 @@ detect_go_version() typeset -r runtimeVersionsURL="https://raw.githubusercontent.com/kata-containers/runtime/${runtimeRevision}/versions.yaml" info "Getting golang version from ${runtimeVersionsURL}" # This may fail if we are a kata bump. - if GO_VERSION="$(curl -fsSL "$runtimeVersionsURL" | $yq r - "languages.golang.version")"; then + if GO_VERSION="$(curl -fsSL "$runtimeVersionsURL" | tac | tac | $yq r - "languages.golang.version")"; then [ "$GO_VERSION" != "null" ] return 0 fi @@ -301,7 +301,7 @@ detect_go_version() info "There is not runtime repository in filesystem (${kata_runtime_pkg_dir})" local runtime_versions_url="https://raw.githubusercontent.com/kata-containers/runtime/${KATA_BRANCH}/versions.yaml" info "Get versions file from ${runtime_versions_url}" - GO_VERSION="$(curl -fsSL "${runtime_versions_url}" | $yq r - "languages.golang.version")" + GO_VERSION="$(curl -fsSL "${runtime_versions_url}" | tac | tac | $yq r - "languages.golang.version")" if [ "$?" == "0" ] && [ "$GO_VERSION" != "null" ]; then return 0 fi