Skip to content
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

RDS engine version comparison causes panic #20860

Closed
ajjohnston opened this issue Sep 9, 2021 · 2 comments · Fixed by #23039
Closed

RDS engine version comparison causes panic #20860

ajjohnston opened this issue Sep 9, 2021 · 2 comments · Fixed by #23039
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/rds Issues and PRs that pertain to the rds service.

Comments

@ajjohnston
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

$ terraform -v
Terraform v1.0.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.57.0

Affected Resource(s)

  • aws_rds_cluster

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_rds_cluster" "staging-aurora-cluster" {
  port                 = 3306
  engine               = "aurora-mysql"
  engine_mode          = "serverless"
  engine_version       = "5.7.mysql_aurora.2.08.3"

  master_username        = var.staging-mysql-root-un
  master_password        = var.staging-mysql-root-pw
  db_subnet_group_name   = aws_db_subnet_group.rds-subnet-group.name
  vpc_security_group_ids = [aws_security_group.staging-db.id]
  
  skip_final_snapshot     = false
  apply_immediately       = true
  backup_retention_period = 5 # days
  deletion_protection     = true

  scaling_configuration {
    auto_pause               = true
    min_capacity             = 1
    max_capacity             = 16
    seconds_until_auto_pause = 300
    timeout_action           = "RollbackCapacityChange"
  }
}

Panic Output

Stack trace from the terraform-provider-aws_v3.57.0_x5 plugin:

panic: runtime error: slice bounds out of range [:35] with capacity 32

goroutine 258 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.compareActualEngineVersion(0xc0027d4e00, 0xc0027e3ef0, 0x22, 0xc000bb1f98, 0x17)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_rds_cluster.go:1513 +0x28a
github.com/terraform-providers/terraform-provider-aws/aws.rdsClusterSetResourceDataEngineVersionFromCluster(0xc0027d4e00, 0xc000c26a00)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_rds_cluster.go:1509 +0x9c
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsRDSClusterRead(0xc0027d4e00, 0x66420e0, 0xc001c08000, 0xba2b140, 0xc001b80000)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_rds_cluster.go:1065 +0xabb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000a9afc0, 0x806b608, 0xc002318200, 0xc0027d4e00, 0x66420e0, 0xc001c08000, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/gdavison/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:335 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a9afc0, 0x806b608, 0xc002318200, 0xc000f2cbd0, 0x66420e0, 0xc001c08000, 0xc000692dc0, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/gdavison/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:624 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0001b4ee8, 0x806b608, 0xc002318200, 0xc002318240, 0xc002318200, 0x40b965, 0x6f9e500)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/gdavison/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:575 +0x43b
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc000fae240, 0x806b6b0, 0xc002318200, 0xc00230fb00, 0xc000fae240, 0xc002305b90, 0xc000b2eba0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/server/server.go:298 +0x105
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x7288080, 0xc000fae240, 0x806b6b0, 0xc002305b90, 0xc00230faa0, 0x0, 0x806b6b0, 0xc002305b90, 0xc001ca2e00, 0x6d2)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003ae8c0, 0x808d9b8, 0xc00125ef00, 0xc0027e8800, 0xc0028824e0, 0xb9e96d0, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0003ae8c0, 0x808d9b8, 0xc00125ef00, 0xc0027e8800, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0008bf7c0, 0xc0003ae8c0, 0x808d9b8, 0xc00125ef00, 0xc0027e8800)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:857 +0x1fd

Error: The terraform-provider-aws_v3.57.0_x5 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.

Expected Behavior

Version comparison works correctly.

Actual Behavior

Version comparison causes a crash.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/rds Issues and PRs that pertain to the rds service. labels Sep 9, 2021
@ajjohnston
Copy link
Contributor Author

ajjohnston commented Sep 9, 2021

Looks like this can happen if oldVersion is larger than newVersion in the comparison function

func compareActualEngineVersion(d *schema.ResourceData, oldVersion string, newVersion string) {
if oldVersion != newVersion && string(append([]byte(oldVersion), []byte(".")...)) != string([]byte(newVersion)[0:len(oldVersion)+1]) {
d.Set("engine_version", newVersion)
}
d.Set("engine_version_actual", newVersion)
}

@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 9, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants