Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudbuild/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ COPY --chown=ia-tests:ia-tests . /init-actions
# https://docs.bazel.build/versions/master/install-ubuntu.html
RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
RUN apt-get update && apt-get install -y openjdk-8-jdk python3-setuptools bazel
RUN apt-get update && apt-get install -y openjdk-8-jdk python3-setuptools bazel gettext-base

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems fine. I don't see it being used below, but perhaps the kubectl apply depends on this for translation. Can you share why we included this package?


USER ia-tests
174 changes: 87 additions & 87 deletions cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ steps:
id: 'gcr-push'
args: ['push', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID']

# Run presubmit tests in parallel for 1.5 Debian image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.5-debian10-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-debian10']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 1.5 Rocky Linux image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.5-rocky8-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-rocky8']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 1.5 Ubuntu image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.5-ubuntu18-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-ubuntu18']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# # Run presubmit tests in parallel for 1.5 Debian image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the previous/next two comments. leave comments for one PR and remove them in the next to reduce file size and execution time.

# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-1.5-debian10-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-debian10']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
# # Run presubmit tests in parallel for 1.5 Rocky Linux image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-1.5-rocky8-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-rocky8']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
# # Run presubmit tests in parallel for 1.5 Ubuntu image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-1.5-ubuntu18-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.5-ubuntu18']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
# Run presubmit tests in parallel for 2.0 Debian image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.0-debian10-tests'
Expand All @@ -53,60 +53,60 @@ steps:
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 2.0 Rocky Linux image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.0-rocky8-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.0-rocky8']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 2.0 Ubuntu image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.0-ubuntu18-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.0-ubuntu18']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 2.1 Debian image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.1-debian11-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-debian11']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 2.1 Rocky Linux image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.1-rocky8-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-rocky8']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 2.1 Ubuntu image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-2.1-ubuntu20-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-ubuntu20']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
# # Run presubmit tests in parallel for 2.0 Rocky Linux image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, leave the comments for posterity for one release and then remove them to reduce file size and execution time

# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-2.0-rocky8-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.0-rocky8']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
# # Run presubmit tests in parallel for 2.0 Ubuntu image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-2.0-ubuntu18-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.0-ubuntu18']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
## Run presubmit tests in parallel for 2.1 Debian image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-2.1-debian11-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-debian11']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
## Run presubmit tests in parallel for 2.1 Rocky Linux image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-2.1-rocky8-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-rocky8']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'
#
## Run presubmit tests in parallel for 2.1 Ubuntu image
# - name: 'gcr.io/cloud-builders/kubectl'
# id: 'dataproc-2.1-ubuntu20-tests'
# waitFor: ['gcr-push']
# entrypoint: 'bash'
# args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '2.1-ubuntu20']
# env:
# - 'COMMIT_SHA=$COMMIT_SHA'
# - 'CLOUDSDK_COMPUTE_REGION=us-central1'
# - 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Delete Docker image from GCR
- name: 'gcr.io/cloud-builders/gcloud'
Expand Down
37 changes: 37 additions & 0 deletions cloudbuild/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: {{IMAGE_NAME}}
name: {{IMAGE_NAME}}
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: {{IMAGE_NAME}}
template:
metadata:
labels:
app: {{IMAGE_NAME}}
spec:
containers:
- command:
- bash
- /init-actions/cloudbuild/presubmit.sh
env:
- name: COMMIT_SHA
value: {{COMMIT_SHA}}
- name: IMAGE_VERSION
value: {{IMAGE_VERSION}}
name: {{IMAGE_NAME}}
image: {{IMAGE_BUILD_ID}}
resources:
limits:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
requests:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
24 changes: 17 additions & 7 deletions cloudbuild/run-presubmit-on-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ gcloud container clusters get-credentials "${CLOUDSDK_CONTAINER_CLUSTER}"

LOGS_SINCE_TIME=$(date --iso-8601=seconds)

kubectl run "${POD_NAME}" \
--image="${IMAGE}" \
--requests='cpu=750m,memory=2Gi,ephemeral-storage=2Gi' \
--restart=Never \
--env="COMMIT_SHA=${COMMIT_SHA}" \
--env="IMAGE_VERSION=${DATAPROC_IMAGE_VERSION}" \
--command -- bash /init-actions/cloudbuild/presubmit.sh
#kubectl run "${POD_NAME}" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this old command in the previous commit in the main branch. Thank you for preserving the previous implementation in comments. I loathe the concept of removing the old implementation as well. We could leave this comment in for the next release for posterity and then remove them to reduce file size and execution time.

# --image="${IMAGE}" \
# --restart=Never \
# --env="COMMIT_SHA=${COMMIT_SHA}" \
# --env="IMAGE_VERSION=${DATAPROC_IMAGE_VERSION}" \
# --command -- bash /init-actions/cloudbuild/presubmit.sh
export IMAGE_NAME=${POD_NAME}
export COMMIT_SHA=${COMMIT_SHA}
export IMAGE_VERSION=${DATAPROC_IMAGE_VERSION}
export IMAGE_BUILD_ID=${BUILD_ID}
export IMAGE_BUILD_ID=gcr.io/cloud-dataproc-ci/init-actions-image:${BUILD_ID}

template=`cat cloudbuild/deployment.yaml | sed "s/{{IMAGE_NAME}}/${IMAGE_NAME}/g;s/{{COMMIT_SHA}}/${COMMIT_SHA}/g;s/{{IMAGE_VERSION}}/${IMAGE_VERSION}/g;s|{{IMAGE_BUILD_ID}}|${IMAGE_BUILD_ID}|g" `
echo "$template"

echo "$template" | kubectl apply -f -

# Delete POD on exit and describe it before deletion if exit was unsuccessful
trap '[[ $? != 0 ]] && kubectl describe "pod/${POD_NAME}"; kubectl delete pods "${POD_NAME}"' EXIT
Expand All @@ -30,6 +39,7 @@ while ! kubectl describe "pod/${POD_NAME}" | grep -q Terminated; do
LOGS_SINCE_TIME=$(date --iso-8601=seconds)
done


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this new newline is probably not necessary

EXIT_CODE=$(kubectl get pod "${POD_NAME}" \
-o go-template="{{range .status.containerStatuses}}{{.state.terminated.exitCode}}{{end}}")

Expand Down