Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
546 stars 419 forks source link

Okta Authentication Crashes on v0.88.0 (And All Previous Versions with Okta Auth) #2699

Closed joshcazalas closed 6 months ago

joshcazalas commented 6 months ago

Terraform CLI and Provider Versions

Terraform Version 1.7.5 registry.terraform.io/snowflake-labs/snowflake v0.88.0

Terraform Configuration

provider "snowflake" {
  account       = <ACCOUNT>.<REGION>
  user          = <USERNAME>
  password   = <PASSWORD>
  role          = <ROLE>
  authenticator = "Okta"
  okta_url = "<OKTA_URL>"
}

Expected Behavior

Terraform should be able to connect to Snowflake using Okta authentication

Actual Behavior

The Terraform provider crashes:

Error: Plugin did not respond

The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain more details.

Stack trace from the terraform-provider-snowflake_v0.88.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x55a184]

goroutine 66 [running]: net/url.(URL).ResolveReference(0x0, 0xc000a9dd40) net/url/url.go:1082 +0x84 net/url.(URL).Parse(0xc000e236b4?, {0xc000e236b4?, 0xb?}) net/url/url.go:1070 +0x3f github.com/snowflakedb/gosnowflake.postBackURL({0xc000f5a000, 0x6119, 0x7000}) github.com/snowflakedb/gosnowflake@v1.7.1/authokta.go:189 +0x1aa github.com/snowflakedb/gosnowflake.authenticateBySAML({0x2452b10, 0x349eee0}, 0xc0008d9040, 0xc0008d0900, {0xc0007b5be1, 0x1c}, {0xc0007b5ba4, 0xb}, {0xc0007b5b80, 0x11}, ...) github.com/snowflakedb/gosnowflake@v1.7.1/authokta.go:156 +0xc2e github.com/snowflakedb/gosnowflake.authenticateWithConfig(0xc000898480) github.com/snowflakedb/gosnowflake@v1.7.1/auth.go:534 +0x35a github.com/snowflakedb/gosnowflake.SnowflakeDriver.OpenWithConfig({}, {, }, {{0xc0007b5ba4, 0xb}, {0xc0007b5b80, 0x11}, {0xc0009f2570, 0xf}, {0x0, ...}, ...}) github.com/snowflakedb/gosnowflake@v1.7.1/driver.go:43 +0x148 github.com/snowflakedb/gosnowflake.SnowflakeDriver.Open({}, {0xc0007b5b80, 0x12e}) github.com/snowflakedb/gosnowflake@v1.7.1/driver.go:26 +0x112 github.com/luna-duclos/instrumentedsql.dsnConnector.Connect(...) github.com/luna-duclos/instrumentedsql@v1.1.3/connector.go:53 github.com/luna-duclos/instrumentedsql.wrappedConnector.Connect({{{0x243a340, 0x21b63a0}, {0x243ca60, 0x349eee0}, 0x0, 0x0}, {0x24423b8, 0xc0009724c0}, 0xc0008bd9c0}, {0x2452b10, ...}) github.com/luna-duclos/instrumentedsql@v1.1.3/connector.go:33 +0x1ec database/sql.(DB).conn(0xc0008d8f70, {0x2452b10, 0x349eee0}, 0x1) database/sql/sql.go:1387 +0x717 database/sql.(DB).PingContext.func1(0xa0?) database/sql/sql.go:850 +0x3a database/sql.(DB).retry(0xc000bc9aa0?, 0xc000d1cd28) database/sql/sql.go:1538 +0x42 database/sql.(DB).PingContext(0xc0008d8f70, {0x2452b10?, 0x349eee0}) database/sql/sql.go:849 +0x94 database/sql.(DB).Ping(...) database/sql/sql.go:867 github.com/jmoiron/sqlx.Connect({0x20df1fe?, 0x16?}, {0xc0007b5b80?, 0xc0008bd980?}) github.com/jmoiron/sqlx@v1.3.5/sqlx.go:642 +0x48 github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.NewClient(0x0?) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/client.go:151 +0x12f github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider.ConfigureProvider(0x20a0ed5?) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/provider.go:786 +0x19b2 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Provider).Configure(0xc000bd16e0, {0x2452b48, 0xc000bc8c60}, 0xc0008becd0) github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/provider.go:296 +0x1b8 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ConfigureProvider(0xc000e94330, {0x2452b48?, 0xc000b6dec0?}, 0xc0006746f0) github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:607 +0x3a9 github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ConfigureProvider({{0x24689e0?, 0xc000e94330?}}, {0x2452b48?, 0xc000b6dec0?}, 0xc000674690?) github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:80 +0x182 github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(muxServer).ConfigureProvider(0xc000cb4000, {0x2452b48?, 0xc000b6dbc0?}, 0xc000b6db90?) github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ConfigureProvider.go:28 +0x14f github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(server).ConfigureProvider(0xc000bfe6e0, {0x2452b48?, 0xc000b6d3b0?}, 0xc0008bd400) github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:568 +0x2ba github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ConfigureProvider_Handler({0x2026fc0?, 0xc000bfe6e0}, {0x2452b48, 0xc000b6d3b0}, 0xc0008cdd80, 0x0) github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:449 +0x169 google.golang.org/grpc.(Server).processUnaryRPC(0xc0000ded20, {0x2452b48, 0xc000b6d320}, {0x2463c60, 0xc000007d40}, 0xc000b9a120, 0xc0008b3590, 0x345ae10, 0x0) google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03 google.golang.org/grpc.(Server).handleStream(0xc0000ded20, {0x2463c60, 0xc000007d40}, 0xc000b9a120) google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec google.golang.org/grpc.(Server).serveStreams.func2.1() google.golang.org/grpc@v1.60.0/server.go:1016 +0x59 created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 38 google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

Error: The terraform-provider-snowflake_v0.88.0 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.

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

The provider crashes any time it attempts to connect to Snowflake. When running terraform plan, it hangs on the refreshing state step when it hits Snowflake resources. Same for Terraform Apply.

We've tried rolling back versions to solve this issue, but these crashes are happening on every version all the way back to 0.74.0 when the updated provider config (and Okta auth) was introduced.

joshcazalas commented 6 months ago

The project with this issue uses this configuration:

Terraform v1.3.9 on linux_amd64

After further testing, when spinning up a new test project only using this configuration, the Okta auth works:

Terraform v1.3.9 on linux_amd64

At this point I'm not sure if the issue is due to multiple providers or something else entirely

joshcazalas commented 6 months ago

Closing issue. Crashes were due to an internal issue.