fivetran / terraform-provider-fivetran

Terraform Provider for Fivetran
https://fivetran.com
Apache License 2.0
41 stars 22 forks source link

1.1.6 - plugin crash #241

Closed z0rc closed 5 months ago

z0rc commented 6 months ago

Describe the bug Upgraded provider on existing state from 1.1.5 to 1.1.6, run terraform validate.

To Reproduce I'll try to look into providing minimum reproduction, but right now my code is filled with sensitive values and resources, so this might be hard to archive.

Expected behavior No crash.

Logs & Output

% terraform validate
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-fivetran_v1.1.6 plugin:

fatal error: concurrent map iteration and map write
fatal error: concurrent map writes

goroutine 50 [running]:
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema.GetResourceConfigSchemaAttributes()
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema/connector_config.go:40 +0xf4
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema.ConnectorResourceBlocks({0x10335a9c0, 0x140004e2de0})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema/connector.go:114 +0x284
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources.(*connector).Schema(0x10335a9c0?, {0x10335a9c0, 0x140004e2de0}, {}, 0x14000480960)
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources/connector.go:36 +0x3c
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ResourceSchema(0x140002311e0, {0x10335a9c0, 0x140004e2de0}, {0x1400052c030, 0x12})
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/fwserver/server.go:489 +0x2b0
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ValidateResourceConfig(0x140002311e0, {0x10335a9c0?, 0x140004e2c90?}, 0x1400052e138)
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/proto6server/server_validateresourceconfig.go:31 +0x150
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ValidateResourceConfig(0x10335a918?, {0x10335a9c0?, 0x140004e2960?}, 0x1400052e138)
    github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ValidateResourceConfig.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ValidateResourceConfig(0x140002250e0, {0x10335a9c0?, 0x140004e21b0?}, 0x1400048e340)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:727 +0x264
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ValidateResourceConfig_Handler({0x10331ca40?, 0x140002250e0}, {0x10335a9c0, 0x140004e21b0}, 0x140004de070, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:359 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002943c0, {0x10335fb20, 0x140001029c0}, 0x140004e8000, 0x14000415410, 0x10391f9e8, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1360 +0xc88
google.golang.org/grpc.(*Server).handleStream(0x140002943c0, {0x10335fb20, 0x140001029c0}, 0x140004e8000, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1737 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.57.0/server.go:982 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.57.0/server.go:980 +0x16c

goroutine 1 [select]:
github.com/hashicorp/go-plugin.Serve(0x14000208600)
    github.com/hashicorp/go-plugin@v1.5.1/server.go:474 +0x10f0
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.Serve({0x103024f00, 0x31}, 0x14000205e60, {0x0, 0x0, 0x0})
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:315 +0x9d8
main.main()
    github.com/fivetran/terraform-provider-fivetran/main.go:56 +0x2cc

goroutine 17 [select]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x0?)
    github.com/hashicorp/go-plugin@v1.5.1/grpc_broker.go:125 +0x58
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0x14000212a00)
    github.com/hashicorp/go-plugin@v1.5.1/grpc_broker.go:437 +0x40
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
    github.com/hashicorp/go-plugin@v1.5.1/grpc_server.go:88 +0x48c

goroutine 18 [IO wait]:
internal/poll.runtime_pollWait(0x12b19fa10, 0x72)
    runtime/netpoll.go:305 +0xa0
internal/poll.(*pollDesc).wait(0x14000208a80?, 0x140001af000?, 0x1)
    internal/poll/fd_poll_runtime.go:84 +0x28
internal/poll.(*pollDesc).waitRead(...)
    internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0x14000208a80, {0x140001af000, 0x1000, 0x1000})
    internal/poll/fd_unix.go:167 +0x1e0
os.(*File).read(...)
    os/file_posix.go:31
os.(*File).Read(0x1400020a330, {0x140001af000?, 0x400?, 0x103200580?})
    os/file.go:119 +0x5c
