Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ start_benchmarking_runs() {
fi

# Read the CSV file line by line, skipping the header
tail -n +2 "$fio_job_cases" | while IFS=, read -r bs file_size iodepth iotype threads nrfiles; do
while IFS=, read -r bs file_size iodepth iotype threads nrfiles || [[ -n "$nrfiles" ]]; do
# Iterate for the specified number of runs for this job case
nrfiles="${nrfiles%$'\r'}"

Expand Down Expand Up @@ -508,7 +508,7 @@ start_benchmarking_runs() {
sleep 20

done
done
done < <(tail -n +2 "$fio_job_cases")


}
Expand Down
16 changes: 14 additions & 2 deletions gcsfuse-micro-benchmarking/helpers/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ def create_vm_if_not_exists(vm_details, zone, project):
return None

def is_running_on_gce():
"""Checks if the script is running on a GCE VM."""
"""
Checks if the script is running on a GCE VM *on the same network*.
Returns False for Cloudtop/Corp workstations to force External IP/IAP usage.
"""
# 1. CRITICAL: Check for Corporate Environment (Cloudtop)
# Cloudtops reside on a different VPC and cannot use --internal-ip
# to reach project VMs. We detect them by their unique home directory path.
if os.path.exists("/usr/local/google/home"):
print("Debug: Detected Cloudtop environment. Forcing External/IAP connection.")
return False

# 2. Standard GCE Metadata Check
try:
response = requests.get(
"http://metadata.google.internal/computeMetadata/v1/instance/",
Expand All @@ -100,13 +111,14 @@ def wait_for_ssh(vm_name, zone, project, retries=15, delay=20):
'gcloud', 'compute', 'ssh', vm_name,
f'--zone={zone}', f'--project={project}',
'--quiet', # Suppress interactive prompts
'--', 'echo "SSH ready"'
]
if is_running_on_gce():
print("Detected environment: GCE VM. Using internal IP.")
ssh_cmd.append('--internal-ip')
ssh_cmd.extend(['--', '-vvv', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', 'echo "SSH ready"'])
else:
print("Detected environment: Cloudtop/External. Using default (External IP).")
ssh_cmd.extend(['--', 'echo "SSH ready"'])

print(f"Waiting for VM '{vm_name}' to become SSH-ready...")
for i in range(retries):
Expand Down
4 changes: 2 additions & 2 deletions gcsfuse-micro-benchmarking/resources/starter_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ start_benchmarking_runs() {
fi

# Read the CSV file line by line, skipping the header
tail -n +2 "$fio_job_cases" | while IFS=, read -r bs file_size iodepth iotype threads nrfiles; do
while IFS=, read -r bs file_size iodepth iotype threads nrfiles || [[ -n "$nrfiles" ]]; do
# Iterate for the specified number of runs for this job case
# Mount the bucket once before the loop if reuse_same_mount is 'true'
if [[ "$reuse_same_mount" == "true" ]]; then
Expand Down Expand Up @@ -522,7 +522,7 @@ start_benchmarking_runs() {
if [[ "$reuse_same_mount" == "true" ]]; then
unmount_gcsfuse "$mntdir"
fi
done
done < <(tail -n +2 "$fio_job_cases")


}
Expand Down