1
---
2
name: google-cloud-filestore-log-troubleshooting
3
metadata:
4
version: "1.0.2"
5
category: Storage
6
description: >-
7
Diagnoses and resolves Filestore client mount failures on Google Cloud,
8
permission errors (EACCES), and network timeouts (ETIMEDOUT). Use when an NFS
9
mount hangs or fails from a Compute Engine VM, GKE pod, Cloud Run service, or
10
Vertex AI workload, when `mount.nfs` reports "Connection timed out" or "access
11
denied by server", when checking whether VPC ingress firewall rules or
12
`nfsExportOptions` allow a client IP, or when a previously working Filestore
13
share suddenly stops mounting after an administrative change. Don't use for
14
Cloud Storage (GCS) buckets, Persistent Disk, or Cloud NetApp Volumes, and
15
don't use for Filestore capacity scaling or backup and export-policy auditing.
16
---
17
18
<!-- disableFinding(LINE_OVER_80) -->
19
20
# Filestore Log-Based Troubleshooting
21
22
Diagnoses, troubleshoots, and remediates Filestore client mount failures, permission errors (`EACCES`), and network timeouts (`ETIMEDOUT`) across projects.
23
24
## Prerequisites & Quick Start
25
26
Required IAM roles on target project(s) (and Shared VPC host project if applicable):
27
* **Read**: `roles/file.viewer` (instance & export ACLs), `roles/compute.networkViewer` (VPC firewall rules), `roles/logging.viewer` (Cloud Audit & GKE CSI logs), `roles/mcp.toolUser` (if using MCP tools).
28
* **Write (Remediation only)**: `roles/file.editor` (export ACL updates), `roles/compute.securityAdmin` (firewall rule creation).
29
30
Authenticate, verify billing/APIs, and configure your environment:
31
32
```bash
33
gcloud auth login && gcloud auth application-default login
34
gcloud billing projects describe {project_id} --format="value(billingEnabled)"
35
gcloud services enable file.googleapis.com compute.googleapis.com logging.googleapis.com --quiet
36
gcloud config set project {project_id} && gcloud config set compute/region {region}
37
```
38
39
## Usage Attribution
40
41
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
42
MUST read and follow the instructions in
43
[Usage Attribution](references/attribution.md).
44
45
## Conceptual & Informational Queries (CRITICAL)
46
47
For purely conceptual, architectural, or educational questions (e.g., "What causes EACCES on Filestore?", "Why does GKE Node IP appear instead of Pod IP?", "What ports does Filestore require?", "Explain root squash"):
48
* **Rule**: **Answer immediately using pre-trained knowledge and the workflow rules below.** Answering directly minimizes tool latency and token usage when the user only seeks architectural guidance.
49
* **Constraint**: **Do not execute external tool calls or API requests** for basic knowledge questions.
50
51
## Handling "No-Command" Constraints (CRITICAL)
52
53
If the user prompt contains constraints like "Do not execute commands", "without executing", or "read-only":
54
* **Rule**: **Strictly avoid calling `run_command`** to execute any shell, Python, or `gcloud` commands.
55
* **Discovery**:
56
1. Always read [Usage Attribution](references/attribution.md) first so every recommended `gcloud` command includes the required attribution environment variable.
57
2. Check if Filestore MCP tools (`get_instance`, `list_instances`) are available and use them (API calls, not command executions).
58
3. If MCP tools are unavailable, read `references/mock-fleet-data.md` **only if** the requested instance matches one of the evaluation scenarios (`finance-share`, `shared-nfs`, `ml-data`, `data-hub`, `prod-share`). Never report mock data as live production state. If the instance is not listed there, state that live access is required and provide the exact attributed commands for the user to run.
59
4. **Fast-Path Stop Rule**: Once you have read [Usage Attribution](references/attribution.md) and located the target instance in `references/mock-fleet-data.md`, **stop reading additional files immediately** and formulate your response with the attributed `gcloud` remediation command. Do **NOT** read `scripts/quick_diagnose.py`, `scripts/diagnose_lib.py`, `_internal/quick_diagnose_test.py`, or `EVAL.*` files when command execution is disabled, as inspecting code/test files wastes turns and triggers timeouts.
60
* **Mandatory User Confirmation Requirement**: Even when command execution is disabled or the user asks only for recommendations, your response **MUST STILL end with a clear question prompting the user for explicit confirmation** before applying any remediation (e.g., *"Would you like me to proceed with creating the VPC ingress firewall rule `[rule_name]`? Please confirm to proceed."*).
61
62
## Multi-Runtime Execution Options
63
64
### Option 1: Bundled Python CLI Script (Recommended for CLI / Terminal Agents)
65
66
```bash
67
# Single instance diagnosis
68
python3 scripts/quick_diagnose.py --instance="<INSTANCE_ID>" --location="<LOCATION_OR_ZONE>" \
69
[--project="<PROJECT_ID>"] [--client-ip="<CLIENT_IP>"] [--client-subnet="<CLIENT_SUBNET_CIDR>"]
70
71
# Bulk project-wide fleet diagnosis
72
python3 scripts/quick_diagnose.py --all --project="<PROJECT_ID>" [--json]
73
```
74
75
| Flag | Purpose |
76
| :--- | :--- |
77
| `--instance`, `--location` | Filestore instance ID and region/zone (`--zone` is a legacy alias). Required unless `--all`. |
78
| `--project` | GCP project ID (defaults to active `gcloud` project). |
79
| `--client-ip` / `--client-subnet` | Client IP or CIDR to evaluate against export ACLs and ingress firewall rules. |
80
| `--json` | Emit machine-readable JSON on stdout (narrative report goes to stderr). |
81
| `--apply-fix` | Execute generated remediation commands. **Only pass after explicit user confirmation.** |
82
83
### Option 2: Filestore MCP Tools / REST API / `gcloud` CLI
84
* **MCP Tools**: Call `get_instance(name='projects/{project_id}/locations/{location}/instances/{instance_id}')` and inspect `fileShares[0].nfsExportOptions` and `networks[0].network`.
85
* **Native REST API (`call_gcp_api`)**: Invoke `service="file"`, `version="v1"`, `resource_path="projects/{project_id}/locations/{location}/instances/{instance_id}"`.
86
* **Standard `gcloud`**:
87
```bash
88
gcloud filestore instances describe {instance_id} --location={location} --project={project_id} --format=json
89
```
90
91
--------------------------------------------------------------------------------
92
93
## Core Operational Workflow
94
95
### Step 1: Parameter Extraction & GKE Node Architecture
96
* Extract `instance`, `location` (region/zone), `project`, and `client_ip` / `client_subnet`. If target parameters are missing, list instances or ask the user to confirm.
97
* **GKE Architecture Rule**: PersistentVolumes are mounted by the Linux kernel on the **GKE Worker Node**, not inside the Pod network namespace. Even if Pod IPs (`10.4.0.0/14`) are allowlisted, the NFS server sees traffic originating from the **GKE Node Internal IP**. Always evaluate and allowlist the **GKE Node Subnet CIDR** in `nfsExportOptions` and VPC firewall rules.
98
99
### Step 2: Instance Metadata & Shared VPC Resolution
100
1. Verify instance `state` is `READY` (report state blocker if `CREATING`, `DELETING`, or `ERROR`).
101
2. Extract primary Filestore IP (`networks[0].ipAddresses[0]`) and VPC network URI.
102
3. If `networks[0].network` references `projects/{host_project}/global/networks/{network}`, resolve `{host_project}` as the Shared VPC host project for firewall queries.
103
104
### Step 3: Export ACL Evaluation (`EACCES` vs `EROFS`)
105
1. Inspect `fileShares[0].nfsExportOptions` (if empty, default `0.0.0.0/0` `READ_WRITE` `NO_ROOT_SQUASH` applies).
106
2. **`EACCES (Permission Denied by Server)`**: Triggered when the client IP or subnet CIDR is not covered by any `ipRanges` entry.
107
* **Remediation**: Non-destructively append the client IP/subnet CIDR to `nfsExportOptions`, preserving all existing export rules to avoid breaking active mounts.
108
3. **`EROFS (Read-only file system)`**: Triggered when `accessMode` is `READ_ONLY` but client writes are attempted.
109
110
### Step 4: VPC Ingress Firewall Inspection (`ETIMEDOUT`)
111
1. Query ingress firewall rules in the VPC network (in the host project if Shared VPC).
112
2. **`ETIMEDOUT (Connection Timed Out)`**: Triggered when priority-sorted ingress rules block or fail to allow TCP port `2049` (NFS) and TCP/UDP port `111` (rpcbind) from the client CIDR.
113
* **Remediation**: Create an ingress firewall rule (`ALLOW` `tcp:2049,udp:2049,tcp:111,udp:111`) from the client subnet CIDR.
114
115
### Step 5: Cloud Audit Logs & Configuration Drift Scanning
116
Query Cloud Audit Admin Activity logs (`file.googleapis.com`) over the past 24 hours to check if an `UpdateInstance` operation modified export ACLs or networks:
117
118
```bash
119
gcloud logging read 'logName="projects/{project_id}/logs/cloudaudit.googleapis.com%2Factivity" AND protoPayload.serviceName="file.googleapis.com" AND protoPayload.resourceName=~".*{instance}.*"' \
120
--project="{project_id}" --freshness="1d" --limit=5 --format="json"
121
```
122
123
* **Scope to Admin Activity**: Always include `cloudaudit.googleapis.com%2Factivity` in `logName` so read-only `GetInstance`/`ListInstances` calls (`data_access`) are not falsely flagged as administrative drift.
124
* **Drift is Informational**: Recent `UpdateInstance` events explain *when* and *by whom* (`principalEmail`, `timestamp`) configuration changed, but only a failed export ACL or firewall check constitutes a mount blocker.
125
* **Single Bulk Query Rule**: When scanning multiple instances (`--all`), issue a single project-wide audit log query rather than per-instance queries in a loop.
126
* **GKE CSI Driver Logs**: Optionally inspect `resource.labels.container_name="gcp-filestore-driver"` (`severity>=ERROR`) for client-side mount errors.
127
128
--------------------------------------------------------------------------------
129
130
## Output Format & Mandatory Confirmation Gate
131
132
Every diagnostic report MUST include a structured summary table and root cause analysis:
133
134
````markdown
135
### Filestore Diagnostic Report: `[instance-name]`
136
137
| Parameter | Value |
138
| :--- | :--- |
139
| **Instance ID** | `[instance-name]` (`[location]`, Tier: `[tier]`, State: `READY`) |
140
| **Filestore IP & Network** | `[filestore-ip]` on VPC `[network-name]` (Host Project: `[host-project]`) |
141
| **Port 2049 & Export ACL** | Port 2049: `OPEN / BLOCKED` \| Export ACL: `PASS / REJECTED` |
142
| **Diagnostic Verdict** | **HEALTHY** or **BLOCKED: [Root Cause]** |
143
144
#### Root Cause Analysis & Recommended Remediation
145
- [Explanation of ETIMEDOUT (missing firewall rule on port 2049) vs EACCES (missing export ACL rule) and any recent UpdateInstance audit drift]
146
147
```bash
148
gcloud compute firewall-rules create ...
149
```
150
````
151
152
### Interactive Remediation Confirmation Gate (MANDATORY)
153
* **NEVER execute write or remediation commands without explicit user confirmation.**
154
* Always conclude your response with an explicit confirmation question:
155
> *"Would you like me to proceed with executing this remediation command for you? Please confirm to proceed."*
156
157
## References & Bundled Scripts
158
* [Usage Attribution](references/attribution.md)
159
* [Error Signatures & Architecture Matrix](references/error-signatures.md)
160
* [Cloud Logging & Audit Drift Queries](references/logging-and-audit-queries.md)
161
* [VPC Network & Firewall Specification](references/network-firewall-spec.md)
162
* [Mock Fleet Data for Evaluations](references/mock-fleet-data.md)
163
* `scripts/quick_diagnose.py` & `scripts/diagnose_lib.py`: Zero-dependency CLI runner and pure-Python evaluation engine.
164