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

Fix for InvalidGitRepositoryError under certain conditions #15735

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

CastawayEGR
Copy link
Contributor

@CastawayEGR CastawayEGR commented Jan 9, 2025

SUMMARY

Catch InvalidGitRepositoryError errors and remove the project directory in order to successfully clone the project and proceed.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Other
AWX VERSION
awx: 0.1.dev34286+g2f3b2e7
ADDITIONAL INFORMATION

In some rare occurrences job runs can fail due to InvalidGitRepositryError. This has been observed particularly when git requests are being rate limited where either just an empty project directory is created, an empty .git directory, or a malformed/corrupt .git directory exists inside of the project when using the Source Control Branch option at the job level.

This change will catch the InvalidGitRepositoryError and remove the empty or corrupt project directory to successfully clone the git repo.

Copy link

sonarqubecloud bot commented Jan 9, 2025

else:
original_branch = git_repo.active_branch
except git.exc.InvalidGitRepositoryError:
logger.error(f"Invalid git repository at {project_path}. Removing directory and continuing.")
Copy link
Member

Choose a reason for hiding this comment

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

This log would lose too much information. I'd prefer convert logger.error to logger.exception. Because, diving into questions about what this fixes, the answers were too broad. It could be because the entire directory contents were deleted, but it could be due to a ratelimiting error leaving corrupted data. Not having the specific error pinned down in the planning of this, we definitely need to at absolute minimum have that information in the logs when this happens.

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