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: recover when there is unreleased lock file #914

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

sdowell
Copy link
Contributor

@sdowell sdowell commented Aug 5, 2024

If a previous git invocation crashes, it is possible that an orphaned lock file (e.g. shallow.lock) is left on the filesystem. This previously caused git-sync to crash loop because the lock file is never deleted.

This change adds a check in sanityCheckRepo for the existence of a git lock file. If the git lock file exists at this stage, then initRepo will re-initialize the repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 5, 2024
@k8s-ci-robot k8s-ci-robot requested review from nan-yu and stp-ip August 5, 2024 17:59
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 5, 2024
main.go Outdated
@@ -1227,6 +1227,19 @@ func (git *repoSync) removeStaleWorktrees() (int, error) {
return count, nil
}

func hasGitLockFile(gitRoot absPath) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

How about also returning the name of the first detected lockfile which , so the caller can log it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@thockin
Copy link
Member

thockin commented Aug 12, 2024

Just one super small point, then LGTM. Thanks!

main.go Outdated Show resolved Hide resolved
If a previous git invocation crashes, it is possible that an orphaned
lock file (e.g. shallow.lock) is left on the filesystem. This previously
caused git-sync to crash loop because the lock file is never deleted.

This change adds a check in sanityCheckRepo for the existence of a git
lock file. If the git lock file exists at this stage, then initRepo will
re-initialize the repository.
@thockin
Copy link
Member

thockin commented Aug 12, 2024

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 12, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sdowell, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit a5a965f into kubernetes:master Aug 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants