diff options
author | Chris Evich <cevich@redhat.com> | 2018-10-08 09:06:10 -0400 |
---|---|---|
committer | Chris Evich <cevich@redhat.com> | 2018-10-18 12:37:08 -0400 |
commit | 02bc3c9962f8d80a239bba1a6c8bd97d1c5ba44c (patch) | |
tree | ed03e5aad9042750fed9a6e062e2fabd5327cfd1 | |
parent | a75a888640efcbecdf80caac3004957d6b0752ed (diff) | |
download | podman-02bc3c9962f8d80a239bba1a6c8bd97d1c5ba44c.tar.gz podman-02bc3c9962f8d80a239bba1a6c8bd97d1c5ba44c.tar.bz2 podman-02bc3c9962f8d80a239bba1a6c8bd97d1c5ba44c.zip |
Fix Cirrus/Packer VM image building
An invalid GCE value is being passed to packer, preventing it from
building VM images. Fix this, and centralize the definition of the
image name suffix by setting it at ``setup_environment.sh`` call-time,
rather encoding inside packer's `libpod_images.json`. This makes
the value available for use by other scripts.
Also, switch the unique component of the name, to be based on the
commit-sha being tested. This will improve traceability, since the git
history is more permanent than the `CIRRUS_BUILD_ID` env. var. The
later is subject to log-rotation, destroying evidence of the images
source state.
Signed-off-by: Chris Evich <cevich@redhat.com>
-rw-r--r-- | .cirrus.yml | 20 | ||||
-rwxr-xr-x | contrib/cirrus/build_vm_images.sh | 2 | ||||
-rw-r--r-- | contrib/cirrus/lib.sh | 5 | ||||
-rw-r--r-- | contrib/cirrus/packer/libpod_images.json | 10 | ||||
-rwxr-xr-x | contrib/cirrus/setup_environment.sh | 1 |
5 files changed, 22 insertions, 16 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index c00f2d095..f59dd9396 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -82,19 +82,21 @@ build_vm_images_task: PACKER_BUILDS: "ubuntu-18" # TODO: Make these work (also full_vm_testing_task above) # PACKER_BUILDS: "rhel-7,centos-7,fedora-28,ubuntu-18" - # Command to register a RHEL VM - RHSM_COMMAND: ENCRYPTED[fec01433222af1ed0b8e40e89e7d18f6ee2fa9f49a1e721dc72f7eed3c740661215d1bd05cb54ac66a1a62116b92bdce] - # Additional environment variables needed to build GCE images, within a GCE VM - SERVICE_ACCOUNT: ENCRYPTED[02e03838b1156eb9516c7cc1e888e287910759842275f3c7bc2b4d56075cc6740e29ffa0ab71ebdbbd079673361dd8c9] - GCE_SSH_USERNAME: ENCRYPTED[a19a4ec62423e3e0fe4e7d1a5c9f11eda8fde321b9047ab5ed5590c2b1d7a2d12091c2be1531f949eae927059c2ae531] - GCP_PROJECT_ID: ENCRYPTED[77cb2d392bbc8d17412547d7d91f8d190089bf6e6b96eab9927994bbff6ab2c691ba0329ac7a650ba6182fbbab9fb68d] - # Existing base values to use, output images get epoc stamped names - PACKER_VER: "1.3.1" - # low-level base VM image name inputs to packer CENTOS_BASE_IMAGE: "centos-7-v20180911" RHEL_BASE_IMAGE: "rhel-server-ec2-7-5-165-1" FEDORA_BASE_IMAGE: "fedora-cloud-base-28-1-1-7" UBUNTU_BASE_IMAGE: "ubuntu-1804-bionic-v20180911" + # low-level base VM image name inputs to packer + + # Command to register a RHEL VM + RHSM_COMMAND: ENCRYPTED[5caa5ff8c5370c3d25c7a1a28168501ab0fa2e5e3b627926f6eaba02b3fed965a7638a6151657809661f8c905c7dc187] + # Additional environment variables needed to build GCE images, within a GCE VM + SERVICE_ACCOUNT: ENCRYPTED[99e9a0b1c23f8dd29e83dfdf164f064cfd17afd9b895ca3b5e4c41170bd4290a8366fe2ad8e7a210b9f751711d1d002a] + GCE_SSH_USERNAME: ENCRYPTED[a7706b9e4b8bbb47f76358df7407f4fffa2e8552531190cc0b3315180c4b50588f560c4f85731e99cb5f43a396778277] + GCP_PROJECT_ID: ENCRYPTED[7c80e728e046b1c76147afd156a32c1c57d4a1ac1eab93b7e68e718c61ca8564fc61fef815952b8ae0a64e7034b8fe4f] + # Version of packer to use + PACKER_VER: "1.3.1" + gce_instance: image_name: "image-builder-image" # Simply CentOS 7 + packer dependencies diff --git a/contrib/cirrus/build_vm_images.sh b/contrib/cirrus/build_vm_images.sh index 8538ee910..80c689a6c 100755 --- a/contrib/cirrus/build_vm_images.sh +++ b/contrib/cirrus/build_vm_images.sh @@ -13,7 +13,7 @@ UBUNTU_BASE_IMAGE $UBUNTU_BASE_IMAGE FEDORA_BASE_IMAGE $FEDORA_BASE_IMAGE RHEL_BASE_IMAGE $RHEL_BASE_IMAGE RHSM_COMMAND $RHSM_COMMAND -CIRRUS_BUILD_ID $CIRRUS_BUILD_ID +BUILT_IMAGE_SUFFIX $BUILT_IMAGE_SUFFIX SERVICE_ACCOUNT $SERVICE_ACCOUNT GCE_SSH_USERNAME $GCE_SSH_USERNAME GCP_PROJECT_ID $GCP_PROJECT_ID diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index e69f1e040..1b61fd5ec 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -35,8 +35,11 @@ req_env_var() { # and useful variables. # ref: https://cirrus-ci.org/guide/writing-tasks/#environment-variables show_env_vars() { + # This is almost always multi-line, print it separately + echo "export CIRRUS_CHANGE_MESSAGE=$CIRRUS_CHANGE_MESSAGE" echo " BUILDTAGS $BUILDTAGS +BUILT_IMAGE_SUFFIX $BUILT_IMAGE_SUFFIX CI $CI CIRRUS_CI $CIRRUS_CI CI_NODE_INDEX $CI_NODE_INDEX @@ -47,7 +50,6 @@ CIRRUS_BASE_SHA $CIRRUS_BASE_SHA CIRRUS_BRANCH $CIRRUS_BRANCH CIRRUS_BUILD_ID $CIRRUS_BUILD_ID CIRRUS_CHANGE_IN_REPO $CIRRUS_CHANGE_IN_REPO -CIRRUS_CHANGE_MESSAGE $CIRRUS_CHANGE_MESSAGE CIRRUS_CLONE_DEPTH $CIRRUS_CLONE_DEPTH CIRRUS_DEFAULT_BRANCH $CIRRUS_DEFAULT_BRANCH CIRRUS_PR $CIRRUS_PR @@ -66,6 +68,7 @@ CIRRUS_USER_PERMISSION $CIRRUS_USER_PERMISSION CIRRUS_WORKING_DIR $CIRRUS_WORKING_DIR CIRRUS_HTTP_CACHE_HOST $CIRRUS_HTTP_CACHE_HOST $(go env) +PACKER_BUILDS $PACKER_BUILDS " | while read NAME VALUE do [[ -z "$NAME" ]] || echo "export $NAME=\"$VALUE\"" diff --git a/contrib/cirrus/packer/libpod_images.json b/contrib/cirrus/packer/libpod_images.json index 82a41ca25..ec2641282 100644 --- a/contrib/cirrus/packer/libpod_images.json +++ b/contrib/cirrus/packer/libpod_images.json @@ -15,7 +15,7 @@ "SERVICE_ACCOUNT": "{{env `SERVICE_ACCOUNT`}}", "GCP_PROJECT_ID": "{{env `GCP_PROJECT_ID`}}", - "CIRRUS_BUILD_ID": "{{env `CIRRUS_BUILD_ID`}}", + "BUILT_IMAGE_SUFFIX": "{{env `BUILT_IMAGE_SUFFIX`}}", "GCE_SSH_USERNAME": "{{env `GCE_SSH_USERNAME`}}", "RHSM_COMMAND": "{{env `RHSM_COMMAND`}}" }, @@ -29,7 +29,7 @@ "project_id": "{{user `GCP_PROJECT_ID`}}", "zone": "us-central1-a", "source_image": "{{user `RHEL_BASE_IMAGE`}}", - "image_name": "{{user `RHEL_BASE_IMAGE`}}-libpod-{{user `CIRRUS_BUILD_ID`}}", + "image_name": "{{user `RHEL_BASE_IMAGE`}}{{user `BUILT_IMAGE_SUFFIX`}}", "image_family": "{{user `RHEL_BASE_IMAGE`}}-libpod", "service_account_email": "{{user `SERVICE_ACCOUNT`}}", "communicator": "ssh", @@ -41,7 +41,7 @@ "project_id": "{{user `GCP_PROJECT_ID`}}", "zone": "us-central1-a", "source_image": "{{user `CENTOS_BASE_IMAGE`}}", - "image_name": "{{user `CENTOS_BASE_IMAGE`}}-libpod-{{user `CIRRUS_BUILD_ID`}}", + "image_name": "{{user `CENTOS_BASE_IMAGE`}}{{user `BUILT_IMAGE_SUFFIX`}}", "image_family": "{{user `CENTOS_BASE_IMAGE`}}-libpod", "service_account_email": "{{user `SERVICE_ACCOUNT`}}", "communicator": "ssh", @@ -53,7 +53,7 @@ "project_id": "{{user `GCP_PROJECT_ID`}}", "zone": "us-central1-a", "source_image": "{{user `FEDORA_BASE_IMAGE`}}", - "image_name": "{{user `FEDORA_BASE_IMAGE`}}-libpod-{{user `CIRRUS_BUILD_ID`}}", + "image_name": "{{user `FEDORA_BASE_IMAGE`}}{{user `BUILT_IMAGE_SUFFIX`}}", "image_family": "{{user `FEDORA_BASE_IMAGE`}}-libpod", "service_account_email": "{{user `SERVICE_ACCOUNT`}}", "communicator": "ssh", @@ -65,7 +65,7 @@ "project_id": "{{user `GCP_PROJECT_ID`}}", "zone": "us-central1-a", "source_image": "{{user `UBUNTU_BASE_IMAGE`}}", - "image_name": "{{user `UBUNTU_BASE_IMAGE`}}-libpod-{{user `CIRRUS_BUILD_ID`}}", + "image_name": "{{user `UBUNTU_BASE_IMAGE`}}{{user `BUILT_IMAGE_SUFFIX`}}", "image_family": "{{user `UBUNTU_BASE_IMAGE`}}-libpod", "service_account_email": "{{user `SERVICE_ACCOUNT`}}", "communicator": "ssh", diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index 2302f0e15..167db127f 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -41,6 +41,7 @@ then "export OS_RELEASE_ID=\"$(os_release_id)\"" \ "export OS_RELEASE_VER=\"$(os_release_ver)\"" \ "export OS_REL_VER=\"${OS_RELEASE_ID}-${OS_RELEASE_VER}\"" \ + "export BUILT_IMAGE_SUFFIX=\"-$CIRRUS_REPO_NAME-${CIRRUS_CHANGE_IN_REPO:0:8}\"" \ "export GOPATH=\"/go\"" \ 'export PATH="$HOME/bin:$GOPATH/bin:/usr/local/bin:$PATH"' \ 'export LD_LIBRARY_PATH="/usr/local/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"' |