HewlettPackard / terraform-provider-oneview

Automates the provisioning of physical infrastructure from a private cloud using templates from HPE OneView with Terraform
Apache License 2.0
49 stars 30 forks source link

Cannot import Server Profile Template, provider crashes #459

Closed odesaphy closed 2 years ago

odesaphy commented 2 years ago

Scenario/Intent

Hello,

I'm trying to import a Server Profile Template resource with Terragrunt to update my tfstate

When I'm running the Terragrunt import command the provider is crashing

Environment Details

crash.log

[ERROR] setting state: Invalid address to set: []string{"iscsi_initiator_name"}: timestamp=2022-02-22T13:34:12.611Z
[ERROR] setting state: Invalid address to set: []string{"associated_server"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"in_progress"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"profile_uuid"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"server_hardware_reapply_state"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"service_manager"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"task_uri"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"template"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"template_compliance"}: timestamp=2022-02-22T13:34:12.866Z
[ERROR] setting state: Invalid address to set: []string{"uuid"}: timestamp=2022-02-22T13:34:12.866Z

The provider is trying to get/set properties that are not part of a Server Profile Template object but part of a Server Profile

nabhajit-ray commented 2 years ago

Hi @odesaphy ,

Thanks for reporting this. Will get back to you.

odesaphy commented 2 years ago

If we have configured an iLO local account in the Server Profile Template, we have to manage how to set the password ... Because when I do a GET on the Template uri (with curl or powershell) the iLO local account account is null/empty

nabhajit-ray commented 2 years ago

Oneview does not return the password value for GET operation. We setting the password field in the state file from the configuration to resolve idempotency issue.

nabhajit-ray commented 2 years ago

Closing this as the issue is resolved . Please reopen if it is still not working.

jullienl commented 2 years ago

Facing same issue, I cannot import SPT. This is the error I have:

oneview_server_profile_template.name: Refreshing state... [id=CentOS7.8]

Error: rpc error: code = Unavailable desc = transport is closing

panic: interface conversion: interface {} is nil, not *schema.Set
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: 
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: goroutine 33 [running]:
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/HewlettPackard/terraform-provider-oneview/oneview.resourceServerProfileTemplateRead(0xc000140680, 0xe1b320, 0xc0000e6180, 0x154c480, 0xf46f40)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/HewlettPackard/terraform-provider-oneview/oneview/resource_server_profile_template.go:2133 +0xe286
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003b5e00, 0x1087160, 0xc0000ff040, 0xc000140680, 0xe1b320, 0xc0000e6180, 0x0, 0x0, 0x0)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/resource.go:290 +0x88
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003b5e00, 0x1087160, 0xc0000ff040, 0xc0004eff80, 0xe1b320, 0xc0000e6180, 0xc0001dc078, 0x0, 0x0, 0x0)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/resource.go:564 +0x1cb
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0001a6480, 0x1087160, 0xc0000ff040, 0xc0000ff580, 0xc0000ff040, 0xe8f580, 0xec2420)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/grpc_provider.go:575 +0x43b
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc000250b20, 0x1087160, 0xc0000ff040, 0xc00046c1e0, 0xc000250b20, 0xc000135e90, 0xc000226ba0)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/server/server.go:298 +0x105
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0xec2420, 0xc000250b20, 0x1087220, 0xc000135e90, 0xc00046c180, 0x0, 0x1087220, 0xc000135e90, 0xc000169680, 0x244)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001f2e00, 0x108ed60, 0xc0001f6a80, 0xc0004f8e00, 0xc0003bb260, 0x150e230, 0x0, 0x0, 0x0)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   google.golang.org/grpc@v1.32.0/server.go:1194 +0x522
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: google.golang.org/grpc.(*Server).handleStream(0xc0001f2e00, 0x108ed60, 0xc0001f6a80, 0xc0004f8e00, 0x0)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   google.golang.org/grpc@v1.32.0/server.go:1517 +0xd05
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000414000, 0xc0001f2e00, 0x108ed60, 0xc0001f6a80, 0xc0004f8e00)
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   google.golang.org/grpc@v1.32.0/server.go:859 +0xa5
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13: created by google.golang.org/grpc.(*Server).serveStreams.func1
2022-03-07T17:56:00.966Z [DEBUG] plugin.terraform-provider-oneview_v6.5.0-13:   google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
2022-03-07T17:56:00.968Z [DEBUG] plugin: plugin process exited: path=.terraform/plugins/registry.terraform.io/hewlettpackard/oneview/6.5.0-13/linux_amd64/terraform-provider-oneview_v6.5.0-13 pid=40392 error="exit status 2"
2022-03-07T17:56:00.968Z [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Canceled desc = context canceled"
2022/03/07 17:56:00 [ERROR] eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2022/03/07 17:56:00 [ERROR] eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2022/03/07 17:56:00 [TRACE] [walkImport] Exiting eval tree: import oneview_server_profile_template.name result
2022/03/07 17:56:00 [TRACE] vertex "import oneview_server_profile_template.name result": visit complete
2022/03/07 17:56:00 [TRACE] vertex "oneview_server_profile_template.name (import id \"CentOS7.8\")": dynamic subgraph encountered errors
2022/03/07 17:56:00 [TRACE] vertex "oneview_server_profile_template.name (import id \"CentOS7.8\")": visit complete
2022/03/07 17:56:00 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hewlettpackard/oneview\"] (close)" errored, so skipping
2022/03/07 17:56:00 [TRACE] dag/walk: upstream of "root" errored, so skipping
2022/03/07 17:56:00 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2022/03/07 17:56:00 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2022-03-07T17:56:00.968Z [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
odesaphy commented 2 years ago

The issue is not fixed in latest 6.6.0 provider :

iscsi_initiator_name (iscsiInitiatorName) is not a property of Server Profile Template (only iscsiInitiatorNameType)

2022-03-25T12:03:45.553+0100 [INFO]  plugin.terraform-provider-oneview_v6.6.0-13: 2022/03/25 12:03:45 [ERROR] setting state: Invalid address to set: []string{"iscsi_initiator_name"}: timestamp=2022-03-25T12:03
:45.553+0100
2022-03-25T12:03:45.860+0100 [DEBUG] plugin.terraform-provider-oneview_v6.6.0-13: panic: interface conversion: interface {} is nil, not *schema.Set