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

Trailing space in CEPH_HOST when creating a Ceph datastore #543

Closed
acidroper opened this issue Apr 27, 2024 · 0 comments · Fixed by #544
Closed

Trailing space in CEPH_HOST when creating a Ceph datastore #543

acidroper opened this issue Apr 27, 2024 · 0 comments · Fixed by #544

Comments

@acidroper
Copy link
Contributor

acidroper commented Apr 27, 2024

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

  1. Create an opennebula_datastore resource with a ceph { ... } configuration defined.
  2. Run terraform plan and terraform apply.
  3. Run terraform plan and terraform 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

References

#544

@acidroper acidroper changed the title Extra trailing space in CEPH_HOST when creating a Ceph datastore Trailing space in CEPH_HOST when creating a Ceph datastore Apr 27, 2024
@frousselet frousselet linked a pull request May 2, 2024 that will close this issue
7 tasks
@frousselet frousselet added this to the 1.4.1 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants