How to delete old unused routes created by ECFS GCP deployment

Elastifile Cloud File System (ECFS) deployment creates routes pointing to the storage nodes.

When Elastifile Cloud File System (ECFS) storage nodes are deleted manually from the GCP console (not from ECFS cli), the routes are not deleted with the instances.

Those routes need to be cleaned manually by using the GCP console or GCLOUD cli.

The procedure below will create routes-to-delete.txt file, which contained the gcloud commands with the stale routes. 
Before executing the commands in routes-to-delete.txt file, make sure the routes objects going to be deleted, are not being used using GCP Console.

Without double checking the list, this procedure may cause NFS Clients downtime.
  1. Create routes-to-delete.txt file

export PROJECT="GCP project ID used for ECFS deployment" 

export VPC_PROJECT="GCP project ID used for Network ECFS deployment. If using SVPC its different than PROJECT" 

gcloud compute routes list --project $VPC_PROJECT|grep `hostname`|awk '{print $4}'|sort > routes.ip.list; gcloud compute instances list --project $PROJECT |grep `hostname` | grep elfs |awk '{print $(NF-1)}'|sort > instances.ip.list; diff routes.ip.list instances.ip.list |grep "<"|awk '{print "gcloud compute routes list --project $PROJECT|grep elfs|grep "$2}'|sh|awk '{print "gcloud compute routes delete "$1" --project $PROJECT --quiet"}' > routes-to-delete.txt

At this point the routes-to-delete.txt file, need to be double checked against the GCP console routes objects. 
  1. Delete all stale routes 

bash routes-to-delete.txt

Was this helpful?
How can we improve it?
true
Search
Clear search
Close search
Google apps
Main menu
Search Help Center
false
false