From 27306a237ff594960d4b7f2b040a66be29cd6005 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Wed, 6 Mar 2019 11:39:44 +0100 Subject: [PATCH 1/2] build_library: fix Flatcar-specific download path from GCS There was an issue with vagrant json files where `url` field is set to an invalid URL. For example, in https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_vagrant.json, `url` is gs://flatcar-jenkins/alpha/amd64-usr/2023.0.0/flatcar_production_vagrant.box. It should be actually https://alpha.release.flatcar-linux.net/amd64-usr/2023.0.0/flatcar_production_vagrant.box. Its reason is, the function `download_image_url()` in release_util.sh simply assumes that the input variable `download_root` includes `gs://builds.release.core-os.net/alpha` in `GS_RELEASE_ROOT` of resource variables. That's true only for Container Linux. In case of Flatcar, the `download_root` is actually `gs://flatcar-jenkins/alpha`. What we should do here is to check for `flatcar-jenkins` in download_root. If it's true, reconstruct the download_path as `.release.flatcar-linux.net/...`. Also we should change `http` to `https` to be used for Flatcar servers. Doing that, we will not need to run `fix_vagrant.sh` for every release. --- build_library/release_util.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index bfe92318ef..951aa340b5 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -229,9 +229,14 @@ download_image_url() { local download_root="${FLAGS_download_root:-${UPLOAD_ROOT}}" local download_path + local download_channel if [[ -n "${FLAGS_download_path}" ]]; then download_path="${FLAGS_download_path%%/}" - elif [[ "${download_root}" = *release.core-os.net* ]]; then + elif [[ "${download_root}" = *flatcar-jenkins* ]]; then + if [[ "${download_path}" == gs://* ]]; then + download_channel="${download_root##*/}" + download_root="gs://${download_channel}.release.flatcar-linux.net" + fi # Official release download paths don't include the boards directory download_path="${download_root%%/}/${BOARD}/${FLATCAR_VERSION}" else @@ -240,7 +245,7 @@ download_image_url() { # Just in case download_root was set from UPLOAD_ROOT if [[ "${download_path}" == gs://* ]]; then - download_path="http://${download_path#gs://}" + download_path="https://${download_path#gs://}" fi echo "${download_path}/$1" From 43c4c013407e6e53d5ac2452262b6b422ca97a30 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Tue, 12 Mar 2019 12:24:44 +0100 Subject: [PATCH 2/2] build_library: set download_path even if its input is empty `${download_path}` gets initialized only if `${FLAGS_download_path}` is given by the user. If not given, that becomes simply an empty string. So it does not make sense to check if that includes `gs://`. Let's simply remove the if statement. That's why the vagrant json file still has a wrong URL like `https://flatcar-jenkins/alpha/...`. Tested with the following test script. ``` download_path="" download_root="gs://flatcar-jenkins/alpha" if [[ -n "${FLAGS_download_path}" ]]; then download_path="${download_path%%/}" elif [[ "${download_root}" == *flatcar-jenkins* ]]; then download_channel="${download_root##*/}" download_root="gs://${download_channel}.release.flatcar-linux.net" download_path="${download_root%%/}/amd64-usr/2065.0.0" else download_path="${download_root%%/}/boards/amd64-usr/2065.0.0" fi if [[ "${download_path}" == gs://* ]]; then download_path="https://${download_path#gs://}" fi echo "Result: download_path = ${download_path}" ``` --- build_library/release_util.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index 951aa340b5..12d8a82807 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -232,11 +232,9 @@ download_image_url() { local download_channel if [[ -n "${FLAGS_download_path}" ]]; then download_path="${FLAGS_download_path%%/}" - elif [[ "${download_root}" = *flatcar-jenkins* ]]; then - if [[ "${download_path}" == gs://* ]]; then - download_channel="${download_root##*/}" - download_root="gs://${download_channel}.release.flatcar-linux.net" - fi + elif [[ "${download_root}" == *flatcar-jenkins* ]]; then + download_channel="${download_root##*/}" + download_root="gs://${download_channel}.release.flatcar-linux.net" # Official release download paths don't include the boards directory download_path="${download_root%%/}/${BOARD}/${FLATCAR_VERSION}" else