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

Nexus_blobstore_file cannot apply path does not reflect in tf state #400

Open
1 task done
EugenMayer opened this issue Nov 22, 2023 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@EugenMayer
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

Terraform Version

1.6.4

Nexus Provider Version

1.22.0

Nexus Version

3.62.2

Affected Resource(s)/Data Source(s)

nexus_blobstore_file

Terraform Configuration Files

resource "nexus_blobstore_file" "nexus-maven-proxy-cache" {
  name = "nexus-maven-proxy-cache"
  path = "/nexus-data/blobs/nexus-maven-proxy-cache"
}


### Debug Output/Panic Output

```shell
There is no panic, but after each apply, it will try to apply the next time too.

So either the state is not properly updated/retrieved or something else is wrong. 

The path itslef is 



module.nexus_config.module.blobstore.nexus_blobstore_file.nexus-npm-proxy-cache will be updated in-place
  ~ resource "nexus_blobstore_file" "nexus-npm-proxy-cache" {
        id                       = "nexus-npm-proxy-cache"
        name                     = "nexus-npm-proxy-cache"
      ~ path                     = "nexus-npm-proxy-cache" -> "/nexus-data/blobs/nexus-npm-proxy-cache"
        # (3 unchanged attributes hidden)
    }


### Expected Behaviour

After applying it, it should no long show up as 'to be changed' in the next run

### Actual Behaviour

tries to re-appy again and again


### Steps to Reproduce

1. have a `nexus_blobstore_file`
2. tf apply

### References

-
@EugenMayer EugenMayer added the bug Something isn't working label Nov 22, 2023
@Edu-DevOps
Copy link

Edu-DevOps commented Mar 5, 2024

I could reproduce this using the latest provider release (2.2.0) and Terraform 1.6.6

This is not happening all the time we want to modify a blobstore path, it only happens if you use an absolute path in the default Nexus blobs directory, for example /nexus-data/blobs/nexus-npm-proxy-cache.

This is happening because Nexus itself is converting the path from absolute to relative while using the default blobs path /nexus-data/blobs/ (this is also reproducible using the UI/API) so when Terraform refresh the blobstore state Nexus answers with the relative path while Terraform wants to apply the absolute path.

Should we follow the same approach than Sonatype converting the absolute path to relative path in case of the default blobstore path is configured? What if someone else has configured by default another blobstore path?

As of now, I´d suggest to use relative paths in the Terraform declaration if you use the default blobstore path. I can confirm that this not happen while using relative path, please find below an example of path update working properly:

edu@edu-ThinkPad-T470s:~/Git/terraform-product$ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # nexus_blobstore_file.tf-bs-test will be created
  + resource "nexus_blobstore_file" "tf-bs-test" {
      + available_space_in_bytes = (known after apply)
      + blob_count               = (known after apply)
      + id                       = (known after apply)
      + name                     = "tf-bs-test"
      + path                     = "tf-random-path"
      + total_size_in_bytes      = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

nexus_blobstore_file.tf-bs-test: Creating...
nexus_blobstore_file.tf-bs-test: Creation complete after 0s [id=tf-bs-test]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
edu@edu-ThinkPad-T470s:~/Git/terraform-product$ terraform apply
nexus_blobstore_file.tf-bs-test: Refreshing state... [id=tf-bs-test]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # nexus_blobstore_file.tf-bs-test will be updated in-place
  ~ resource "nexus_blobstore_file" "tf-bs-test" {
        id                       = "tf-bs-test"
        name                     = "tf-bs-test"
      ~ path                     = "tf-random-path" -> "tf-random-path-CHANGED"
        # (3 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

nexus_blobstore_file.tf-bs-test: Modifying... [id=tf-bs-test]
nexus_blobstore_file.tf-bs-test: Modifications complete after 0s [id=tf-bs-test]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
edu@edu-ThinkPad-T470s:~/Git/terraform-product$ terraform apply
nexus_blobstore_file.tf-bs-test: Refreshing state... [id=tf-bs-test]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

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
Status: High priority
Development

No branches or pull requests

2 participants