Skip to content

Avoid error with slash in git branch name#6120

Closed
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:branch_folder_fix
Closed

Avoid error with slash in git branch name#6120
AlanCoding wants to merge 1 commit intoansible:develfrom
AlanCoding:branch_folder_fix

Conversation

@AlanCoding
Copy link
Copy Markdown
Member

SUMMARY

Speculative fix for #6119

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION
9.2.0
ADDITIONAL INFORMATION

still needs better replication and confirmation of fix

@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Build succeeded.

if not os.path.exists(destination_folder):
os.mkdir(destination_folder, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
tmp_branch_name = 'awx_internal/{}'.format(uuid4())
tmp_branch_name = 'awx_internal_{}'.format(uuid4())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔
I do not doubt that this fixes the problem, but given that we already include a uuid in the branch name, I'm wondering why removing the forward slash prevents a duplicate file exception ?

Is it because we're always creating an awx_internal directory (because of the slash) and so the uuids don't matter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'm guessing that's probably it:

FileExistsError: [Errno 17] File exists: '/var/lib/awx/projects/_71__project_aspectmatter/.git/refs/heads/awx_internal' <----------------------------------------- 

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how git works, in that it nests these refs under directories when there are slashes. The race condition is where the library we use doesn't account for multi-processing, and tests for existence and creates the directory with a time gap in-between.

@AlanCoding
Copy link
Copy Markdown
Member Author

Closing in favor of gitpython-developers/GitPython#998

@AlanCoding AlanCoding closed this Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants