Skip to content

Commit

Permalink
Remove instance_group_urls (#5378)
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn authored Oct 28, 2021
1 parent a243bae commit 0a17e69
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
resource "google_compute_instance_group_named_port" "<%= ctx[:primary_resource_id] %>" {
group = google_container_cluster.my_cluster.instance_group_urls[0]
group = google_container_cluster.my_cluster.node_pool[0].instance_group_urls[0]
zone = "us-central1-a"

name = "http"
port = 8080
}

resource "google_compute_instance_group_named_port" "<%= ctx[:primary_resource_id] %>s" {
group = google_container_cluster.my_cluster.instance_group_urls[0]
group = google_container_cluster.my_cluster.node_pool[0].instance_group_urls[0]
zone = "us-central1-a"

name = "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,14 +938,6 @@ func resourceContainerCluster() *schema.Resource {
Description: `The IP address of this cluster's Kubernetes master.`,
},

"instance_group_urls": {
Type: schema.TypeList,
Computed: true,
Deprecated: `Please use node_pool.instance_group_urls instead.`,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `List of instance group URLs which have been assigned to the cluster.`,
},

"master_version": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1882,14 +1874,6 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
return err
}

igUrls, err := getInstanceGroupUrlsFromManagerUrls(config, userAgent, cluster.InstanceGroupUrls)
if err != nil {
return err
}
if err := d.Set("instance_group_urls", igUrls); err != nil {
return err
}

if err := d.Set("vertical_pod_autoscaling", flattenVerticalPodAutoscaling(cluster.VerticalPodAutoscaling)); err != nil {
return err
}
Expand Down Expand Up @@ -2964,30 +2948,6 @@ func containerClusterAwaitRestingState(config *Config, project, location, cluste
return state, err
}

// container engine's API returns the instance group manager's URL instead of the instance
// group's URL in its responses, while the field is named as if it should have been the group
// and not the manager. This shim should be supported for backwards compatibility reasons.
func getInstanceGroupUrlsFromManagerUrls(config *Config, userAgent string, igmUrls []string) ([]string, error) {
instanceGroupURLs := make([]string, 0, len(igmUrls))
for _, u := range igmUrls {
if !instanceGroupManagerURL.MatchString(u) {
instanceGroupURLs = append(instanceGroupURLs, u)
continue
}
matches := instanceGroupManagerURL.FindStringSubmatch(u)
instanceGroupManager, err := config.NewComputeClient(userAgent).InstanceGroupManagers.Get(matches[1], matches[2], matches[3]).Do()
if isGoogleApiErrorWithCode(err, 404) {
// The IGM URL is stale; don't include it
continue
}
if err != nil {
return nil, fmt.Errorf("Error reading instance group manager returned as an instance group URL: %s", err)
}
instanceGroupURLs = append(instanceGroupURLs, instanceGroupManager.InstanceGroup)
}
return instanceGroupURLs, nil
}

func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
l := configured.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ resource "google_compute_backend_service" "my-backend-service" {
protocol = "HTTP"

backend {
group = element(google_container_cluster.primary.instance_group_urls, 1)
group = element(google_container_cluster.primary.node_pool[0].instance_group_urls, 1)
}

health_checks = [google_compute_http_health_check.default.self_link]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ output "endpoint" {
}
output "instance_group_urls" {
value = data.google_container_cluster.my_cluster.instance_group_urls
value = data.google_container_cluster.my_cluster.node_pool[0].instance_group_urls
}
output "node_config" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,6 @@ exported:

* `endpoint` - The IP address of this cluster's Kubernetes master.

* `instance_group_urls` - List of instance group URLs which have been assigned
to the cluster.

* `label_fingerprint` - The fingerprint of the set of labels for this cluster.

* `maintenance_policy.0.daily_maintenance_window.0.duration` - Duration of the time window, automatically chosen to be
Expand Down

0 comments on commit 0a17e69

Please sign in to comment.