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

Resource crash junos_security_nat_source_pool when port_range is used #382

Closed
zachfi opened this issue Apr 28, 2022 · 2 comments · Fixed by #385
Closed

Resource crash junos_security_nat_source_pool when port_range is used #382

zachfi opened this issue Apr 28, 2022 · 2 comments · Fixed by #385
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zachfi
Copy link

zachfi commented Apr 28, 2022

Howdy, I'm looking at this provider to move some custom configuration tool, so I have a bunch of config to migrate. Here is what I'm up to first.

resource "junos_security_nat_source_pool" "wireguard_v4" {
  name       = "wireguard_v4"
  address    = ["xxx.xxx.xxx.xxx/32"]
  port_range = "11111"
}

With this resource, I get the following crash.

Stack trace from the terraform-provider-junos_v1.26.0 plugin:

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

goroutine 60 [running]:
github.com/jeremmfr/terraform-provider-junos/junos.validateSourcePoolPortRange.func1({0xfade60?, 0xc0001ce130?}, {0xc0005a7fc0, 0x1, 0x1})
	/home/runner/work/terraform-provider-junos/terraform-provider-junos/junos/resource_security_nat_source_pool.go:474 +0xc45
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Schema).validateFunc(0xc00089f9da?, {0xfade60?, 0xc0001ce130?}, {0x10b7830?, 0x10?}, {0xc0005a7fc0?, 0x1, 0x1})
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:566 +0xfa
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validatePrimitive(0xc0008bef68?, {0x10b7830, 0xa}, {0xfade60, 0xc0005a79d0}, 0xc00051b540, 0xc000572bd0?, {0xc0005a7fc0, 0x1, 0x1})
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:2294 +0xa08
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateType(0xc0005a7d70?, {0x10b7830?, 0x60e72a?}, {0xfade60?, 0xc0005a79d0?}, 0xc00051b540, 0xfd1360?, {0xc0005a7fc0, 0x1, 0x1})
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:2321 +0x14a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validate(0xff6440?, {0x10b7830, 0xa}, 0xc00051b540, 0x11c?, {0xc0005a7fc0, 0x1, 0x1})
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:1731 +0x6ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateObject(0x11?, {0x0, 0x0}, 0x12?, 0x0?, {0x1838228?, 0x0, 0x0})
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:2167 +0x591
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Validate(...)
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:786
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Validate(0xc00051e000, 0xc0003629f0?)
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:916 +0x4d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ValidateResource(0x12664d8?, {0xc000604680, 0x1e}, 0xd?)
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/provider.go:255 +0xf2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ValidateResourceTypeConfig(0xc00011c0a8, {0x1266430?, 0xc0002569c0?}, 0xc000018618)
	/home/runner/go/pkg/mod/github.com/jeremmfr/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:246 +0x1a9
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ValidateResourceTypeConfig(0xc0004bb360, {0x12664d8?, 0xc0005720c0?}, 0xc000256740)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:687 +0x2f5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ValidateResourceTypeConfig_Handler({0x1088aa0?, 0xc0004bb360}, {0x12664d8, 0xc0005720c0}, 0xc000399380, 0x0)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:277 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000142700, {0x1269058, 0xc0006829c0}, 0xc00025ea20, 0xc000117680, 0x17fa2f0, 0x0)
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc000142700, {0x1269058, 0xc0006829c0}, 0xc00025ea20, 0x0)
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1619 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:919 +0x28a

Error: The terraform-provider-junos_v1.26.0 plugin crashed!

Looking at the srx config I have set security nat source pool wireguard_v4 port range 11111. Please advise.

@jeremmfr
Copy link
Owner

Hi, ok there is a bug.
The port_range argument expects a range of ports like 11111-22222 that generates these lines :

set security nat source pool wireguard_v4 port range 11111
set security nat source pool wireguard_v4 port range to 22222

A single port wasn't foreseen.
I will take care of fixing the bug and permit a single port

@jeremmfr jeremmfr added the bug Something isn't working label Apr 30, 2022
@jeremmfr jeremmfr self-assigned this Apr 30, 2022
@jeremmfr jeremmfr added this to the v1.27.0 milestone Apr 30, 2022
@zachfi
Copy link
Author

zachfi commented May 16, 2022

Nice, thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants