dell / dell-terraform-providers

Terraform providers will provide easy and seamless integration with Dell Infrastructure.
Mozilla Public License 2.0
3 stars 1 forks source link

[BUG]: powerscale.FileSystemResource ACL Attributes "owner" and "group" have "name" and "type" set to Required, should be Optional #9

Closed petew-nfx closed 7 months ago

petew-nfx commented 9 months ago

Bug Description

Optional attributes on ACLs are marked as Required - import FilesystemResource fails on nil pointer. Namespace objects with unresolvable UID/GID on the cluster lack a "name" and a "type" attribute for the ACL.

Resource or DataSource Name

FileSystem

Terraform Version

Terraform 1.6.6

OneFS Version

9.4.0.13

go Version

go 1.21.5

Unisphere Version

N/A

Operating System

MacOS Darwin Kernel Version 23.2.0

Terraform File Used

resource "powerscale_filesystem" "some_path" {
}

Logs

% terraform import powerscale_filesystem.some_path ifs/<some_path>

 ╷
 │ Error: Plugin did not respond
 │
 │ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ImportResourceState call. The plugin
 │ logs may contain more details.

 Stack trace from the terraform-provider-powerscale_v1.1.0 plugin:

 panic: runtime error: invalid memory address or nil pointer dereference
 [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x242dbe9]

 goroutine 37 [running]:
 terraform-provider-powerscale/powerscale/helper.UpdateFileSystemResourceState({0x2f69cf0?, 0xc0003df1d0?}, 0x2d961c0?, 0xc00008b040, 0xc0000bc2c0, 0x0?)
    terraform-provider-powerscale/powerscale/helper/file_system_helper.go:297 +0x189
 terraform-provider-powerscale/powerscale/provider.(*FileSystemResource).ImportState(0xc000416130, {0x2f69cf0, 0xc0003df1d0}, {{0xc0001a0228?, 0x2db58df?}}, 0xc000180960)
    terraform-provider-powerscale/powerscale/provider/file_system_resource.go:516 +0x109
 github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ImportResourceState(0xc0002191e0, {0x2f69cf0, 0xc0003df1d0}, 0xc0001a6ba0, 0xc0002495c8)
...

A GET of namespace/ifs/ via the REST API returns:

{
  "acl": [
    {
      "accessrights": [
        "dir_gen_all"
      ],
      "accesstype": "allow",
      "inherit_flags": [],
      "trustee": {
        "id": "UID:99"
      }
    },
    {
      "accessrights": [
        "dir_gen_all"
      ],
      "accesstype": "allow",
      "inherit_flags": [],
      "trustee": {
        "id": "GID:99"
      }
    },
    {
      "accessrights": [
        "dir_gen_all"
      ],
      "accesstype": "allow",
      "inherit_flags": [],
      "trustee": {
        "id": "SID:S-1-1-0",
        "name": "Everyone",
        "type": "wellknown"
      }
    }
  ],
  "authoritative": "acl",
  "group": {
    "id": "GID:99"
  },
  "mode": "0777",
  "owner": {
    "id": "UID:99"
  }
}

Steps to Reproduce

terraform import powerscale_filesystem.some_path ifs/

Where some_path has uid/gid set which do not resolve on the cluster providers.

Expected Behavior

Importing a Filesystem with an unresolvable UID/GID in the ACL should succeed.

Actual Behavior

Importing a Filesystem with an unresolvable UID/GID in the ACL fails with a panic.

Screenshots

No response

Additional Information

No response

taohe1012 commented 9 months ago

hi @petew-nfx , as we discussed in the previous thread - https://github.com/dell/terraform-provider-powerscale/issues/118, we will change these two fields to optional and solve this issue in our plan. welcome for more further comment, thanks.

forrestxia commented 7 months ago

Close since it's fixed in the PR aforementioned.