Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions docker/base/setup_clusterfuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fi

if [[ "$IMMUTABLE_IMAGE" == "true" ]]; then
echo "Not downloading Clusterfuzz source code as it is an immutable image"
cp -r /data/clusterfuzz $INSTALL_DIRECTORY/.
else
CLUSTERFUZZ_FILE=clusterfuzz_package.zip
# When $LOCAL_SRC is set, use source zip on mounted volume for local testing.
Expand Down
4 changes: 2 additions & 2 deletions docker/build-immutable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ rm -rf src/appengine/config

# Loop through each image name in the IMAGES array.
for image_name in "${IMAGES[@]}"; do
# Read the ClusterFuzz revision from the revision.txt file. This is used to
# Read the ClusterFuzz revision from the clusterfuzz-source.manifest file. This is used to
# tag the Docker images.
CURRENT_CLUSTERFUZZ_REVISION="$(cat /workspace/revision.txt)"
CURRENT_CLUSTERFUZZ_REVISION="$(cat src/appengine/resources/clusterfuzz-source.manifest)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Maybe use a global var to set the manifest filename?


# Determine the directory containing the Dockerfile and related build context.
project_dir=docker/${image_name#gcr.io/clusterfuzz-images/}
Expand Down
5 changes: 3 additions & 2 deletions docker/immutable-cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ steps:
git clone https://github.com/google/clusterfuzz.git
cd clusterfuzz
git checkout "${_CLUSTERFUZZ_REVISION}"
cp -r /workspace/clusterfuzz-config .
else
echo "☑️ _CLUSTERFUZZ_REVISION is not set. Using the latest commit."
fi
Expand All @@ -74,11 +75,11 @@ steps:

# Using the builder service account as the user
RAW_USER=$(gcloud auth list --filter=status:ACTIVE --format="value(account)")
USER=$(echo "$$RAW_USER" | cut -d'@' -f1)
USER=$(echo "$$RAW_USER" | cut -d'@' -f1 | sed 's/-compute//')

REVISION="$${TIMESTAMP}-$${CF_SHA}-$${USER}-$${CF_CONFIG_SHA}-prod"
echo "Computed revision: $${REVISION}"
echo "$${REVISION}" > /workspace/revision.txt
echo "$${REVISION}" > src/appengine/resources/clusterfuzz-source.manifest

- id: build immutable image
name: gcr.io/cloud-builders/docker
Expand Down
4 changes: 4 additions & 0 deletions src/clusterfuzz/_internal/system/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,10 @@ def is_tworker():
return get_value('TWORKER', False)


def is_immutable_instance():
return get_value('IMMUTABLE_IMAGE', False)


def update_task_enabled() -> bool:
""" It uses the GCE VM metadata server `update_task_enabled` flag.

Expand Down
3 changes: 3 additions & 0 deletions src/python/bot/startup/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def stop_android_heartbeat():

def update_source_code_if_needed():
"""Update source code if needed."""
if environment.is_immutable_instance():
logs.info("This is an immutable image, not updating source code.")
return
try:
# Update the bot source, if there's a newer version.
newer_source_revision = update_task.get_newer_source_revision()
Expand Down
Loading