Skip to content

[Bug] 0.11.13 plan fails for existing data views #991

Closed
@Bunzab

Description

@Bunzab

Describe the bug
When using the new provider 0.11.13 terraform plan fails for existing Data views with:

╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).UpgradeResourceState request was cancelled.
╵
Stack trace from the terraform-provider-elasticstack_v0.11.13 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x147bbfd]
goroutine 72 [running]:
github.com/elastic/terraform-provider-elasticstack/internal/kibana/data_view.dataViewModel.getViewIDAndSpaceID({{0x2, {0xc00096ae80, 0x1b}}, {0x2, {0xc0009be570, 0x7}}, {0x2, 0x0}, {0xc0001e8cc0, 0xc0001dfad0, ...}})
	github.com/elastic/terraform-provider-elasticstack/internal/kibana/data_view/models.go:237 +0x1d
github.com/elastic/terraform-provider-elasticstack/internal/kibana/data_view.(*DataViewResource).Read(0xc0006a0700, {0x1b4f318, 0xc0006d6a50}, {{{{0x1b55df8, 0xc0001df290}, {0x16e9660, 0xc0001deb70}}, {0x1b58ef0, 0xc00056b6d0}}, 0xc0006a0710, ...}, ...)
	github.com/elastic/terraform-provider-elasticstack/internal/kibana/data_view/read.go:25 +0x1b8
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadResource(0xc00016b448, {0x1b4f318, 0xc0006d6a50}, 0xc0006d6ab0, 0xc000593590)
	github.com/hashicorp/[email protected]/internal/fwserver/server_readresource.go:117 +0x84e
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadResource(0xc00016b448, {0x1b4f318?, 0xc0006d6960?}, 0xc0002a89c0)
	github.com/hashicorp/[email protected]/internal/proto6server/server_readresource.go:55 +0x38e
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0xc0002faf00, {0x1b4f318?, 0xc0006d6690?}, 0xc0002a89c0)
	github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0003d46e0, {0x1b4f318?, 0xc0003fbe30?}, 0xc000284770)
	github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:784 +0x2f3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x18b2100, 0xc0003d46e0}, {0x1b4f318, 0xc0003fbe30}, 0xc0001ba000, 0x0)
	github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:575 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003da400, {0x1b4f318, 0xc0003fbda0}, {0x1b574a0, 0xc000524000}, 0xc0001b47e0, 0xc0003f9e30, 0x2867948, 0x0)
	google.golang.org/[email protected]/server.go:1394 +0xe2b
google.golang.org/grpc.(*Server).handleStream(0xc0003da400, {0x1b574a0, 0xc000524000}, 0xc0001b47e0)
	google.golang.org/[email protected]/server.go:1805 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/[email protected]/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 28
	google.golang.org/[email protected]/server.go:1040 +0x125
Error: The terraform-provider-elasticstack_v0.11.13 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

We deploy ~200 data views and Error: Request cancelled is repeated for each one.
This works fine in 0.11.11.

To Reproduce
Steps to reproduce the behavior:

  1. Data views are defined in a local like:
locals {
  index_mappings = {
    "space_id = {
      indices = {
        "data-view1.log-*" = {
          id = "data-view1.log"
          field_formats = {
            ...
          }
          field_atts = {
            ...
          }
        }
      }
    }
  }
}

Another local is used to format and then the resources are created:

resource "elasticstack_kibana_data_view" "kibana_data_views" {

  for_each = {
    for k, v in local.flattened_dataviews : "${v.space_id}_${v.name}" => v
  }

  data_view = {
    name = each.value.name
    title = each.value.indices
    id = each.value.id
    time_field_name = "@timestamp"
    field_formats = each.value.field_formats != null ? each.value.field_formats : null
    field_attrs = each.value.field_attrs != null ? each.value.field_attrs : null
  }
  space_id = lower(each.value.space_id)

  lifecycle {
    create_before_destroy = false
  }
}
  1. No changes have been made the only change is to update the provider from 0.11.11 to 0.11.13 (same error happens in 12)
    Run terraform plan
  2. Expected behavior
    The plan should succeed.

Debug output
I can't provide the entire output as it is 30MB and includes sensitive data.
I do see API requests:
GET /s/space01/api/data_views/data_view/logs-dirs.log-%2A HTTP/1.1
And then a 200 response with the full data view returned.
The next log occurrence for that data view is:
2025-01-22T16:17:02.092+0100 [ERROR] plugin6.(GRPCProvider).UpgradeResourceState: error="rpc error: code = Canceled desc = context canceled"
2025-01-22T16:17:02.092+0100 [ERROR] vertex "elasticstack_kibana_data_view.kibana_data_views["logs-dirs.log-
"]" error: Request cancelled
If a full log is required I can raise a support request.

Versions (please complete the following information):

  • OS: Linux (RHEL)
  • Terraform Version 1.9.8
  • Provider version 0.11.13
  • Elasticsearch Version 8.15.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions