Trailing space in `CEPH_HOST` when creating a Ceph datastore
acidroper opened this issue · 0 comments
acidroper commented
Description
When creating a Ceph datastore, the CEPH_HOST
parameter in the datastore template generated by the provider contains a trailing space.
In the terraform debug and onedatastore show
outputs the string appears as follows:
CEPH_HOST="ceph-host1 ceph-host2 ceph-host3 "
This causes the resource to be updated when terraform plan
or terraform apply
is run without any changes to the configuration:
# opennebula_datastore.images_ceph will be updated in-place
~ resource "opennebula_datastore" "images_ceph" {
id = "118"
name = "images_ceph"
# (8 unchanged attributes hidden)
- ceph {
- host = [
- "", <<<--------------- this empty string shouldn't be here
- "ceph-host1",
- "ceph-host2",
- "ceph-host3",
] -> null
- local_storage = false -> null
- pool_name = "pool" -> null
- secret = "uuid_of_secret" -> null
- trash = false -> null
- user = "user" -> null
}
+ ceph {
+ host = [
+ "ceph-host1",
+ "ceph-host2",
+ "ceph-host3",
]
+ local_storage = false
+ pool_name = "pool"
+ secret = "uuid_of_secret"
+ trash = false
+ user = "user"
}
}
And when applying, the plugin crashes with panic: set item just set doesn't exist
.
Terraform and Provider version
- Terraform 1.8.2 (linux_amd64)
- Provider registry.terraform.io/opennebula/opennebula v1.4.0
Affected resources and data sources
opennebula_datastore
Terraform configuration
resource "opennebula_datastore" "images_ceph" {
name = "images_ceph"
type = "image"
bridge_list = var.storage_bridge_list
ceph {
host = ["ceph-host1", "ceph-host2", "ceph-host3"]
pool_name = "pool"
user = "user"
secret = "uuid_of_secret"
local_storage = false
trash = false
}
}
Expected behavior
The CEPH_HOST
parameter generated by the provider should not contain a trailing space:
CEPH_HOST="ceph-host1 ceph-host2 ceph-host3"
Actual behavior
A trailing space is added to the end of the string value of CEPH_HOST
.
Steps to Reproduce
- Create an
opennebula_datastore
resource with aceph { ... }
configuration defined. - Run
terraform plan
andterraform apply
. - Run
terraform plan
andterraform apply
again without making any changes to the configuration.
Debug output
No response
Panic output
╷
│ Error: Request cancelled
│
│ with opennebula_datastore.images_ceph_tf_test,
│ on datastores.tf line 15, in resource "opennebula_datastore" "images_ceph_tf_test":
│ 15: resource "opennebula_datastore" "images_ceph_tf_test" {
│
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵
Stack trace from the terraform-provider-opennebula_v1.4.0 plugin:
panic: set item just set doesn't exist
goroutine 82 [running]:
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).setSet(0xc0004a2df8, {0xc0001b97c0, 0x1, 0x1}, {0xc2eac0, 0xc0004b2d08}, 0xc00043e280)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/field_writer_map.go:327 +0x972
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).set(0xc0004a2df8, {0xc0001b97c0, 0x1, 0x1}, {0xc2eac0, 0xc0004b2d08})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/field_writer_map.go:107 +0x14c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).WriteField(0xc0004a2df8, {0xc0001b97c0, 0x1, 0x1}, {0xc2eac0, 0xc0004b2d08})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/field_writer_map.go:89 +0x3f9
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc00053b480, {0xd5d19a, 0x4}, {0xc2eac0, 0xc0004b2d08})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource_data.go:227 +0x210
github.com/OpenNebula/terraform-provider-opennebula/opennebula.resourceOpennebulaDatastoreRead({0xc000019e60?, 0xd6c63b?}, 0xc00053b480, {0xc668e0, 0xc0003c0940})
github.com/OpenNebula/terraform-provider-opennebula/opennebula/resource_opennebula_datastore.go:595 +0x1075
github.com/OpenNebula/terraform-provider-opennebula/opennebula.resourceOpennebulaDatastoreUpdate({0xeb3848, 0xc0004ef740}, 0xc00053b480, {0xc668e0?, 0xc0003c0940?})
github.com/OpenNebula/terraform-provider-opennebula/opennebula/resource_opennebula_datastore.go:870 +0x1e57
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc000430fc0, {0xeb3880, 0xc000516060}, 0xd?, {0xc668e0, 0xc0003c0940})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:741 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000430fc0, {0xeb3880, 0xc000516060}, 0xc000524680, 0xc00053b200, {0xc668e0, 0xc0003c0940})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:847 +0x82c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0003c2438, {0xeb3880?, 0xc0003e5f20?}, 0xc0006103c0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000276a00, {0xeb3880?, 0xc0003e5680?}, 0xc0001da070)
github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xd2ce00?, 0xc000276a00}, {0xeb3880, 0xc0003e5680}, 0xc0001da000, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002741e0, {0xeb6b00, 0xc00048a1a0}, 0xc000346000, 0xc0003e5410, 0x13b6960, 0x0)
google.golang.org/grpc@v1.56.3/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0002741e0, {0xeb6b00, 0xc00048a1a0}, 0xc000346000, 0x0)
google.golang.org/grpc@v1.56.3/server.go:1712 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.56.3/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.56.3/server.go:958 +0x15c
Error: The terraform-provider-opennebula_v1.4.0 plugin crashed!
Important factoids
No response