Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install google-cloud-filestore-autoscale@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin google-cloud-filestore-autoscale v1.0.0 follows the Agent Plugins spec.
gh skills-hub install google-cloud-filestore-autoscale Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/google-cloud-filestore-autoscale/ Extract the ZIP to .github/skills/ in your repo. The folder name must match google-cloud-filestore-autoscale for Copilot to auto-discover it.
Skill Files (5)
SKILL.md 13.2 KB
---
name: google-cloud-filestore-autoscale
metadata:
version: "1.0.3"
category: Storage
description: >-
Inspects Filestore capacity and utilization on Google Cloud, evaluates storage
scaling rules, and performs capacity autoscaling (scale UP for low free space
or scale DOWN for cost optimization). Use when monitoring Filestore instance
headroom, resizing instance shares, configuring automated growth/shrink
thresholds (custom thresholds apply globally across projects in session memory),
or preventing out-of-space outages. Don't use for Cloud Storage (GCS) buckets,
Persistent Disk block storage, or NetApp Volumes.
---
# Filestore Autoscale
This skill enables agents to inspect, evaluate, and modify Filestore
instance capacities across Google Cloud projects based on configured
thresholds.
## Prerequisites / IAM Requirements
Before an agent or user can execute this skill, their runtime Service Account
must possess the following IAM roles on the target project(s):
- **`roles/file.editor`** (Required for listing instances and triggering scale
up/down updates)
- **`roles/monitoring.viewer`** (Required for reading Cloud Monitoring
capacity metrics `used_bytes`)
- **`roles/mcp.toolUser`** (Required if utilizing backend Filestore MCP tools)
## Quick Start
1. Ensure `gcloud` is installed. See
[gcloud installation guide](https://cloud.google.com/sdk/docs/install) if
needed.
2. Enable essential APIs:
```bash
gcloud services enable file.googleapis.com monitoring.googleapis.com --quiet
```
3. Inspect fleet capacity and free space (see "Discovery & Read Operations"
below).
4. Evaluate against configured up/down capacity thresholds.
5. Scale target instances and apply attribution tags.
## Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read and follow the instructions in
[Usage Attribution](references/attribution.md).
## Conceptual & Informational Queries (CRITICAL)
For purely conceptual, educational, or informational questions (e.g., "What are Filestore scaling limits?",
"Can Basic instances scale down?", "Explain Filestore Tiers"):
* **Rule**: **Answer immediately using your pre-trained knowledge and the matrix below.**
* **Constraint**: **Do not execute external tool calls or API requests** for basic knowledge questions.
## Handling "No-Command" Constraints (CRITICAL)
If the user prompt contains constraints like "Do not execute commands", "without executing", or "read-only":
* **Rule**: **Strictly avoid calling the `run_command` tool** to execute any
shell, `gcloud`, or code search (`cs`) commands (including read-only
list/describe commands).
* **Discovery**:
1. Whenever outputting or recommending a `gcloud` command (including when
evaluating instance values provided directly in the user prompt), read
[Usage Attribution](references/attribution.md) first so the command
includes the required attribution prefix; do not search for additional
unrelated files when instance tier, capacity, and utilization are
already in the prompt.
2. Otherwise, check if Filestore MCP tools (`list_instances`,
`get_instance`) are available and use them (these are API calls, not
command executions).
3. If MCP tools are not available, check
`references/instance-tiers-specs.md` for any mock instance definitions
or project details matching the request. (Do NOT run repository-wide
searches or attempt to read evaluation config files such as `EVAL.yaml`
or `EVAL.txtpb` during evaluation runs as access is restricted).
4. If no data can be found, explain the required steps and formulas, and
output the attributed `gcloud` terminal commands for the user to confirm
and run, without executing them yourself.
* **Mandatory User Confirmation Requirement**: Even when the user prompt asks not to execute commands or asks only for command syntax/recommendations, your response MUST STILL end with a clear question prompting the user for confirmation before executing any capacity resizing commands (e.g., *"Would you like me to proceed with scaling `[instance]` from [A] TiB to [B] TiB? Please confirm to execute."*).
## Tier & Capacity Limits Matrix
Filestore tiers enforce specific boundaries and behaviors. The skill must accept both modern UI names (`Basic`, `Zonal`, `Regional`) and legacy API enums interchangeably.
See `references/instance-tiers-specs.md` for the full Tier & Capacity Limits Matrix (Min/Max capacities, step increments).
**Critical Thresholds:**
- **Basic HDD / Basic SSD**: Can scale up, but **cannot scale down**.
- **Zonal / Regional**: Can scale down, but cannot shrink below their minimum
floor (100 GiB for Regional Small Band, 1 TiB for Zonal Small Band, or 10 TiB
for Large Band) AND cannot shrink below current `used_bytes`.
## Core Operational Workflow
### 1. Discovery & Read Operations
- **Step 1 (Fleet Discovery)**: Call the MCP tool
`list_instances(parent='projects/{project_id}/locations/-')` or CLI `gcloud
filestore instances list --project={project_id}` to discover all Filestore
instances in the target project. Read the `capacityGb` and `tier` directly
from the instances returned.
- **Step 2 (Single Bulk Utilization Metric Query)**: Immediately after
discovering instances, query the Cloud Monitoring API for the
`file.googleapis.com/nfs/server/used_bytes` metric across the entire project
in a single request (see `references/monitoring-metrics.md` for
runtime-specific options including GCP REST API, `gcloud`, `curl`, and MCP
tools).
**CRITICAL**: Make exactly ONE bulk metric request for the entire project.
**NEVER emit multiple per-instance queries or loops.** Do NOT filter by zone
or region.
- **Step 3 (Metric Extraction & Calculation)**:
- Match each instance's short name (or `resource.labels.instance_name` /
`metric.labels.instance_name`) in the returned `timeSeries` data to
extract its latest `int64Value` bytes.
- If an instance is not listed in `timeSeries` or has no points, default
its `used_bytes` to 0.
- Calculate `used_bytes_gb = used_bytes / (1024^3)`.
- Calculate `Free Space % = ((capacityGb - used_bytes_gb) / capacityGb) *
100`.
- NEVER leave `Used Bytes` or `Free Space %` as "N/A". Populate actual
numbers into the output summary table.
### 2. Autoscale Needed Matrix
The skill must categorize each evaluated instance into one of 5 definitive verdicts. On the initial analysis/fleet inspection run, the skill suggests the required scaling action with target capacity and update commands, and **prompts for user confirmation before executing any autoscale modifications**. State the value of the "Autoscale Needed" column clearly as one of the following:
- **Yes (Scale Up)**: Triggered when free space percentage is below the
scale-up safety threshold (< 15% free space remaining). The evaluation
response MUST explicitly state that the current free space percentage is
below the 15% scale-up safety threshold. Capacity must be increased by 10%
(default) or step-size minimum, rounded to the tier's step increment (1 GiB
for Regional Small Band [100 GiB-10,239 GiB] or Basic, 256 GiB for Zonal
Small Band [1-9.75 TiB] or Enterprise [1-10 TiB],
2.5 TiB for Large Band [10-100 TiB],
as specified in `references/instance-tiers-specs.md`), not exceeding the
maximum capacity. Always explicitly state the calculated target capacity in
**both TiB and GiB** (for example, for a 1 TiB [1024 GiB] Basic instance
increased by +10%, explicitly state `1.1 TiB` alongside its 1 GiB
step-aligned equivalent `1126 GiB` / `1127 GiB`). Suggest target capacity,
provide the attributed `gcloud`
update command, and MUST conclude the response with a clear question
prompting the user for confirmation to execute (e.g., *"Would you like me to
proceed with scaling `[instance]` from [A] TiB to [B] TiB? Please confirm to
execute."*).
- **Yes (Scale Down)**: Triggered when free space exceeds the scale-down
threshold (> 30% free space remaining) and the instance is eligible for
downscaling (Zonal or Regional / Enterprise tiers). Apply the default step
reduction of -10% of current capacity, aligned to the tier's step increment
(1 GiB for Regional Small Band [100 GiB-10,239 GiB], 256 GiB for Zonal
Small Band [1-9.75 TiB] or Enterprise [1-10 TiB],
2.5 TiB for Large Band [10-100 TiB],
as specified in `references/instance-tiers-specs.md`). For example, for a
2 TiB (2048 GiB) Enterprise / Zonal Small Band instance, rounding to the
256 GiB step yields a proposed target capacity of 1.75 TiB (1792 GiB, or
1.8 TiB). The response MUST explicitly verify that the proposed target
capacity (e.g. 1.75 TiB / 1792 GiB or 1.8 TiB) remains strictly above both
the tier's minimum capacity floor (100 GiB for Regional Small Band, 1 TiB
for Zonal Small Band / Enterprise, or 10 TiB for Large Band) and currently
used space (e.g. 0.9 TiB). Do NOT reduce directly to the floor in a single
step. Suggest target capacity, estimated cost savings, provide the
attributed `gcloud` update command, and prompt the user for confirmation to
execute.
- **No (Healthy)**: Triggered when the instance's free space is within the
optimal operating range (15% – 30%). No action required.
- **No (At min capacity limit)**: Triggered when free space is > 30%, but the
instance is already at the minimum allowed tier capacity floor (100 GiB for
Regional Small Band, 1 TiB for Zonal Small Band / Enterprise, or 10 TiB for
Large Band) or currently used space limit. No action can be taken.
- **No (Tier cannot scale down)**: Triggered when free space is > 30%, but the
instance is on a Basic tier (Basic HDD / Basic SSD) which does not support
downscaling. The agent must explicitly inform the user that scale-down is
not supported and suggest data migration instead. No action can be taken.
### Output Format
**Every status report, evaluation, or recommendation response MUST include a markdown table summarizing the evaluated instances.** Even if evaluating a single instance, format it as a table.
The table MUST contain the following columns:
* `Instance`
* `Service Tier`
* `Provisioned Capacity`
* `Used Bytes`
* `Free Space %`
* `Autoscale Needed` (MUST contain one of: `Yes (Scale Up)`, `Yes (Scale Down)`, `No (Healthy)`, `No (At min capacity limit)`, or `No (Tier cannot scale down)`)
Example standard output table:
```markdown
| Instance | Service Tier | Provisioned Capacity | Used Bytes | Free Space % | Autoscale Needed | Proposed Action |
|---|---|---|---|---|---|---|
| `[instance-name]` | REGIONAL | 2048 GiB | 900 GiB | 56.05% | Yes (Scale Down) | Scale down to 1792 GiB. `gcloud filestore instances update ...` |
```
### 3. Execution & Confirmation Workflow
1. **Analysis & Recommendation (First Run / Inspection)**:
- Calculate step-aligned target capacity adhering to tier ceilings, floors, and basic scale-up only rules.
- Present the summary table and proposed actions.
- **MANDATORY USER CONFIRMATION PROMPT**: Whenever recommending target capacity or providing a `gcloud filestore instances update` command, your response MUST explicitly include a clear question asking the user to confirm execution before any modifications are made (e.g. *"Would you like me to proceed with scaling `[instance]` from [A] TiB to [B] TiB? Please confirm to execute."*) to prevent accidental billing spikes or capacity exhaustion.
- **Do not execute autoscale commands without user confirmation.**
2. **Execution upon Confirmation**:
- Once the user confirms (e.g., "Yes, proceed with scaling", "Scale instance X"), execute the attributed `gcloud filestore instances update` command on the confirmed instance(s).
3. **Fallback**:
- If execution fails due to Prod mutation restrictions, output the failure reason and provide the user with the exact attributed `gcloud` command to run manually, reminding them to confirm before manual execution.
### Custom Thresholds
When the user configures or passes custom threshold values in prompts (e.g.
"Scale up if free space drops below 10% with a 20% step", or custom
max_threshold / up_increment):
1. **Global Session Memory Confirmation**: The response MUST accept and
acknowledge the custom thresholds and MUST explicitly confirm that custom
thresholds apply globally across projects in session memory, explicitly
mentioning the target project IDs evaluated or active in session memory to
prevent accidental cross-project misconfiguration.
2. **Configuration Summary**: The response MUST display the updated active
configuration summary showing all active thresholds and step increments.
3. **Preserve Overrides**: The response MUST NOT revert to default thresholds
(15% / 10%) when custom overrides are provided.
## Reference Directory
For progressive disclosure of deeper topics, consult the `references/` directory:
- [Usage Attribution](references/attribution.md)
- [Instance Tiers & Specs](references/instance-tiers-specs.md)
- [Monitoring Metrics Formulas](references/monitoring-metrics.md)
- [Troubleshooting & Errors](references/troubleshooting-errors.md)
attribution.md 1.9 KB
# Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
- **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
subcommand, with the metrics environment variable. Set it inline on each
command because shell state may not persist between commands:
```bash
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:google-cloud-filestore-autoscale)" \
gcloud <command> [flags]
```
Do not use `gcloud config set` for this: it would persist beyond the current
task and mislabel unrelated usage.
- **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
server, include
`agent-skills/1.0 (skill:google-cloud-filestore-autoscale)` in the
`User-Agent` header. If a `User-Agent` header is already specified, append
this string to the end of it rather than overwriting existing `User-Agent`
data — the collection pipeline parses the `agent-skills/<version>` and
`skill:<name>` tokens, so any rewording breaks attribution:
```text
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:google-cloud-filestore-autoscale)
```
- **Constraint for Generated Code**: The tracking prefix is strictly for
commands you execute directly in the terminal. Do NOT include this tracking
prefix in generated scripts, Terraform templates, or code provided to the
user for their own repositories.
- **User Opt-Out**: If the user asks to disable or remove tracking or
attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
and custom `User-Agent` suffix from all commands.
instance-tiers-specs.md 3.0 KB
# Google Cloud Filestore Instance Tiers & Architecture
This reference provides architectural context for Cloud Filestore service tiers.
## Simplified Naming (Console) vs. API Enums
Google Cloud rebranded Filestore tiers in the UI. For API/CLI operations, legacy enums are still widely used:
- **Basic HDD / SSD** (`BASIC_HDD`, `BASIC_SSD`): Single-node architecture. Standard or Premium performance.
- **Zonal** (`ZONAL`, legacy: `HIGH_SCALE_SSD`): Scale-out single-zone cluster.
- **Regional** (`REGIONAL`, legacy: `ENTERPRISE`): Scale-out multi-zone HA cluster.
## Architecture Profiles
### Basic Tiers (Scale-Up Only)
- **Architecture**: A single Compute Engine VM attached to Persistent Disk (Standard or SSD).
- **Behavior**: You can increase the capacity of a Basic tier instance, but you **cannot decrease it**. The underlying disk cannot be shrunk.
- **Performance**: Predictable IOPS and throughput scaling linearly with capacity.
### Scale-Out Tiers (Zonal & Regional)
- **Architecture**: ECFS (Elastifile Cloud File System) multi-node cluster.
- **Behavior**: These tiers support both **Scale-up** and **Scale-down**, providing significant flexibility for cost optimization.
- **Capacity Bands**:
- Regional Small Band: 100 GiB - 10,239 GiB (1 GiB increments).
- Zonal Small Band: 1 TiB - 9.75 TiB (256 GiB increments).
- Large Band: 10 TiB - 100 TiB.
- *Instances cannot currently cross the boundary between small and large bands.*
- **Availability**:
- Zonal: Data is replicated within a single GCP zone.
### Sample Mock Fleet Instances (For Read-Only Analysis & Evals)
When Filestore API / MCP tools are not present:
- **Project `analytics-prod`**:
- `prod-vol`: Basic HDD tier (`BASIC_HDD`), 10 TiB capacity, 9 TiB used space (10% free space / 90% utilized).
## Tier & Capacity Limits Matrix
Filestore tiers enforce specific boundaries and behaviors. The skill must accept both modern UI names (`Basic`, `Zonal`, `Regional`) and legacy API enums interchangeably.
| Service Tier (UI & API Enums) | Min Capacity | Max Capacity | Scaling Step Increment | Scale-Up? | Scale-Down? |
| :--- | :--- | :--- | :--- | :---: | :---: |
| **Basic HDD** (`BASIC_HDD` / `STANDARD`) | **1 TiB** (100 GiB on GKE) | **63.9 TiB** | **1 GiB** | Yes | **No (Scale-Up Only)** |
| **Basic SSD** (`BASIC_SSD` / `PREMIUM`) | **2.5 TiB** | **63.9 TiB** | **1 GiB** | Yes | **No (Scale-Up Only)** |
| **Regional (Small Band)** (`REGIONAL`) | **100 GiB** | **10,239 GiB** | **1 GiB** | Yes | **Yes** (Floor: 100 GiB, usage) |
| **Regional (Large Band)** (`REGIONAL`) | **10 TiB** | **100 TiB** | **2.5 TiB** | Yes | **Yes** (Floor: 10 TiB, usage) |
| **Zonal (Small Band)** (`ZONAL`) | **1 TiB** | **9.75 TiB** | **256 GiB** | Yes | **Yes** (Floor: 1 TiB, usage) |
| **Zonal (Large Band)** (`ZONAL`, `HIGH_SCALE_SSD`)| **10 TiB** | **100 TiB** | **2.5 TiB** | Yes | **Yes** (Floor: 10 TiB, usage) |
| **Enterprise** (`ENTERPRISE`) | **1 TiB** | **10 TiB** | **256 GiB** | Yes | **Yes** (Floor: 1 TiB, usage) |
monitoring-metrics.md 3.3 KB
# Filestore Monitoring Metrics
## Essential Filestore Storage Metrics
When determining if a Filestore instance needs scaling, query the Cloud Monitoring API for utilization.
### Used Capacity Metric
- **Metric Type**: `file.googleapis.com/nfs/server/used_bytes`
- **Description**: The amount of storage space currently utilized on the file share.
- **Aggregation**: It is recommended to use a 5-minute rolling average to smooth out transient spikes.
### Provisioned Capacity
- **DO NOT fetch provisioned capacity or total_bytes from Cloud Monitoring**.
- **Description**: The total provisioned storage capacity is identical to the
instance capacity. You must read the `capacityGb` property directly from the
instances returned by the `list_instances` MCP tool or the GCP API.
### Fetching Metrics Across Agent Runtimes
You must retrieve the `used_bytes` metric from the Cloud Monitoring API. Select
the method that matches your active runtime tools:
#### Option 1: GCP REST API Tool (e.g., `call_gcp_api` in Gemini Enterprise File Agent)
If your runtime provides a native GCP API execution tool, invoke it with:
- **service**: "monitoring"
- **version**: "v3"
- **resource_path**: "projects/{project_id}/timeSeries"
- **query_params**: `{"filter":
"metric.type=\"file.googleapis.com/nfs/server/used_bytes\""}`
*(Note: Do NOT include `interval.startTime` or `interval.endTime` or aggregation
parameters; the tool calculates and attaches the latest 15-minute window
automatically).*
#### Option 2: `gcloud` CLI (Recommended for Terminal / Command-Line Agents)
If your agent environment has terminal/command execution enabled:
```bash
gcloud monitoring time-series list \
--filter='metric.type="file.googleapis.com/nfs/server/used_bytes"' \
--project="{project_id}" \
--format="json"
```
#### Option 3: Direct HTTP REST (`curl`)
```bash
curl -s -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://monitoring.googleapis.com/v3/projects/{project_id}/timeSeries?filter=metric.type%3D%22file.googleapis.com%2Fnfs%2Fserver%2Fused_bytes%22"
```
#### Option 4: Cloud Monitoring MCP
If an MCP server for Google Cloud Monitoring is mounted, use `list_time_series`
with:
- `filter`: `metric.type="file.googleapis.com/nfs/server/used_bytes"`
--------------------------------------------------------------------------------
### Critical Metric Query Rules (Applies to All Methods)
1. **NO LOCATION FILTERS REQUIRED:** Do NOT attempt to filter by zone, region,
or location (e.g., `us-central1-a`). Filestore metric labels differ between
zonal and regional tiers; querying at the project level avoids empty
results.
2. **ONE BULK QUERY PER PROJECT:** Always fetch metrics for the entire project
in a single call to avoid per-instance agent looping and timeouts.
3. **DO NOT FETCH `total_bytes`:** Read `capacityGb` directly from
`list_instances`. Do not make secondary queries for provisioned capacity.
4. **INSTANCE FILTER (IF SCOPED):** When filtering to a single instance, use
`resource.labels.instance_name="{instance_name}"` (NOT `instance_id`).
## Calculation Formulas
- **Free Bytes**: `total_bytes - used_bytes`
- **Free Space Percentage**: `((total_bytes - used_bytes) / total_bytes) * 100`
Use these formulas when evaluating instances against the `max_threshold` and `min_threshold` safety factors.
troubleshooting-errors.md 1.6 KB
# Filestore Autoscaling Troubleshooting & Errors
## Common Scale-Down Errors
### "capacity for file share may only be increased"
- **Trigger**: Attempting to decrease the capacity of a `BASIC_HDD` or `BASIC_SSD` tier instance.
- **Root Cause**: Basic tier instances are backed by single Persistent Disks, which do not support shrinking.
- **Resolution**: Remind the user that Basic instances cannot be shrunk. You must delete and recreate, or migrate to a Zonal/Regional scale-out tier if elasticity is required.
### "cannot decrease capacity below current usage"
- **Trigger**: Attempting to scale down a Zonal or Regional instance below the amount of data it currently holds.
- **Root Cause**: Self-evident safety mechanism; you cannot compress existing files mechanically by reducing provisioned space below `used_bytes`.
- **Resolution**: Set the target capacity strictly greater than the current `used_bytes` metric (with sufficient buffer).
## Common Scale-Up Errors
### `RESOURCE_EXHAUSTED` (Quota Limits)
- **Trigger**: Attempting to scale up an instance beyond available GCP project quotas in a region.
- **Root Cause**: The project lacks sufficient `filestore.googleapis.com` quota (e.g. `CPUs`, `Storage Capacity`).
- **Resolution**: Instruct the user to request a quota increase via the Pantheon Quotas page for the specific region and metric.
### `PERMISSION_DENIED`
- **Trigger**: Missing IAM permissions.
- **Root Cause**: The executing service account or user lacks `roles/file.editor` or `roles/file.admin`.
- **Resolution**: Grant the necessary IAM bindings to the user executing the scaling operation.
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE