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

fix composite alert crash #226

Merged
merged 1 commit into from
May 28, 2024
Merged

fix composite alert crash #226

merged 1 commit into from
May 28, 2024

Conversation

MisterSquishy
Copy link
Contributor

fixes a latent bug in composite alerts, in which a drop-and-recreate of a subalert causes an OOB panic:

Stack trace from the terraform-provider-lightstep_v1.95.2 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 258 [running]:
github.com/lightstep/terraform-provider-lightstep/lightstep.buildCompositeAlert(0x12bd7b8?)
	github.com/lightstep/terraform-provider-lightstep/lightstep/resource_metric_condition.go:1109 +0x5e5
github.com/lightstep/terraform-provider-lightstep/lightstep.getUnifiedConditionAttributesFromResource(0x5b9a6a?, 0x1)
	github.com/lightstep/terraform-provider-lightstep/lightstep/resource_metric_condition.go:653 +0x1d9
github.com/lightstep/terraform-provider-lightstep/lightstep.(*resourceUnifiedConditionImp).resourceUnifiedConditionUpdate(0xc00035de88, {0xdb6048, 0xc0003e1b90}, 0xc0005bda00, {0xc8bcc0?, 0xc000114600?})
	github.com/lightstep/terraform-provider-lightstep/lightstep/resource_metric_condition.go:568 +0x94
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0004ccb60, {0xdb6080, 0xc00046a030}, 0xd?, {0xc8bcc0, 0xc000114600})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:741 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0004ccb60, {0xdb6080, 0xc00046a030}, 0xc000e51450, 0xc0001e9480, {0xc8bcc0, 0xc000114600})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:847 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000460d68, {0xdb6080?, 0xc000963e90?}, 0xc000d30140)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0003c2320, {0xdb6080?, 0xc000962690?}, 0xc00037e070)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xc6b2a0?, 0xc0003c2320}, {0xdb6080, 0xc000962690}, 0xc00037e000, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002ca1e0, {0xdb9a38, 0xc00012dd40}, 0xc0007a8000, 0xc000493290, 0x1280120, 0x0)
	google.golang.org/[email protected]/server.go:1336 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc0002ca1e0, {0xdb9a38, 0xc00012dd40}, 0xc0007a8000, 0x0)
	google.golang.org/[email protected]/server.go:1704 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-lightstep_v1.95.2 plugin crashed!

this bug seems to have been latent since composite alert support was introduced in #144; we appear to have noticed it but it went unfixed.

this PR is not a perfect fix; it is still unclear to me why a change to hidden_queries triggers a drop-and-recreate of an entire alert object (but a change to, say, query_string does not), or why a drop-and-recreate would show up as an empty alert object in the list. but this seems like the quickest way out of this mess

@MisterSquishy MisterSquishy merged commit a769a12 into main May 28, 2024
6 checks passed
@MisterSquishy MisterSquishy deleted the fix_composite_alert branch May 28, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants