woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.3k stars 371 forks source link

Disabling a repo doesn't remove CRON builds #4361

Open pat-s opened 1 week ago

pat-s commented 1 week ago

Component

server

Describe the bug

When disabling a repo, the id in the repos table is set to 0. However, existing CRON tasks defined in the repo are not altered in the crons table.

The server is trying to execute them normally and fails in the logs with 

image

Whether or not the CRONs should be deleted is debatable (likely not so they continue to work in case the repo gets enabled again). Yet then they should gain a new column which indicates whether they are active or not.

The following DB query can temporarily clean up (= delete) CRON jobs of deactivated repos:

DELETE FROM crons
WHERE repo_id IN (
    SELECT id
    FROM repos
    WHERE user_id = '0'
);

This could also be part of a daily "garbage collection" job.

Steps to reproduce

  1. Define CRON
  2. Disable a repo
  3. Inspect server logs during execution

Expected behavior

CRONs are disabled/not run when a repo is disabled.

System Info

2.7.3

Additional context

No response

Validations