Skip to content

Race Condition with multiple project_share_repository #209

@ALxWi

Description

@ALxWi

Describe the bug
I was trying to create multiple project_share_repository within a artifactory project that share the same repository. To ease the configuration, i tried adding a for_each sequence, but unfortunately, it wasn't working.
With the current provider (v1.9.3) i'm getting multiple bad request errors and no valid state. If i try to create 4 shares for a repository i might end with 1-3 on a random base and tf quits with a bad request error. Subsequent tries try to replace some resources and mess with the state. This ends with some resources beeing created and no beeing in the state at all.

I'm using Artifactory self hosted (enterprise) with the following versions:
"version" : "7.104.5",
"revision" : "80405900"

Terraform: 1.12.2

Requirements for and issue

  • A fully functioning terraform snippet that can be copy&pasted (no outside files or ENV vars unless that's part of the issue)
  • Your version of artifactory (you can curl it at $host/artifactory/api/system/version
  • Your version of terraform

Expected behavior
I would expect that all shares are created and the state to be consistent

Additional context
I found out that the problem was that multiple api calls for the same repository were causing the issue. To fix this, I added a mutex to the create and deletion functions of the resource project_share_repository to stop concurrency.
The mutex is defined as global to use it for future reference if necessary.

PR #208 fixes this issue

script to reproduce
TF file attached as main.txt
main.txt

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions