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 #10442

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
3 changes: 3 additions & 0 deletions .changelog/5378.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
container: `instance_group_urls` has been removed in favor of `node_pool.instance_group_urls`
```
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ func TestAccComputeInstanceGroupNamedPort_instanceGroupNamedPortGkeExample(t *te
func testAccComputeInstanceGroupNamedPort_instanceGroupNamedPortGkeExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_instance_group_named_port" "my_port" {
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" "my_ports" {
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
40 changes: 0 additions & 40 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,14 +704,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 @@ -1559,14 +1551,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 @@ -2490,30 +2474,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
2 changes: 1 addition & 1 deletion google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,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
2 changes: 1 addition & 1 deletion website/docs/d/container_cluster.html.markdown
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 @@ -45,15 +45,15 @@ To get more information about InstanceGroupNamedPort, see:

```hcl
resource "google_compute_instance_group_named_port" "my_port" {
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" "my_ports" {
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
3 changes: 0 additions & 3 deletions website/docs/r/container_cluster.html.markdown
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