streamnative/terraform-provider-pulsar

Ordering is important when updating backlog_quota.limit_bytes and retention_policies.retention_size_in_mb

jop-di opened this issue · 0 comments

When a TF file is updated and the update contains changes in a namespace for both backlog_quota.limit_bytes and retention_policies.retention_size_in_mb, the order in which they are updated matters. If the order is incorrect, the update will result in an error. Running the same terraform apply again, results in an OK however.

Pulsar returns an error when you try to configure an backlog quota which exceeds the retention quota(or a retention quota which is lower to the backlog quota):

│ Error: ERROR_UPDATE_NAMESPACE_CONFIG: 1 error occurred:
│ * SetRetention: code: 412 reason: Retention Quota must exceed configured backlog quota for namespace.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v1.2.2
on linux_amd64

Affected Resource(s)

  • resource_pulsar_namespace.go

Terraform Configuration Files

Configuration file can be copied from example: examples/namespaces/maint.tf (https://github.com/streamnative/terraform-provider-pulsar/blob/master/examples/namespaces/main.tf)

Debug Output

not relevant

Panic Output

not relevant

Expected Behavior

Update both retention quota and backlog quota without error.

Actual Behavior

Error is shown:

│ Error: ERROR_UPDATE_NAMESPACE_CONFIG: 1 error occurred:
│ * SetRetention: code: 412 reason: Retention Quota must exceed configured backlog quota for namespace.

Steps to Reproduce

  1. terraform apply
  2. update the retention quota to exceed the old retention quota and increase the backlog quota to be just below the new retention quota, but above the old retention quota.
  3. terraform apply

Important Factoids

I think somewhere around this line:

if retentionPoliciesConfig.Len() > 0 {
there needs to be a condition:

  • if both retention and backlog limits are updated
    • if retention limit has decreased
      • backlog needs to be updated first!
    • else
      • retention needs to be updated first!
  • else
    • no change compared to current implementation.

References

  • #0000