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

Closed PRs getting picked up by build servers monitoring Gitea repos with Gitea 1.19 #24213

Closed
parnic-sks opened this issue Apr 19, 2023 · 4 comments · Fixed by #24231
Closed
Assignees
Labels

Comments

@parnic-sks
Copy link

Description

We recently upgraded from Gitea 1.18.5 to Gitea 1.19.1, and our TeamCity server has started queuing builds for a number of closed PRs for no discernable reason. No changes are being pushed to these PRs, in fact some of the PRs's branches have been deleted.

I haven't been able to track down the specific details of what's going on, but I can see on the Gitea host filesystem that the directory under repositories/org/repo/refs/pull for the closed PR is getting re-created with the "head" file containing a commit hash that doesn't belong to that branch at all (it seems to always belong to our default 'main' branch instead).

Our only fix has been to constantly monitor TeamCity for queueing builds on closed PRs and canceling them, then fully Deleting the closed PR in Gitea. This is causing a significant problem for us at the moment, so if there's a commit I can cherry-pick to manually build and deploy a fix, we'd be very happy to do that.

This only applies to PRs that are closed, it is not happening with open or merged ones.

I found some issues/PRs that sound possibly related:

Gitea Version

1.19.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Hand-built 1.19.1 with one local modification, running on an arm64 AWS EC2 instance.

Database

PostgreSQL

@wolfogre
Copy link
Member

wolfogre commented Apr 20, 2023

Could you please explain how your Gitea instance triggers builds in TeamCity? Is it via a webhook or by monitoring the repository refs files?

@sillyguodong Please take a look.

@parnic-sks
Copy link
Author

Could you please explain how your Gitea instance triggers builds in TeamCity? Is it via a webhook or by monitoring the repository refs files?

Yes, good question, I left that out of the initial report.

Our TeamCity is set up to monitor branches matching the specification:

+:refs/heads/*
+:refs/(pull/*)/head

This is in the "VCS root" section:
image

Then the VCS Trigger is defined like so:
image

@sillyguodong
Copy link
Contributor

I have probably found out the cause of this problem, I will fix that this week.

@parnic-sks
Copy link
Author

I have probably found out the cause of this problem, I will fix that this week.

We've been running the change from #24231 on our server for the past couple of weeks and it has indeed fixed the issue.

Is this going to be merged in soon?

lunny pushed a commit that referenced this issue May 8, 2023
Close #24213 
Replace #23830

#### Cause

- Before, in order to making PR can get latest commit after reopening,
the `ref`(${REPO_PATH}/refs/pull/${PR_INDEX}/head) of evrey closed PR
will be updated when pushing commits to the `head branch` of the closed
PR.

#### Changes

- For closed PR , won't perform these behavior: insert`comment`, push
`notification` (UI and email), exectue
[pushToBaseRepo](https://github.com/go-gitea/gitea/blob/74225033413dc0f2b308bbe069f6d185b551e364/services/pull/pull.go#L409)
function and trigger `action` any more when pushing to the `head branch`
of the closed PR.
- Refresh the reference of the PR when reopening the closed PR (**even
if the head branch has been deleted before**). Make the reference of PR
consistent with the `head branch`.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue May 8, 2023
Close go-gitea#24213 
Replace go-gitea#23830

#### Cause

- Before, in order to making PR can get latest commit after reopening,
the `ref`(${REPO_PATH}/refs/pull/${PR_INDEX}/head) of evrey closed PR
will be updated when pushing commits to the `head branch` of the closed
PR.

#### Changes

- For closed PR , won't perform these behavior: insert`comment`, push
`notification` (UI and email), exectue
[pushToBaseRepo](https://github.com/go-gitea/gitea/blob/74225033413dc0f2b308bbe069f6d185b551e364/services/pull/pull.go#L409)
function and trigger `action` any more when pushing to the `head branch`
of the closed PR.
- Refresh the reference of the PR when reopening the closed PR (**even
if the head branch has been deleted before**). Make the reference of PR
consistent with the `head branch`.
silverwind pushed a commit that referenced this issue May 8, 2023
Backport #24231 by @sillyguodong

Close #24213 
Replace #23830

#### Cause

- Before, in order to making PR can get latest commit after reopening,
the `ref`(${REPO_PATH}/refs/pull/${PR_INDEX}/head) of evrey closed PR
will be updated when pushing commits to the `head branch` of the closed
PR.

#### Changes

- For closed PR , won't perform these behavior: insert`comment`, push
`notification` (UI and email), exectue
[pushToBaseRepo](https://github.com/go-gitea/gitea/blob/74225033413dc0f2b308bbe069f6d185b551e364/services/pull/pull.go#L409)
function and trigger `action` any more when pushing to the `head branch`
of the closed PR.
- Refresh the reference of the PR when reopening the closed PR (**even
if the head branch has been deleted before**). Make the reference of PR
consistent with the `head branch`.

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants