// cleanFailedContainerCluster deletes clusters that failed but were
// created in an error state. Similar to resourceContainerClusterDelete
// but implemented in separate function as it doesn't try to lock already
// locked cluster state, does different error handling, and doesn't do retries.
cleanFailedContainerCluster deletes clusters that failed but were
created in an error state. Similar to resourceContainerClusterDelete
but implemented in separate function as it doesn't try to lock already
locked cluster state, does different error handling, and doesn't do retries.
// cleanFailedContainerCluster deletes clusters that failed but were // created in an error state . Similar to resourceContainerClusterDelete // but implemented in separate function as it doesn ' t try to lock already // locked cluster state does different error handling and doesn ' t do retries .
func cleanFailedContainerCluster(d *schema.ResourceData, meta interface{}) error {
	config := meta.(*Config)
	project, err := getProject(d, config)
	if err != nil {
		return err
	}
	location, err := getLocation(d, config)
	if err != nil {
		return err
	}
	clusterName := d.Get("name").(string)
	fullName := containerClusterFullName(project, location, clusterName)
	log.Printf("[DEBUG] Cleaning up failed GKE cluster %s", d.Get("name").(string))
	clusterDeleteCall := config.clientContainerBeta.Projects.Locations.Clusters.Delete(fullName)
	if config.UserProjectOverride {
		clusterDeleteCall.Header().Add("X-Goog-User-Project", project)
	}
	op, err := clusterDeleteCall.Do()
	if err != nil {
		return handleNotFoundError(err, d, fmt.Sprintf("Container Cluster %q", d.Get("name").(string)))
	}
	waitErr := containerOperationWait(config, op, project, location, "deleting GKE cluster", d.Timeout(schema.TimeoutDelete))
	if waitErr != nil {
		return waitErr
	}
	log.Printf("[INFO] GKE cluster %s has been deleted", d.Id())
	d.SetId("")
	return nil
}
func cleanFailedContainerCluster ( d * schema . ResourceData , meta interface { } ) error { config := meta . ( * Config ) project , err := getProject ( d , config ) if err != nil { return err } location , err := getLocation ( d , config ) if err != nil { return err } clusterName := d . Get ( " " ) . ( string ) fullName := containerClusterFullName ( project , location , clusterName ) log . Printf ( " " , d . Get ( " " ) . ( string ) ) clusterDeleteCall := config . clientContainerBeta . Projects . Locations . Clusters . Delete ( fullName ) if config . UserProjectOverride { clusterDeleteCall . Header ( ) . Add ( " " , project ) } op , err := clusterDeleteCall . Do ( ) if err != nil { return handleNotFoundError ( err , d , fmt . Sprintf ( " " , d . Get ( " " ) . ( string ) ) ) } waitErr := containerOperationWait ( config , op , project , location , " " , d . Timeout ( schema . TimeoutDelete ) ) if waitErr != nil { return waitErr } log . Printf ( " " , d . Id ( ) ) d . SetId ( " " ) return nil }
cleanFailedContainerCluster deletes clusters that failed but were
created in an error state.
cleanFailedContainerCluster deletes clusters that failed but were created in an error state .
// Wait until it's deleted