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

Avoid error with slash in git branch name #6120

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awx/main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ def make_local_copy(project_path, destination_folder, scm_type, scm_revision):
git_repo = git.Repo(project_path)
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
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
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
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.

# always clone based on specific job revision
if not scm_revision:
raise RuntimeError('Unexpectedly could not determine a revision to run from project.')
Expand Down