Refactor creating GCP disks (#8330)
This commit is contained in:
parent
58bfe974e1
commit
6a6f2865d3
|
@ -194,11 +194,9 @@ jobs:
|
||||||
PREFER_MAIN_CACHED_STATE: ${{ inputs.prefer_main_cached_state }}
|
PREFER_MAIN_CACHED_STATE: ${{ inputs.prefer_main_cached_state }}
|
||||||
run: |
|
run: |
|
||||||
source ./.github/workflows/scripts/gcp-get-cached-disks.sh
|
source ./.github/workflows/scripts/gcp-get-cached-disks.sh
|
||||||
echo "cached_disk_name=${CACHED_DISK_NAME}" >> "${GITHUB_OUTPUT}"
|
|
||||||
echo "STATE_VERSION=${LOCAL_STATE_VERSION}" >> "${GITHUB_ENV}"
|
echo "STATE_VERSION=${LOCAL_STATE_VERSION}" >> "${GITHUB_ENV}"
|
||||||
echo "CACHED_DISK_NAME=${CACHED_DISK_NAME}" >> "${GITHUB_ENV}"
|
echo "CACHED_DISK_NAME=${CACHED_DISK_NAME}" >> "${GITHUB_ENV}"
|
||||||
echo "DISK_OPTION=image=$CACHED_DISK_NAME," >> "${GITHUB_ENV}"
|
echo "cached_disk_name=${CACHED_DISK_NAME}" >> "${GITHUB_OUTPUT}"
|
||||||
|
|
||||||
|
|
||||||
# Create a Compute Engine virtual machine and attach a cached state disk using the
|
# Create a Compute Engine virtual machine and attach a cached state disk using the
|
||||||
# $CACHED_DISK_NAME variable as the source image to populate the disk cached state
|
# $CACHED_DISK_NAME variable as the source image to populate the disk cached state
|
||||||
|
@ -207,12 +205,17 @@ jobs:
|
||||||
id: create-instance
|
id: create-instance
|
||||||
shell: /usr/bin/bash -x {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
|
NAME="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}"
|
||||||
|
DISK_PARAMS="size=400GB,type=pd-ssd,name=${NAME},device-name=${NAME}"
|
||||||
|
if [ -n "${{ env.CACHED_DISK_NAME }}" ]; then
|
||||||
|
DISK_PARAMS+=",image=${{ env.CACHED_DISK_NAME }}"
|
||||||
|
fi
|
||||||
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
||||||
--boot-disk-size 50GB \
|
--boot-disk-size 50GB \
|
||||||
--boot-disk-type pd-ssd \
|
--boot-disk-type pd-ssd \
|
||||||
--image-project=cos-cloud \
|
--image-project=cos-cloud \
|
||||||
--image-family=cos-stable \
|
--image-family=cos-stable \
|
||||||
--create-disk=${DISK_OPTION}name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=400GB,type=pd-ssd \
|
--create-disk="${DISK_PARAMS}" \
|
||||||
--container-image=gcr.io/google-containers/busybox \
|
--container-image=gcr.io/google-containers/busybox \
|
||||||
--machine-type ${{ vars.GCP_LARGE_MACHINE }} \
|
--machine-type ${{ vars.GCP_LARGE_MACHINE }} \
|
||||||
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
||||||
|
|
Loading…
Reference in New Issue