A tool to create VACUUM snapshots of the VAI (Virtual Aggregate Informer) database from Rancher pods.
- Opens the VAI database at
/var/lib/rancher/informer_object_cache.db
(read-only) - Creates a VACUUM snapshot (compact copy) of the database
- Outputs the entire database as base64 to stdout
- All errors go to stderr prefixed with "ERROR:"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o vai-vacuum .
This creates a static Linux binary (~6MB) that runs in Rancher pods without any dependencies.
Do NOT commit the binary to git. Instead:
- Build the binary using the command above
- Create a GitHub Release in your repository
- Upload
vai-vacuum
as a release asset - Use the release download URL in your tests
Example URL format:
https://github.com/brudnak/vai-vacuum/releases/download/v1.0.0-beta/vai-vacuum
The binary is used by VAI tests to extract database snapshots from running Rancher pods:
# Download, run, and save snapshot to a file
kubectl exec <pod> -n cattle-system -c rancher -- sh -c \
"curl -kL -o /tmp/vai-vacuum <RELEASE-URL> && chmod +x /tmp/vai-vacuum && /tmp/vai-vacuum" \
| base64 -d > snapshot.db
Note: The -k
flag is required for curl to bypass SSL certificate verification in container environments.
# List all tables
sqlite3 snapshot.db ".tables"
# Example output:
# *v1*Endpoints
# *v1*Event
# *v1*Namespace
# *v1*Node
# cluster.x-k8s.io_v1beta1_Machine
# management.cattle.io_v3_Cluster
# management.cattle.io_v3_FleetWorkspace
# management.cattle.io_v3_Node
# management.cattle.io_v3_Project
# management.cattle.io_v3_Setting
# provisioning.cattle.io_v1_Cluster
# ... and many more
# Check database integrity
sqlite3 snapshot.db "PRAGMA integrity_check;"
# Count rows in a specific table
sqlite3 snapshot.db "SELECT COUNT(*) FROM management.cattle.io_v3_Cluster;"
modernc.org/sqlite
- Pure Go SQLite driver (no CGO required)
- Success: Raw base64 encoded database to stdout (no headers, no newlines at start)
- Failure: Error message to stderr starting with "ERROR:"
To test on your development machine:
In your Go source file, change:
const (
vaiDBPath = "/var/lib/rancher/informer_object_cache.db"
To:
const (
vaiDBPath = "./test.db" // Temporary change for local testing
# For macOS (Intel)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o vai-vacuum-mac .
# For macOS (Apple Silicon M1/M2)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o vai-vacuum-mac .
# Create test database
sqlite3 test.db "CREATE TABLE test (id INTEGER); INSERT INTO test VALUES (1);"
# Run the tool
./vai-vacuum-mac | base64 -d > output.db
# Verify the output
sqlite3 output.db "SELECT * FROM test;"
# Should output: 1
const (
vaiDBPath = "/var/lib/rancher/informer_object_cache.db"
Then build the Linux version for deployment:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o vai-vacuum .
This creates the Linux binary that will run in Rancher pods.
- The tool uses SQLite's VACUUM command to create a compact copy of the database
- The snapshot is created in
/tmp/vai-snapshot.db
temporarily and cleaned up after encoding - All database operations are read-only to ensure safety in production