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

Always delete existing scheduled action tasks #27662

Merged
merged 3 commits into from Oct 18, 2023

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Oct 17, 2023

Fixes #27650

@KN4CK3R KN4CK3R added type/bug topic/gitea-actions related to the actions of Gitea labels Oct 17, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 17, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 17, 2023
@KN4CK3R KN4CK3R added this to the 1.21.0 milestone Oct 17, 2023
services/actions/notifier_helper.go Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 17, 2023
@delvh
Copy link
Member

delvh commented Oct 17, 2023

Something I'm not sure about:
Are our cron schedules relative or absolute?
So, does * /5 * * * mean run at multiples of 5 minutes `starting at 0` , or does it mean run at multiples of 5 minutes `starting now`?
If it is the latter, we will now get somewhat buggy behavior as the existing schedule is cleared.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Oct 17, 2023

The behaviour should not be different than before. If the commit changed something unrelated to the scheduled action, all existing tasks are removed and re-added.

This PR just forces the deletion even if the config does not contain a scheduled action anymore.

@lunny
Copy link
Member

lunny commented Oct 18, 2023

I don't think this PR fixed #27650. The problem is when pushing an error parsed yaml, all old schedule tasks haven't been stop. So we need to check cron jobs when parsing workflow yaml file failed.

@delvh
Copy link
Member

delvh commented Oct 18, 2023

I don't think this PR fixed #27650. The problem is when pushing an error parsed yaml, all old schedule tasks haven't been stop

Well, that is one a completely different problem and two not the critical problem as that can be easily fixed by users.
The biggest problem is fixed by this PR already-

@lunny
Copy link
Member

lunny commented Oct 18, 2023

I think you are right these are 2 bugs . I think this PR just fixed one of two so it should be partially fix in the description.

This PR just resolved if the workflows are deleted but not from valid to invalid.

According togo u #27650, the second screenshot displayed the yaml file parse failed I think which is the real reason that the old cron jobs haven't been deleted.

图片

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 18, 2023
@KN4CK3R
Copy link
Member Author

KN4CK3R commented Oct 18, 2023

Isn't that case covered too? If the file is invalid DetectWorkflows returns nothing but in the end my changed method is called which removes the scheduled actions.

@lunny
Copy link
Member

lunny commented Oct 18, 2023

in line 149, if parse failed, it will return error but will not invoke handleSchedules which is located line 191.
Looks like you are right, it just display a warn but not return error.

	workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload)
	if err != nil {
		return fmt.Errorf("DetectWorkflows: %w", err)
	}

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 18, 2023
@lunny lunny enabled auto-merge (squash) October 18, 2023 09:51
@lunny lunny merged commit 83186ec into go-gitea:main Oct 18, 2023
25 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 18, 2023
@KN4CK3R KN4CK3R deleted the fix-scheduled-actions branch October 18, 2023 11:22
@lunny lunny added the backport/v1.21 This PR should be backported to Gitea 1.21 label Oct 19, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 19, 2023
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Add link for repositories README file (go-gitea#27684)
  Fix typo "GetLatestRunnerToken" (go-gitea#27680)
  Clipboard copy enhancements (go-gitea#27669)
  Remove unnecessary parameter (go-gitea#27671)
  Always delete existing scheduled action tasks (go-gitea#27662)
  Support allowed hosts for webhook to work with proxy (go-gitea#27655)
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Oct 19, 2023
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Oct 19, 2023
KN4CK3R added a commit that referenced this pull request Oct 19, 2023
Backport #27662 by @KN4CK3R

Fixes #27650

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Old Scheduled Action Tasks Not Cleared When Creating Remove Scheduled Task Configuration Commits
4 participants