bufio.(*Reader).Read(0x1400006af30, {0x140001dec00, 0x400, 0x0?})
    bufio/bufio.go:237 +0x1e0
github.com/hashicorp/go-plugin.copyChan({0x103363290, 0x14000224fa0}, 0x0?, {0x103356440?, 0x1400020a330?})
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:184 +0x154
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:40 +0x10c

goroutine 19 [IO wait]:
internal/poll.runtime_pollWait(0x12b19f830, 0x72)
    runtime/netpoll.go:305 +0xa0
internal/poll.(*pollDesc).wait(0x14000208b40?, 0x140001f6000?, 0x1)
    internal/poll/fd_poll_runtime.go:84 +0x28
internal/poll.(*pollDesc).waitRead(...)
    internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0x14000208b40, {0x140001f6000, 0x1000, 0x1000})
    internal/poll/fd_unix.go:167 +0x1e0
os.(*File).read(...)
    os/file_posix.go:31
os.(*File).Read(0x1400020a340, {0x140001f6000?, 0x400?, 0x103200580?})
    os/file.go:119 +0x5c
bufio.(*Reader).Read(0x1400006b730, {0x140001df000, 0x400, 0x0?})
    bufio/bufio.go:237 +0x1e0
github.com/hashicorp/go-plugin.copyChan({0x103363290, 0x14000224fa0}, 0x0?, {0x103356440?, 0x1400020a340?})
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:184 +0x154
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:41 +0x198

goroutine 33 [syscall]:
os/signal.signal_recv()
    runtime/sigqueue.go:149 +0x2c
os/signal.loop()
    os/signal/signal_unix.go:23 +0x1c
created by os/signal.Notify.func1.1
    os/signal/signal.go:151 +0x2c

goroutine 34 [chan receive]:
github.com/hashicorp/go-plugin.Serve.func3()
    github.com/hashicorp/go-plugin@v1.5.1/server.go:439 +0x70
created by github.com/hashicorp/go-plugin.Serve
    github.com/hashicorp/go-plugin@v1.5.1/server.go:436 +0xef4

goroutine 35 [IO wait]:
internal/poll.runtime_pollWait(0x12b19fb00, 0x72)

Error: The terraform-provider-fivetran_v1.1.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.

Plugin version: 1.1.6, reproduced using linux/amd64 and darwin/arm64 arches.

Additional context N/A

z0rc commented 6 months ago

Same error with 1.1.7.

beevital commented 6 months ago

I'm working on it. Thank you for the detailed logs!

beevital commented 6 months ago

@z0rc I've released a new 1.1.8 version with the fix. Could you please check is the fix works for you. I wan't able to reproduce the issue with huge amount of defined connector resources, but wasn't able to unfortunately. But I think the latest refactor with initialisation of config schema should fix the issue.

z0rc commented 6 months ago

@beevital with 1.1.8 terraform validate passes successfully, but terraform plan on the same state fails with:

╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ValidateResourceConfig call. The plugin logs may
│ contain more details.
╵
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ValidateResourceConfig request was cancelled.
╵
Stack trace from the terraform-provider-fivetran_v1.1.8 plugin:
fatal error: concurrent map writes
goroutine 51 [running]:
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema.GetResourceConfigSchemaAttributes()
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema/connector_config.go:42 +0x1de
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema.ConnectorResourceBlocks({0xfd6a00, 0xc00033f6b0})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/schema/connector.go:114 +0x30a
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources.(*connector).Schema(0xfd6a00?, {0xfd6a00, 0xc00033f6b0}, {}, 0xc0002806c0)
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources/connector.go:36 +0x45
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ResourceSchema(0xc0000f4000, {0xfd6a00, 0xc00033f6b0}, {0xc0002942a0, 0x12})
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/fwserver/server.go:489 +0x330
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ValidateResourceConfig(0xc0000f4000, {0xfd6a00?, 0xc00033f560?}, 0xc000140948)
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/proto6server/server_validateresourceconfig.go:31 +0x1bc
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ValidateResourceConfig(0xfd6958?, {0xfd6a00?, 0xc00033f230?}, 0xc000140948)
    github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ValidateResourceConfig.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ValidateResourceConfig(0xc0004cfcc0, {0xfd6a00?, 0xc00033eab0?}, 0xc00028cf40)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:727 +0x2e3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ValidateResourceConfig_Handler({0xe25520?, 0xc0004cfcc0}, {0xfd6a00, 0xc00033eab0}, 0xc0001a82a0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:359 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00033c000, {0xfdbba0, 0xc0001029c0}, 0xc0005a7d40, 0xc00042dad0, 0x15b8b68, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1360 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc00033c000, {0xfdbba0, 0xc0001029c0}, 0xc0005a7d40, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1737 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.57.0/server.go:982 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.57.0/server.go:980 +0x18c
goroutine 1 [select]:
github.com/hashicorp/go-plugin.Serve(0xc000114180)
    github.com/hashicorp/go-plugin@v1.5.1/server.go:474 +0x14d7
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.Serve({0xe824b1, 0x31}, 0xc00011b6c0, {0x0, 0x0, 0x0})
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:315 +0xba5
main.main()
    github.com/fivetran/terraform-provider-fivetran/main.go:56 +0x2f6
goroutine 10 [select]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x0?)
    github.com/hashicorp/go-plugin@v1.5.1/grpc_broker.go:125 +0x67
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0xc000298480)
    github.com/hashicorp/go-plugin@v1.5.1/grpc_broker.go:437 +0x44
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
    github.com/hashicorp/go-plugin@v1.5.1/grpc_server.go:88 +0x4f7
goroutine 11 [IO wait]:
internal/poll.runtime_pollWait(0x7fb652634320, 0x72)
    runtime/netpoll.go:305 +0x89
internal/poll.(*pollDesc).wait(0xc000114660?, 0xc0001bd000?, 0x1)
    internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
    internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000114660, {0xc0001bd000, 0x1000, 0x1000})
    internal/poll/fd_unix.go:167 +0x25a
os.(*File).read(...)
    os/file_posix.go:31
os.(*File).Read(0xc00011c058, {0xc0001bd000?, 0x400?, 0xd07da0?})
    os/file.go:119 +0x5e
bufio.(*Reader).Read(0xc0002a5f40, {0xc0000f0400, 0x400, 0x0?})
    bufio/bufio.go:237 +0x1bb
github.com/hashicorp/go-plugin.copyChan({0xfdf270, 0xc0004cfb80}, 0x0?, {0xfd2400?, 0xc00011c058?})
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:184 +0x1f6
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:40 +0xf5
goroutine 12 [IO wait]:
internal/poll.runtime_pollWait(0x7fb652634140, 0x72)
    runtime/netpoll.go:305 +0x89
internal/poll.(*pollDesc).wait(0xc000114720?, 0xc000138000?, 0x1)
    internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
    internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000114720, {0xc000138000, 0x1000, 0x1000})
    internal/poll/fd_unix.go:167 +0x25a
os.(*File).read(...)
    os/file_posix.go:31
os.(*File).Read(0xc00011c068, {0xc000138000?, 0x400?, 0xd07da0?})
    os/file.go:119 +0x5e
bufio.(*Reader).Read(0xc000081f40, {0xc00013a000, 0x400, 0x0?})
    bufio/bufio.go:237 +0x1bb
github.com/hashicorp/go-plugin.copyChan({0xfdf270, 0xc0004cfb80}, 0x0?, {0xfd2400?, 0xc00011c068?})
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:184 +0x1f6
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
    github.com/hashicorp/go-plugin@v1.5.1/grpc_stdio.go:41 +0x185
goroutine 14 [syscall]:
os/signal.signal_recv()
    runtime/sigqueue.go:152 +0x2f
os/signal.loop()
    os/signal/signal_unix.go:23 +0x19
created by os/signal.Notify.func1.1
    os/signal/signal.go:151 +0x2a
goroutine 15 [chan receive]:
github.com/hashicorp/go-plugin.Serve.func3()
    github.com/hashicorp/go-plugin@v1.5.1/server.go:439 +0x75
created by github.com/hashicorp/go-plugin.Serve
    github.com/hashicorp/go-plugin@v1.5.1/server.go:436 +0x12aa
goroutine 16 [IO wait]:
internal/poll.runtime_pollWait(0x7fb652634410, 0x72)
    runtime/netpoll.go:305 +0x89
Error: The terraform-provider-fivetran_v1.1.8 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.
beevital commented 6 months ago

@z0rc gotcha, found similar error there. Yep, will fix it!

beevital commented 6 months ago

@z0rc try please 1.1.9, I've fixed other race conditions.

z0rc commented 6 months ago

@beevital with 1.1.9 terraform plan passed successfully. There was number of inplace updates about value sensitivity, for which terraform apply passed successfully and connectors configuration in fivetran actually didn't change.

There is one resource that still crashes plugin on terraform apply though:

resource "fivetran_connector" "jira" {
  group_id = data.fivetran_group.group.id
  service  = "jira"

  destination_schema {
    name = "jira"
  }

  config {
    host            = "example.atlassian.net"
    port            = "443"
    consumer_key    = "OauthKey"
    consumer_secret = data.vault_kv_secret_v2.jira.data.fivetran_oauth_key
  }
}
% terraform apply

...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # fivetran_connector.jira will be updated in-place
  ~ resource "fivetran_connector" "jira" {
      ~ connected_by       = "realization_deflate" -> (known after apply)
      ~ created_at         = "2020-07-31 15:24:37.131774 +0000 UTC" -> (known after apply)
      ~ id                 = "gents_start" -> (known after apply)
      ~ name               = "jira" -> (known after apply)
      + run_setup_tests    = (known after apply)
      + trust_certificates = (known after apply)
      + trust_fingerprints = (known after apply)
        # (2 unchanged attributes hidden)

      ~ config {
          + abs_connection_string                               = (known after apply)
          + abs_container_name                                  = (known after apply)
          + access_key                                          = (known after apply)
          + access_key_id                                       = (known after apply)
          + access_token                                        = (sensitive value)
          + account                                             = (known after apply)
          + account_id                                          = (known after apply)
          + account_key                                         = (sensitive value)
          + action_report_time                                  = (known after apply)
          + agent_host                                          = (known after apply)
          + agent_ora_home                                      = (known after apply)
          + agent_password                                      = (sensitive value)
          + agent_port                                          = (known after apply)
          + agent_public_cert                                   = (known after apply)
          + agent_user                                          = (known after apply)
          + aggregation                                         = (known after apply)
          + always_encrypted                                    = (known after apply)
          + api_access_token                                    = (sensitive value)
          + api_environment                                     = (known after apply)
          + api_key                                             = (sensitive value)
          + api_quota                                           = (known after apply)
          + api_requests_per_minute                             = (known after apply)
          + api_secret                                          = (sensitive value)
          + api_token                                           = (sensitive value)
          + api_type                                            = (known after apply)
          + api_url                                             = (known after apply)
          + api_version                                         = (known after apply)
          + app_sync_mode                                       = (known after apply)
          + append_file_option                                  = (known after apply)
          + archive_pattern                                     = (known after apply)
          + are_soap_credentials_provided                       = (known after apply)
          + asm_option                                          = (known after apply)
          + asm_oracle_home                                     = (known after apply)
          + asm_password                                        = (sensitive value)
          + asm_tns                                             = (known after apply)
          + asm_user                                            = (known after apply)
          + auth                                                = (known after apply)
          + auth_mode                                           = (known after apply)
          ~ auth_type                                           = "OAUTH" -> (known after apply)
          + authorization_method                                = (known after apply)
          + aws_region_code                                     = (known after apply)
          + base_url                                            = (known after apply)
          + bucket                                              = (known after apply)
          + bucket_name                                         = (known after apply)
          + bucket_service                                      = (known after apply)
          + certificate                                         = (known after apply)
          + click_attribution_window                            = (known after apply)
          + client_id                                           = (known after apply)
          + client_name                                         = (known after apply)
          + client_secret                                       = (sensitive value)
          + cloud_storage_type                                  = (known after apply)
          + company_id                                          = (known after apply)
          + compression                                         = (known after apply)
          + config_method                                       = (known after apply)
          + config_type                                         = (known after apply)
          + connection_method                                   = (known after apply)
          + connection_string                                   = (known after apply)
          + connection_type                                     = (known after apply)
          + consumer_group                                      = (known after apply)
          + consumer_key                                        = (sensitive value)
          + consumer_secret                                     = (sensitive value)
          + container_name                                      = (known after apply)
          + conversion_report_time                              = (known after apply)
          + conversion_window_size                              = (known after apply)
          + csv_definition                                      = (known after apply)
          + customer_id                                         = (known after apply)
          + customer_list_id                                    = (known after apply)
          + daily_api_call_limit                                = (known after apply)
          + data_access_method                                  = (known after apply)
          + data_center                                         = (known after apply)
          + database                                            = (known after apply)
          + dataset_id                                          = (known after apply)
          + datasource                                          = (known after apply)
          + date_granularity                                    = (known after apply)
          + delimiter                                           = (known after apply)
          + distributed_connector_cluster_size                  = (known after apply)
          + domain                                              = (known after apply)
          + domain_host_name                                    = (known after apply)
          + domain_name                                         = (known after apply)
          + domain_type                                         = (known after apply)
          + email                                               = (known after apply)
          + empty_header                                        = (known after apply)
          + enable_all_dimension_combinations                   = (known after apply)
          + enable_archive_log_only                             = (known after apply)
          + enable_data_extensions_syncing                      = (known after apply)
          + enable_distributed_connector_mode                   = (known after apply)
          + enable_enrichments                                  = (known after apply)
          + enable_exports                                      = (known after apply)
          + enable_tde                                          = (known after apply)
          + encryption_key                                      = (sensitive value)
          + endpoint                                            = (known after apply)
          + engagement_attribution_window                       = (known after apply)
          + entity_id                                           = (known after apply)
          + environment                                         = (known after apply)
          + escape_char                                         = (known after apply)
          + eu_region                                           = (known after apply)
          + export_storage_type                                 = (known after apply)
          + external_id                                         = (known after apply)
          + file_type                                           = (known after apply)
          + finance_account_sync_mode                           = (known after apply)
          + folder_id                                           = (known after apply)
          + ftp_host                                            = (known after apply)
          + ftp_password                                        = (sensitive value)
          + ftp_port                                            = (known after apply)
          + ftp_user                                            = (known after apply)
          + function                                            = (known after apply)
          + function_app                                        = (known after apply)
          + function_key                                        = (known after apply)
          + function_name                                       = (known after apply)
          + function_trigger                                    = (sensitive value)
          + gcs_bucket                                          = (known after apply)
          + gcs_folder                                          = (known after apply)
          + group_name                                          = (known after apply)
          + has_manage_permissions                              = (known after apply)
          + home_folder                                         = (known after apply)
          + identity                                            = (known after apply)
          + include_ocapi_endpoints                             = (known after apply)
          + instance                                            = (known after apply)
          + integration_key                                     = (known after apply)
          + is_account_level_connector                          = (known after apply)
          + is_auth2_enabled                                    = (known after apply)
          + is_custom_api_credentials                           = (known after apply)
          + is_external_activities_endpoint_selected            = (known after apply)
          + is_ftps                                             = (known after apply)
          + is_keypair                                          = (known after apply)
          + is_multi_entity_feature_enabled                     = (known after apply)
          + is_new_package                                      = (known after apply)
          + is_private_key_encrypted                            = (known after apply)
          + is_private_link_required                            = (known after apply)
          + is_public                                           = (known after apply)
          + is_sailthru_connect_enabled                         = (known after apply)
          + is_secure                                           = (known after apply)
          + is_single_table_mode                                = (known after apply)
          + is_vendor                                           = (known after apply)
          + key                                                 = (known after apply)
          + last_synced_changes__utc_                           = (known after apply)
          + latest_version                                      = (known after apply)
          + limit_for_api_calls_to_external_activities_endpoint = (known after apply)
          + list_strategy                                       = (known after apply)
          + login_password                                      = (sensitive value)
          + merchant_id                                         = (known after apply)
          + message_type                                        = (known after apply)
          + named_range                                         = (known after apply)
          + network_code                                        = (known after apply)
          + null_sequence                                       = (known after apply)
          + oauth_token                                         = (sensitive value)
          + oauth_token_secret                                  = (sensitive value)
          + on_error                                            = (known after apply)
          ~ on_premise                                          = false -> (known after apply)
          + organization                                        = (known after apply)
          + organization_id                                     = (known after apply)
          + passphrase                                          = (sensitive value)
          + password                                            = (sensitive value)
          + pat                                                 = (sensitive value)
          + path                                                = (known after apply)
          + pattern                                             = (known after apply)
          + pdb_name                                            = (known after apply)
          + pem_certificate                                     = (sensitive value)
          + post_click_attribution_window_size                  = (known after apply)
          + prebuilt_report                                     = (known after apply)
          + prefix                                              = (known after apply)
          + private_key                                         = (sensitive value)
          + project_id                                          = (known after apply)
          + public_key                                          = (known after apply)
          + publication_name                                    = (known after apply)
          + query_id                                            = (known after apply)
          + region                                              = (known after apply)
          + region_api_url                                      = (known after apply)
          + region_auth_url                                     = (known after apply)
          + region_token_url                                    = (known after apply)
          + replica_id                                          = (known after apply)
          + replication_slot                                    = (known after apply)
          + report_type                                         = (known after apply)
          + report_url                                          = (known after apply)
          + resource_url                                        = (known after apply)
          + rest_api_limit                                      = (known after apply)
          + role                                                = (known after apply)
          + role_arn                                            = (sensitive value)
          + rollback_window_size                                = (known after apply)
          + s3bucket                                            = (known after apply)
          + s3external_id                                       = (known after apply)
          + s3folder                                            = (known after apply)
          + s3role_arn                                          = (sensitive value)
          + sales_account_sync_mode                             = (known after apply)
          + sap_user                                            = (known after apply)
          + secret                                              = (sensitive value)
          + secret_key                                          = (sensitive value)
          + secrets                                             = (sensitive value)
          + security_protocol                                   = (known after apply)
          + server                                              = (known after apply)
          + server_url                                          = (known after apply)
          + service_version                                     = (known after apply)
          + sftp_host                                           = (known after apply)
          + sftp_is_key_pair                                    = (known after apply)
          + sftp_password                                       = (sensitive value)
          + sftp_port                                           = (known after apply)
          + sftp_user                                           = (known after apply)
          + share_url                                           = (known after apply)
          + sheet_id                                            = (known after apply)
          + shop                                                = (known after apply)
          + short_code                                          = (sensitive value)
          + show_records_with_no_metrics                        = (known after apply)
          + sid                                                 = (known after apply)
          + site_id                                             = (known after apply)
          + skip_after                                          = (known after apply)
          + skip_before                                         = (known after apply)
          + soap_uri                                            = (known after apply)
          + source                                              = (known after apply)
          + sub_domain                                          = (known after apply)
          + subdomain                                           = (known after apply)
          + subscriber_name                                     = (known after apply)
          + support_connected_accounts_sync                     = (known after apply)
          + support_nested_columns                              = (known after apply)
          + swipe_attribution_window                            = (known after apply)
          + sync_data_locker                                    = (known after apply)
          + sync_format                                         = (known after apply)
          + sync_formula_fields                                 = (known after apply)
          + sync_metadata                                       = (known after apply)
          + sync_method                                         = (known after apply)
          ~ sync_mode                                           = "ALL" -> (known after apply)
          + sync_multiple_accounts                              = (known after apply)
          + sync_pack_mode                                      = (known after apply)
          + sync_pull_api                                       = (known after apply)
          + sync_type                                           = (known after apply)
          + technical_account_id                                = (known after apply)
          + test_table_name                                     = (known after apply)
          + time_zone                                           = (known after apply)
          + timeframe_months                                    = (known after apply)
          + tns                                                 = (known after apply)
          + token_key                                           = (sensitive value)
          + token_secret                                        = (sensitive value)
          + tunnel_host                                         = (known after apply)
          + tunnel_port                                         = (known after apply)
          + tunnel_user                                         = (known after apply)
          + unique_id                                           = (known after apply)
          + update_config_on_each_sync                          = (known after apply)
          + update_method                                       = (known after apply)
          + uri                                                 = (known after apply)
          + use_api_keys                                        = (known after apply)
          + use_customer_bucket                                 = (known after apply)
          + use_oracle_rac                                      = (known after apply)
          + use_pgp_encryption_options                          = (known after apply)
          + use_service_account                                 = (known after apply)
          + use_template_labels                                 = (known after apply)
          + use_webhooks                                        = (known after apply)
          + use_workspace                                       = (known after apply)
          + user                                                = (known after apply)
          + user_id                                             = (known after apply)
          + user_key                                            = (known after apply)
          + user_name                                           = (known after apply)
          + username                                            = (known after apply)
          + view_attribution_window                             = (known after apply)
          + view_through_attribution_window_size                = (known after apply)
          + workspace_same_as_source                            = (known after apply)
            # (2 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

fivetran_connector.jira: Modifying... [id=gents_start]
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-fivetran_v1.1.9 plugin:

panic: interface conversion: interface {} is string, not float64

goroutine 15 [running]:
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.getValue({0x1017192c8, 0x101d19dd0}, {0x1015b5d00?, 0x140000984b0?}, {0x1015b5480?, 0x14000034520?}, 0x140003f5b48?, 0x14000778a50, {0x1400003423c, 0x4})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector_config.go:129 +0x5b0
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.getValue({0x101719508, 0x14000dfc570}, {0x1015fc3c0?, 0x14000dfc4e0?}, {0x1015fc3c0?, 0x14000dfc750?}, 0x140008d4870?, 0x0, {0x1400003423c, 0x4})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector_config.go:161 +0xb34
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.(*ConnectorResourceModel).ReadFromContainer(0x140000a4200, {{0x14000034230, 0xb}, {0x14000034268, 0x4}, {0x140000a3590, 0x13}, {0x140003bc210, 0x24}, {0x140000a3578, ...}, ...})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector.go:233 +0x248
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model.(*ConnectorResourceModel).ReadFromCreateResponse(_, {{{0x140000341d8, 0x7}, {0x1400003a440, 0x1a}}, {{{{...}, {...}, {...}, 0x14000034260, {...}, ...}, ...}, ...}})
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/core/model/connector.go:138 +0x84
github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources.(*connector).Update(0x140005cc068, {0x101716180, 0x140003ff2c0}, {{{{0x10171ae18, 0x140007e6480}, {0x1015fbb20, 0x140006b0fc0}}, {0x10171c748, 0x1400022e8c0}}, {{{0x10171ae18, ...}, ...}, ...}, ...}, ...)
    github.com/fivetran/terraform-provider-fivetran/fivetran/framework/resources/connector.go:287 +0xf2c
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).UpdateResource(0x14000156000, {0x101716180, 0x140003ff2c0}, 0x140003f72d0, 0x140003f71e0)
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/fwserver/server_updateresource.go:122 +0x51c
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0x101716180?, {0x101716180, 0x140003ff2c0}, 0x14000994e60, 0x140003f7400)
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/fwserver/server_applyresourcechange.go:102 +0x118
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0x14000156000, {0x101716180?, 0x140003ff170?}, 0x14000994e10)
    github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/proto6server/server_applyresourcechange.go:55 +0x1a4
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x1017160d8?, {0x101716180?, 0x140003fee40?}, 0x14000994e10)
    github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x140004bbc20, {0x101716180?, 0x140003fe450?}, 0x14000169730)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/tf6server/server.go:857 +0x3b8
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1016d85e0?, 0x140004bbc20}, {0x101716180, 0x140003fe450}, 0x140001696c0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000f41e0, {0x10171b2e0, 0x14000216d00}, 0x140009ccfc0, 0x14000203e00, 0x101cdbc18, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1360 +0xc88
google.golang.org/grpc.(*Server).handleStream(0x140000f41e0, {0x10171b2e0, 0x14000216d00}, 0x140009ccfc0, 0x0)
    google.golang.org/grpc@v1.57.0/server.go:1737 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.57.0/server.go:982 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.57.0/server.go:980 +0x16c

