diff --git a/docker/base/setup_clusterfuzz.sh b/docker/base/setup_clusterfuzz.sh index ec67c0f041f..96a770ac8d8 100644 --- a/docker/base/setup_clusterfuzz.sh +++ b/docker/base/setup_clusterfuzz.sh @@ -28,6 +28,7 @@ fi if [[ "$IMMUTABLE_IMAGE" == "true" ]]; then echo "Not downloading Clusterfuzz source code as it is an immutable image" + ln -s /data/clusterfuzz $INSTALL_DIRECTORY/ else CLUSTERFUZZ_FILE=clusterfuzz_package.zip # When $LOCAL_SRC is set, use source zip on mounted volume for local testing. diff --git a/docker/build-immutable.sh b/docker/build-immutable.sh index d91ea2414be..ddbf17a3230 100755 --- a/docker/build-immutable.sh +++ b/docker/build-immutable.sh @@ -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)" # Determine the directory containing the Dockerfile and related build context. project_dir=docker/${image_name#gcr.io/clusterfuzz-images/} diff --git a/docker/immutable-cloudbuild.yaml b/docker/immutable-cloudbuild.yaml index 2823321bfa4..66fb17c51aa 100644 --- a/docker/immutable-cloudbuild.yaml +++ b/docker/immutable-cloudbuild.yaml @@ -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 @@ -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 diff --git a/src/clusterfuzz/_internal/system/environment.py b/src/clusterfuzz/_internal/system/environment.py index 6618a011907..6b37b662978 100644 --- a/src/clusterfuzz/_internal/system/environment.py +++ b/src/clusterfuzz/_internal/system/environment.py @@ -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. diff --git a/src/python/bot/startup/run.py b/src/python/bot/startup/run.py index 0cd1a07cc2b..7e031b0734b 100644 --- a/src/python/bot/startup/run.py +++ b/src/python/bot/startup/run.py @@ -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()