-
Notifications
You must be signed in to change notification settings - Fork 89
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
internal/kibana: fix datasourceConnectorRead error #729
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, the provider panics when no Kibana connectors are found: ➜ test_elasticstack_provider cat main.tf
data "elasticstack_kibana_action_connector" "my-connector" {
name = "doesnotexist"
connector_type_id = ".pagerduty"
} ➜ test_elasticstack_provider terraform plan
data.elasticstack_kibana_action_connector.my-connector: Reading...
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ReadDataSource request was cancelled.
╵
Stack trace from the terraform-provider-elasticstack_v0.11.6 plugin:
panic: runtime error: index out of range [0] with length 0
goroutine 81 [running]:
github.com/elastic/terraform-provider-elasticstack/internal/kibana.datasourceConnectorRead({0x1752640, 0xc0003ae460}, 0xc000518e00, {0x14d2e20?, 0xc00098e000?})
github.com/elastic/terraform-provider-elasticstack/internal/kibana/connector_data_source.go:86 +0x4c5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003610a0, {0x1752598, 0xc0006d95f0}, 0xc000518e00, {0x14d2e20, 0xc00098e000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:823 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0003610a0, {0x1752598, 0xc0006d95f0}, 0xc000518d00, {0x14d2e20, 0xc00098e000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:1043 +0x13a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc0000119c8, {0x1752598?, 0xc0006d94a0?}, 0xc0006d9560)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1434 +0x6b1
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadDataSource({{0x175c9e8?, 0xc0000119c8?}}, {0x1752598?, 0xc0006d94a0?}, 0xc0006d9170?)
github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:142 +0x282
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadDataSource(0xc0003aed20, {0x1752598?, 0xc0006d91d0?}, 0xc0006d9170)
github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ReadDataSource.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadDataSource(0xc0003a8960, {0x1752598?, 0xc0006d83c0?}, 0xc00032cf00)
github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:688 +0x27d
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadDataSource_Handler({0x14fbba0, 0xc0003a8960}, {0x1752598, 0xc0006d83c0}, 0xc000518800, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:572 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001cd200, {0x1752598, 0xc0006d8330}, {0x1758f40, 0xc0001f5080}, 0xc0005bfb00, 0xc000472120, 0x225e7a0, 0x0)
google.golang.org/grpc@v1.65.0/server.go:1379 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc0001cd200, {0x1758f40, 0xc0001f5080}, 0xc0005bfb00)
google.golang.org/grpc@v1.65.0/server.go:1790 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/grpc@v1.65.0/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 53
google.golang.org/grpc@v1.65.0/server.go:1040 +0x125
Error: The terraform-provider-elasticstack_v0.11.6 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. I locally compiled the provider out of current branch and tested it like so: ➜ test_elasticstack_provider cat .terraform.rc
provider_installation {
dev_overrides {
"registry.terraform.io/elastic/elasticstack" = "/home/alexandros/go/bin"
}
direct {}
}
➜ test_elasticstack_provider export TF_CLI_CONFIG_FILE=.terraform.rc ➜ test_elasticstack_provider terraform plan
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - elastic/elasticstack in /home/alexandros/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
data.elasticstack_kibana_action_connector.my-connector: Reading...
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: error while creating elasticstack_kibana_action_connector datasource: connector with name [default/doesnotexist] and type [.pagerduty] not found
│
│ with data.elasticstack_kibana_action_connector.my-connector,
│ on main.tf line 1, in data "elasticstack_kibana_action_connector" "my-connector":
│ 1: data "elasticstack_kibana_action_connector" "my-connector" {
│
╵ Now it errors out normally. |
Make sure that datasourceConnectorRead() returns the appropriate error when no connectors are found.
tobio
force-pushed
the
alexaf/fix_kibana_connector_datasource
branch
from
August 26, 2024 23:18
5784234
to
cd5d615
Compare
tobio
approved these changes
Aug 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 😍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make sure that datasourceConnectorRead() returns the appropriate error when no connectors are found.