Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove instance_group_urls #5378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -960,14 +960,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 @@ -1904,14 +1896,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 @@ -3025,30 +3009,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 @@ -3386,7 +3386,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 @@ -32,7 +32,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 @@ -931,9 +931,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