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

"tags" always updated if unsorted or are comma-separated #951

Closed
needleshaped opened this issue Feb 27, 2024 · 3 comments · Fixed by #1007
Closed

"tags" always updated if unsorted or are comma-separated #951

needleshaped opened this issue Feb 27, 2024 · 3 comments · Fixed by #1007

Comments

@needleshaped
Copy link
Contributor

Tags are never-ending updated, if a list in *.tf config is not sorted, or uses comma instead of semicolon.
Reason: Proxmox responds with sorted list, thus 2 strings never match.

  # module.XYZ.proxmox_vm_qemu.vm_template will be updated in-place
      ~ tags                      = "dafdk;terraform;test" -> "dafdk;test;terraform"

Same issue was discussed in #771.

Based on new user experience, 2 changes are proposed:
(unless breaks backward-compatibility)

  1. Modify README to mention correct format, https://github.com/Telmate/terraform-provider-proxmox/blob/master/docs/resources/lxc.md?plain=1#L264
    * `tags` - Tags of the container. This is only meta information.
    * `tags` - Tags of the container, semicolon-delimited. This is only meta information.
    
  2. Sort tags before comparing state with Proxmox data in a CODE.
  3. Workaround would either manually sort the tags for each machine OR
  4. Code sorting it within TF module, e.g.
resource "proxmox_vm_qemu" "vm_template" {
  ...
  tags        = join(";", sort(concat(["terraform"], split(";", var.tags)))) # adding "terraform" marker # workaround, as unsorted list will conflict with Proxmox's sorted state, leading to always-update situation
  ...
}

Otherwise, every other new user of Telmate plugin will have increased learning curve and iether will re-invent a wheel, or choose to ignore the problem.

P.S. Proxmox v8.0.4 and Terraform v1.7.4, Telmate v2.9.11.

@needleshaped needleshaped changed the title "tags" always updated if unsorted "tags" always updated if unsorted or are comma-separated Feb 27, 2024
@mleone87
Copy link
Collaborator

the easiest way is to use lifecycle policies

https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#ignore_changes

@needleshaped
Copy link
Contributor Author

the easiest way is to use lifecycle policies

Correct me if I'm wrong, but if in this case I update it manually after realising I want to add another tag, it will be also ignored, right?

In this case this more or less breaks functionality completely, apart from creation step.
On contrary, the reason I'm writing this issue, is to hopefully have it work as it should without workarounds. Update when necessary, do not when not.

needleshaped added a commit to needleshaped/terraform-provider-proxmox that referenced this issue Feb 28, 2024
…rnally

Using commas forces "tags" update on every bump.
@gbrackley
Copy link

I found the same issue. I use the provider in a module, so did the following:

tags = join(";", sort(var.tags))

I provided the tags as an list of strings to my module. Perhaps a good 'fix' would be to have the tags attribute changed to support an list of strings. This would be a change to the interface, but the old behavior of semi-colon separated strings could be supported.

The proxmox provider should provide lossless round-tripping of the tags (so if the proxmox API or proxmox code sorts the tags then that should be allowed for).

Tinyblargon added a commit that referenced this issue Mar 13, 2024
DOC #951: mention correct delimiter, the one Proxmox uses internally
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.

4 participants