PaloAltoNetworks / terraform-provider-panos

Terraform Panos provider
https://www.terraform.io/docs/providers/panos/
MIT License
89 stars 71 forks source link

Bug with th eplugin terraform provider - panos_v1.11.1 plugin crashed #426

Open crkg opened 8 months ago

crkg commented 8 months ago

During the terraform provider panos policy execution, it is found several time. the plugin crash.

Error - [2024-01-30T16:30:16.281Z] The plugin.(GRPCProvider).UpgradeResourceState request was cancelled. [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] Stack trace from the terraform-provider-panos_v1.11.1 plugin: [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] panic: runtime error: slice bounds out of range [:-1] [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] goroutine 949 [running]: [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/util.StripPanosPackaging({0xc0015fb400, 0x0, 0x200}, {0x1324670, 0x0}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/util/util.go:203 +0x395 [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/namespace.(Common).retrieve(0xc00037bd80, {0x1322c8d, 0x3}, {0xc007334900, 0x1260960, 0x9}, 0xb8, {0x0, 0xc00019cdc7}, 0x1, ...) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/namespace/common.go:130 +0xa2d [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/namespace.(Common).Objects(0xc0010841c0, {0x1322c8d, 0x3}, 0xc000ec5fe0, {0x11bfc80, 0xc001999200}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/namespace/common.go:45 +0xa5 [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/poli/security.(Panorama).GetAll(0xc0010841c0, {0xc000be2c40, 0xe}, {0xc000ec5fe0, 0xc}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/poli/security/pano.go:51 +0x9b [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/poli/security.(Panorama).ConfigureRules(0xc00174a030, {0xc000be2c40, 0xe}, {0xc000ec5fe0, 0xc}, {0xc007392000, 0x14, 0x14}, 0xc001ec9698, 0x0, ...) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/poli/security/pano.go:82 +0xdd [2024-01-30T16:30:16.281Z] github.com/terraform-providers/terraform-provider-panos/panos.createUpdateSecurityRuleGroup(0xc000253570, {0x131bda0, 0xc00000a1e0}) [2024-01-30T16:30:16.281Z] github.com/terraform-providers/terraform-provider-panos/panos/security_rules.go:209 +0x8f4 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc0009f8000, 0xc0032d2af0, 0xc0055b7020, {0x131bda0, 0xc00000a1e0}) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:326 +0x3e3 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc000215100, 0xc001ec9a68, 0xc006c7dc20, 0x28) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc00000ecf0, {0xc000252460, 0x4b5646}, 0xc000252460) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x12e14c0, 0xc00000ecf0}, {0x1572b90, 0xc004498b10}, 0xc00795e0c0, 0x0) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170 [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).processUnaryRPC(0xc0001cc380, {0x1583bc0, 0xc000210a80}, 0xc009c08e00, 0xc000304b70, 0x1d5c340, 0x0) [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).handleStream(0xc0001cc380, {0x1583bc0, 0xc000210a80}, 0xc009c08e00, 0x0) [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).serveStreams.func1.2() [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:859 +0x98 [2024-01-30T16:30:16.281Z] created by google.golang.org/grpc.(Server).serveStreams.func1 [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:857 +0x294 [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.282Z] Error: The terraform-provider-panos_v1.11.1 plugin crashed! [2024-01-30T16:30:16.282Z] [2024-01-30T16:30:16.282Z] This is always indicative of a bug within the plugin. It would be immensely [2024-01-30T16:30:16.282Z] helpful if you could report the crash with the plugin's maintainers so that it [2024-01-30T16:30:16.282Z] can be fixed. The output above should help diagnose the issue.

During the terraform apply, panos_security_policy_group it seems the provider is crashing for what ever reason. its found the similar occurence several times.

Expected behavior

The security policy execution should not have a provider crash, if so there should be a gracefull close of the provider. instead panic crashing.

Possible solution

Not sure

Steps to reproduce

  1. run resource "panos_securty_policy_group " for large rulesgroups

Screenshots

Error - [2024-01-30T16:30:16.281Z] The plugin.(GRPCProvider).UpgradeResourceState request was cancelled. [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] Stack trace from the terraform-provider-panos_v1.11.1 plugin: [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] panic: runtime error: slice bounds out of range [:-1] [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.281Z] goroutine 949 [running]: [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/util.StripPanosPackaging({0xc0015fb400, 0x0, 0x200}, {0x1324670, 0x0}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/util/util.go:203 +0x395 [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/namespace.(Common).retrieve(0xc00037bd80, {0x1322c8d, 0x3}, {0xc007334900, 0x1260960, 0x9}, 0xb8, {0x0, 0xc00019cdc7}, 0x1, ...) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/namespace/common.go:130 +0xa2d [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/namespace.(Common).Objects(0xc0010841c0, {0x1322c8d, 0x3}, 0xc000ec5fe0, {0x11bfc80, 0xc001999200}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/namespace/common.go:45 +0xa5 [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/poli/security.(Panorama).GetAll(0xc0010841c0, {0xc000be2c40, 0xe}, {0xc000ec5fe0, 0xc}) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/poli/security/pano.go:51 +0x9b [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango/poli/security.(Panorama).ConfigureRules(0xc00174a030, {0xc000be2c40, 0xe}, {0xc000ec5fe0, 0xc}, {0xc007392000, 0x14, 0x14}, 0xc001ec9698, 0x0, ...) [2024-01-30T16:30:16.281Z] github.com/PaloAltoNetworks/pango@v0.10.2/poli/security/pano.go:82 +0xdd [2024-01-30T16:30:16.281Z] github.com/terraform-providers/terraform-provider-panos/panos.createUpdateSecurityRuleGroup(0xc000253570, {0x131bda0, 0xc00000a1e0}) [2024-01-30T16:30:16.281Z] github.com/terraform-providers/terraform-provider-panos/panos/security_rules.go:209 +0x8f4 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc0009f8000, 0xc0032d2af0, 0xc0055b7020, {0x131bda0, 0xc00000a1e0}) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:326 +0x3e3 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc000215100, 0xc001ec9a68, 0xc006c7dc20, 0x28) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc00000ecf0, {0xc000252460, 0x4b5646}, 0xc000252460) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5 [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x12e14c0, 0xc00000ecf0}, {0x1572b90, 0xc004498b10}, 0xc00795e0c0, 0x0) [2024-01-30T16:30:16.281Z] github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170 [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).processUnaryRPC(0xc0001cc380, {0x1583bc0, 0xc000210a80}, 0xc009c08e00, 0xc000304b70, 0x1d5c340, 0x0) [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).handleStream(0xc0001cc380, {0x1583bc0, 0xc000210a80}, 0xc009c08e00, 0x0) [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a [2024-01-30T16:30:16.281Z] google.golang.org/grpc.(Server).serveStreams.func1.2() [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:859 +0x98 [2024-01-30T16:30:16.281Z] created by google.golang.org/grpc.(Server).serveStreams.func1 [2024-01-30T16:30:16.281Z] google.golang.org/grpc@v1.32.0/server.go:857 +0x294 [2024-01-30T16:30:16.281Z] [2024-01-30T16:30:16.282Z] Error: The terraform-provider-panos_v1.11.1 plugin crashed! [2024-01-30T16:30:16.282Z] [2024-01-30T16:30:16.282Z] This is always indicative of a bug within the plugin. It would be immensely [2024-01-30T16:30:16.282Z] helpful if you could report the crash with the plugin's maintainers so that it [2024-01-30T16:30:16.282Z] can be fixed. The output above should help diagnose the issue.

Context

The issue affects us periodically, due to the crash. the jenkins pipeline has to be retried/refreshed.

Your Environment

the environment is production,