!pip install pymysql
Requirement already satisfied: pymysql in /srv/paws/lib/python3.4/site-packages
import re
import sys
import subprocess

volumes = {}

for line in sys.stdin:
    m = re.search(r'Failed to attach volume "(.*)" on node "(.*)"', line)
    if m:
        volumes[m.groups()[0]] = m.groups()[1]

for vol, node in volumes.items():
    cmd = [
        'gcloud', 'compute', 'instances', 'detach-disk',
        node, '--disk', vol
    ]
    print(cmd)
    subprocess.check_call(cmd)
re.search(r"The disk resource '(.*)' is already being used by '(.*)'", l).groups()
('gke-prod-49ca6b0d-dyna-pvc-39138515-de6e-11e6-98ef-42010af000c3',
 'gke-prod-highmem-pool-0df1a536-d1hk')
l ="""
Failed to attach volume "pvc-39138515-de6e-11e6-98ef-42010af000c3" on node "gke-prod-highmem-pool-0df1a536-mrmw" with: googleapi: Error 400: The disk resource 'gke-prod-49ca6b0d-dyna-pvc-39138515-de6e-11e6-98ef-42010af000c3' is already being used by 'gke-prod-highmem-pool-0df1a536-d1hk'
"""
re