Error: The terraform-provider-fivetran_v1.1.9 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.
beevital commented 6 months ago

Aha, thank you! I know where to dig here. Looks like we will have 1.1.10 =)

beevital commented 6 months ago

@z0rc jira connector doesn't support consumer_key and consumer_secret fields. IDK how it was working before, probably it was just ignored. But we don't have such fields supported:

https://fivetran.com/docs/rest-api/connectors/config#jira

beevital commented 6 months ago

As a WA I'd suggest to re-import this connector into your state without these fields. The problem is that API doesn't return any value in response for these fields (they doesn't exist in upstream).

But actual issue with value type conversion is weird. Looking into it...

beevital commented 6 months ago

Also - I'm currently supporting state import for migrated resources, so please wait for the next release before reimporting connectors. Right now connector resource doesn't support import op

z0rc commented 6 months ago

@beevital thanks, I'll reimport jira connector resource with correct config on next release. Probably this resource was incorrectly imported/configured since inception and I'm finally got to clean it up.

beevital commented 6 months ago

@z0rc I've release v1.1.10 - check it please.

z0rc commented 6 months ago

@beevital I upgraded provider to 1.1.10, removed fivetran_connector.jira from state, imported it again and updated configuration to following:

resource "fivetran_connector" "jira" {
  group_id = data.fivetran_group.group.id
  service  = "jira"

  destination_schema {
    name = "jira"
  }

  config {
    host       = "example.atlassian.net"
    port       = "443"
    on_premise = false
    auth_type  = "OAUTH"
    # consumer_key    = "OauthKey"
    # consumer_secret = data.vault_kv_secret_v2.jira.data.fivetran_oauth_key
    sync_mode = "ALL"
  }
}

We're using OAuth for this connector, and this case isn't covered in API documentation. After some trial and error and sniffing responses in web ui this is configuration that finally worked.

Screenshot 2024-01-18 at 16 39 15

In the mean time I had plugin crashes, but unfortunately I didn't save pristine logs, and with current state I cannot reproduce the crashes.

In the end I'm opting to drop this resource from terraform state, it's too brittle and benefits of having it in terraform are minuscule.

beevital commented 6 months ago

Hey @z0rc, I'm not actually sure that the jira connector actually supports auth via API. So finally you've got the working configuration? Can we close the issue for now?

z0rc commented 5 months ago

@beevital all good on my side, thanks. Closing.