PGSSoft / terraform-provider-mssql

MS SQL Terraform provider
MIT License
17 stars 9 forks source link

provider crashes when creating resouces using atlantis #97

Closed Krad-dono closed 1 year ago

Krad-dono commented 1 year ago

Hello,

another issue. So when run locally on my laptop resources are provisioned, but when we try to use GitOps approach and do apply using Atlantis plugin crashes. We have no idea what is happening. Hope this trace makes more sense to you:

Plan: 1 to add, 0 to change, 0 to destroy. module.safire-sql-01.mssql_script.create_a_db[0]: Creating... module.safire-sql-01.mssql_script.create_a_db[0]: Still creating... [10s elapsed]

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-mssql_v0.5.0 plugin:

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

goroutine 39 [running]: database/sql.(DB).conn(0x0, {0x1227e40, 0xc0007ab530}, 0x1) database/sql/sql.go:1288 +0x53 database/sql.(DB).query(0xe83140?, {0x1227e40, 0xc0007ab530}, {0xc0007802a0, 0x59}, {0x0, 0x0, 0x0}, 0x30?) database/sql/sql.go:1730 +0x5d database/sql.(DB).QueryContext(0xc00053ecc0?, {0x1227e40, 0xc0007ab530}, {0xc0007802a0, 0x59}, {0x0, 0x0, 0x0}) database/sql/sql.go:1708 +0xda github.com/PGSSoft/terraform-provider-mssql/internal/sql.(database).Query(0x122a480?, {0x1227e40, 0xc0007ab530}, {0xc0007802a0, 0x59}) github.com/PGSSoft/terraform-provider-mssql/internal/sql/database.go:148 +0x79 github.com/PGSSoft/terraform-provider-mssql/internal/services/script.(res).queryState.func2() github.com/PGSSoft/terraform-provider-mssql/internal/services/script/resource.go:131 +0x82 github.com/PGSSoft/terraform-provider-mssql/internal/utils.errorMonad.Then({{0x1227e40?, 0xc0007ab530?}}, 0xc0007483c0) github.com/PGSSoft/terraform-provider-mssql/internal/utils/errorHandling.go:15 +0x42 github.com/PGSSoft/terraform-provider-mssql/internal/services/script.(res).queryState(, {, }, {, }, {{0x1, 0x0, {0x0, 0x0}, 0x0, ...}, ...}) github.com/PGSSoft/terraform-provider-mssql/internal/services/script/resource.go:131 +0x228 github.com/PGSSoft/terraform-provider-mssql/internal/services/script.(res).Create.func1() github.com/PGSSoft/terraform-provider-mssql/internal/services/script/resource.go:80 +0x7e github.com/PGSSoft/terraform-provider-mssql/internal/utils.errorMonad.Then({{0x1227e40?, 0xc0007ab530?}}, 0xc000748360) github.com/PGSSoft/terraform-provider-mssql/internal/utils/errorHandling.go:15 +0x42 github.com/PGSSoft/terraform-provider-mssql/internal/core/resource.monadRequest.Then(...) github.com/PGSSoft/terraform-provider-mssql/internal/core/resource/resource.go:24 github.com/PGSSoft/terraform-provider-mssql/internal/services/script.(res).Create(, {, }, {{{{0x1221c40, 0xc00078c650}}, {0x122a480, 0xc000096140}}, {{0x1, 0x0, {0x0, ...}, ...}, ...}}, ...) github.com/PGSSoft/terraform-provider-mssql/internal/services/script/resource.go:80 +0x142 github.com/PGSSoft/terraform-provider-mssql/internal/core/resource.(resourceWrapper[...]).Create(, {, _}, {{{{0x122ed08, 0xc0007aa150}, {0xed4660, 0xc000549800}}, {0xc000581e30, 0x0, 0x0, ...}}, ...}, ...) github.com/PGSSoft/terraform-provider-mssql/internal/core/resource/resourceWrapper.go:66 +0x2f7 github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(Server).CreateResource(0xc0003cc2c0, {0x1227e40, 0xc000549320}, 0xc000697410, 0xc0006973b0) github.com/hashicorp/terraform-plugin-framework@v0.15.0/internal/fwserver/server_createresource.go:97 +0x8ce github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(Server).ApplyResourceChange(0x1227e40?, {0x1227e40, 0xc000549320}, 0xc0004fe320, 0xc000697580) github.com/hashicorp/terraform-plugin-framework@v0.15.0/internal/fwserver/server_applyresourcechange.go:54 +0x4a8 github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(Server).ApplyResourceChange(0xc0003cc2c0, {0x1227e40?, 0xc0005490e0?}, 0xc0004fe2d0) github.com/hashicorp/terraform-plugin-framework@v0.15.0/internal/proto6server/server_applyresourcechange.go:52 +0x27b github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(server).ApplyResourceChange(0xc0000006e0, {0x1227e40?, 0xc0005483f0?}, 0xc0001a40e0) github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov6/tf6server/server.go:816 +0x574 github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1004740?, 0xc0000006e0}, {0x1227e40, 0xc0005483f0}, 0xc0001a4070, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:385 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0xc000554000, {0x122f060, 0xc000102820}, 0xc000706000, 0xc0005491a0, 0x195a840, 0x0) google.golang.org/grpc@v1.48.0/server.go:1295 +0xb2b google.golang.org/grpc.(Server).handleStream(0xc000554000, {0x122f060, 0xc000102820}, 0xc000706000, 0x0) google.golang.org/grpc@v1.48.0/server.go:1636 +0xa2f google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.48.0/server.go:932 +0x98 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.48.0/server.go:930 +0x28a

Error: The terraform-provider-mssql_v0.5.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.

tkielar-pgs commented 1 year ago

The crash is caused by a bug in error handling mechanism. I'll have a look at fixing. In the meantime, I'm guessing that in your case it fails to connect to the server. Please check your credentials

Krad-dono commented 1 year ago

The crash is caused by a bug in error handling mechanism. I'll have a look at fixing. In the meantime, I'm guessing that in your case it fails to connect to the server. Please check your credentials

Yes, the root cause that our internal teams narrowed down are related to connectivity issues. Sadly this crash didn't indicate that in any way. It would be great if it just say - can't connect, failed to create resource.