You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rh...@apache.org on 2020/04/25 02:58:13 UTC
[geode] branch develop updated: GEODE-8022: Fix windows image build
via pinning. (#4993)
This is an automated email from the ASF dual-hosted git repository.
rhoughton pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 0aae6cb GEODE-8022: Fix windows image build via pinning. (#4993)
0aae6cb is described below
commit 0aae6cbce71a9c4e4ca4b93589c0fbe164d8ac99
Author: Robert Houghton <rh...@pivotal.io>
AuthorDate: Fri Apr 24 19:57:42 2020 -0700
GEODE-8022: Fix windows image build via pinning. (#4993)
DRY the packer creation scripts.
Tested by pinning a working windows image ID.
Signed-off-by: Sean Goller <sg...@pivotal.io>
---
ci/images/google-geode-builder/build_image.sh | 63 ----------------------
ci/images/google-geode-builder/packer.json | 2 +-
.../{windows-packer.json => packer.json} | 2 +-
ci/pipelines/images/jinja.template.yml | 16 ++++--
.../build_image.sh | 22 ++++----
5 files changed, 24 insertions(+), 81 deletions(-)
diff --git a/ci/images/google-geode-builder/build_image.sh b/ci/images/google-geode-builder/build_image.sh
deleted file mode 100755
index 0abe911..0000000
--- a/ci/images/google-geode-builder/build_image.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
- SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
-done
-SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-
-
-pushd ${SCRIPTDIR}
-
-if [[ -n "${CONCOURSE_GCP_KEY}" ]]; then
- dd of=credentials.json <<< "${CONCOURSE_GCP_KEY}"
- export GOOGLE_APPLICATION_CREDENTIALS=${SCRIPTDIR}/credentials.json
-fi
-
-GCP_NETWORK="default"
-GCP_SUBNETWORK="default"
-
-MY_NAME=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/name" -H "Metadata-Flavor: Google")
-if [[ -n "${MY_NAME}" ]]; then
- MY_ZONE=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/zone" -H "Metadata-Flavor: Google")
- MY_ZONE=${MY_ZONE##*/}
- NETWORK_INTERFACE_INFO="$(gcloud compute instances describe ${MY_NAME} --zone ${MY_ZONE} --format="json(networkInterfaces)")"
- GCP_NETWORK=$(echo ${NETWORK_INTERFACE_INFO} | jq -r '.networkInterfaces[0].network')
- GCP_NETWORK=${GCP_NETWORK##*/}
- GCP_SUBNETWORK=$(echo ${NETWORK_INTERFACE_INFO} | jq -r '.networkInterfaces[0].subnetwork')
- GCP_SUBNETWORK=${GCP_SUBNETWORK##*/}
-fi
-
-HASHED_PIPELINE_PREFIX="i$(uuidgen -n @dns -s -N "${PIPELINE_PREFIX}")-"
-
-echo "Running packer"
-PACKER_LOG=1 packer build \
- --var "base_family=${BASE_FAMILY}" \
- --var "geode_docker_image=${GEODE_DOCKER_IMAGE}" \
- --var "pipeline_prefix=${PIPELINE_PREFIX}" \
- --var "hashed_pipeline_prefix=${HASHED_PIPELINE_PREFIX}" \
- --var "gcp_project=${GCP_PROJECT}" \
- --var "java_build_version=${JAVA_BUILD_VERSION}" \
- --var "gcp_network=${GCP_NETWORK}" \
- --var "gcp_subnetwork=${GCP_SUBNETWORK}" \
- --var "use_internal_ip=true" \
- --var "packer_ttl=$(($(date +%s) + 60 * 60 * 12))" \
- packer.json
diff --git a/ci/images/google-geode-builder/packer.json b/ci/images/google-geode-builder/packer.json
index b3fed3b..8f691fd 100644
--- a/ci/images/google-geode-builder/packer.json
+++ b/ci/images/google-geode-builder/packer.json
@@ -11,7 +11,7 @@
{
"type": "googlecompute",
"project_id": "{{user `gcp_project`}}",
- "source_image_family": "{{ user `base_family`}}",
+ "source_image": "{{ user `base_image`}}",
"ssh_username": "packer",
"zone": "us-central1-f",
"image_family": "{{user `pipeline_prefix`}}linux-geode-builder",
diff --git a/ci/images/google-windows-geode-builder/windows-packer.json b/ci/images/google-windows-geode-builder/packer.json
similarity index 99%
rename from ci/images/google-windows-geode-builder/windows-packer.json
rename to ci/images/google-windows-geode-builder/packer.json
index 20e169b..7b63db5 100644
--- a/ci/images/google-windows-geode-builder/windows-packer.json
+++ b/ci/images/google-windows-geode-builder/packer.json
@@ -18,7 +18,7 @@
"project_id": "{{user `gcp_project`}}",
"network": "{{user `gcp_network`}}",
"subnetwork": "{{user `gcp_subnetwork`}}",
- "source_image_family": "{{ user `base_family`}}",
+ "source_image": "{{ user `base_image`}}",
"disk_size": "100",
"machine_type": "n1-standard-4",
"communicator": "winrm",
diff --git a/ci/pipelines/images/jinja.template.yml b/ci/pipelines/images/jinja.template.yml
index 9ddeb35..fe8b50c 100644
--- a/ci/pipelines/images/jinja.template.yml
+++ b/ci/pipelines/images/jinja.template.yml
@@ -68,6 +68,7 @@ resources:
source:
branch: ((geode-build-branch))
paths:
+ - ci/scripts/build_image.sh
- ci/images/google-geode-builder
{{ github_access() | indent(4) }}
@@ -76,6 +77,7 @@ resources:
source:
branch: ((geode-build-branch))
paths:
+ - ci/scripts/build_image.sh
- ci/images/google-windows-geode-builder
{{ github_access() | indent(4) }}
@@ -230,6 +232,8 @@ jobs:
config:
inputs:
- name: google-geode-builder
+ - name: linux-base-family
+ path: base-family
outputs:
- name: results
platform: linux
@@ -239,9 +243,10 @@ jobs:
GCP_PROJECT: ((gcp-project))
CONCOURSE_GCP_KEY: "((concourse-gcp-key))"
JAVA_BUILD_VERSION: 8
- BASE_FAMILY: ((linux-base-family))
run:
- path: google-geode-builder/ci/images/google-geode-builder/build_image.sh
+ path: google-geode-builder/ci/scripts/build_image.sh
+ args:
+ - google-geode-builder/ci/images/google-geode-builder/packer.json
- name: build-google-windows-geode-builder
public: ((public-pipelines))
@@ -262,6 +267,8 @@ jobs:
config:
inputs:
- name: google-windows-geode-builder
+ - name: windows-base-family
+ path: base-family
outputs:
- name: results
platform: linux
@@ -271,9 +278,10 @@ jobs:
GCP_PROJECT: ((gcp-project))
CONCOURSE_GCP_KEY: "((concourse-gcp-key))"
JAVA_BUILD_VERSION: 8
- BASE_FAMILY: ((windows-base-family))
run:
- path: google-windows-geode-builder/ci/images/google-windows-geode-builder/build_image.sh
+ path: google-windows-geode-builder/ci/scripts/build_image.sh
+ args:
+ - google-windows-geode-builder/ci/images/google-windows-geode-builder/packer.json
- name: build-alpine-tools-docker-image
public: ((public-pipelines))
diff --git a/ci/images/google-windows-geode-builder/build_image.sh b/ci/scripts/build_image.sh
similarity index 80%
rename from ci/images/google-windows-geode-builder/build_image.sh
rename to ci/scripts/build_image.sh
index 2c2fd96..0db5b48 100755
--- a/ci/images/google-windows-geode-builder/build_image.sh
+++ b/ci/scripts/build_image.sh
@@ -17,21 +17,19 @@
# limitations under the License.
PACKER=${PACKER:-packer}
-PACKER_ARGS="${*}"
+PACKER_JSON_SCRIPT="$(pwd)/${1}"
+PACKER_ARGS="${@:2}"
INTERNAL=${INTERNAL:-false}
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
- SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
-done
-SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-pushd ${SCRIPTDIR}
+PACKERDIR="$( dirname ${PACKER_JSON_SCRIPT} )"
+
+BASE_IMAGE="$(cat base-family/name)"
+
+pushd ${PACKERDIR}
if [[ -n "${CONCOURSE_GCP_KEY}" ]]; then
dd of=credentials.json <<< "${CONCOURSE_GCP_KEY}"
- export GOOGLE_APPLICATION_CREDENTIALS=${SCRIPTDIR}/credentials.json
+ export GOOGLE_APPLICATION_CREDENTIALS=${PACKERDIR}/credentials.json
fi
GCP_NETWORK="default"
@@ -58,7 +56,7 @@ HASHED_PIPELINE_PREFIX="i$(uuidgen -n @dns -s -N "${PIPELINE_PREFIX}")-"
echo "Running packer"
PACKER_LOG=1 ${PACKER} build ${PACKER_ARGS} \
- --var "base_family=${BASE_FAMILY}" \
+ --var "base_image=${BASE_IMAGE}" \
--var "geode_docker_image=${GEODE_DOCKER_IMAGE}" \
--var "pipeline_prefix=${PIPELINE_PREFIX}" \
--var "hashed_pipeline_prefix=${HASHED_PIPELINE_PREFIX}" \
@@ -68,4 +66,4 @@ PACKER_LOG=1 ${PACKER} build ${PACKER_ARGS} \
--var "gcp_subnetwork=${GCP_SUBNETWORK}" \
--var "use_internal_ip=${INTERNAL}" \
--var "packer_ttl=$(($(date +%s) + 60 * 60 * 12))" \
- windows-packer.json
+ ${PACKER_JSON_SCRIPT}