-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: automatically EOL lifeless rolling chroots
When rolling policy finishes, we want to remove the data, but we also want to mark the CoprChroot.deleted (disable it from the project) because the corresponding mock chroot is still active in Copr. When user does a new build, we reset the CoprChroot delete_after/notification state, always. This is ok because during the normal MockChroot EOL policy, we do not allow new builds. Implements: https://github.com/fedora-copr/debate/blob/main/2024-04-23-rawhide-chroots-eol.md Fixes: #2933
- Loading branch information
Showing
20 changed files
with
283 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.. _eol_logic: | ||
|
||
Handling EOL CoprChroot entries | ||
------------------------------- | ||
|
||
There are currently three cases when we schedule a CoprChroot for removal but | ||
preserve the data for some time to allow users to recover: | ||
|
||
1. User disables the chroot in a project ("unclicks" the checkbox). We give | ||
them 14 days "preservation period" to reverse the decision without | ||
forcing them to rebuild everything. | ||
2. Copr Admin makes a chroot EOL, e.g., `fedora-38-x86_64` because the | ||
Fedora 38 version goes EOL. We keep the builds for several months, and | ||
users can extend the preservation period. | ||
3. We disable rolling chroots (e.g., Fedora Rawhide or Fedora ELN) after a | ||
reasonable period of inactivity. | ||
|
||
There are three database fields used for handling the EOL/preservation policies: | ||
``CoprChroot.deleted`` (bool), ``CoprChroot.delete_after`` (timestamp), | ||
and ``MockChroot.is_active`` (bool, 1:N mapped to ``CoprChroot``). The | ||
following table describes certain implications behind the logic: | ||
|
||
|
||
.. table:: Logical implications per in-DB chroot state | ||
|
||
|
||
========= ============ ======= ==================== ========= =========== | ||
is_active delete_after deleted e-mail |br| can build State && |br| Description | ||
notifications | ||
========= ============ ======= ==================== ========= =========== | ||
yes yes yes no no |p_yel| ``preserved`` PM - preserved - manual removal |p_end| | ||
yes no yes -- no |p_red| ``deleted`` manual removal or rolling removal (or EOL removal, and reactivated) |p_end| | ||
yes yes no yes yes |p_yel| ``preserved`` rolling |p_end| | ||
yes no no -- yes |p_gre| ``active`` normal chroot state |p_end| | ||
no yes yes no no |p_yel| ``preserved`` (deleted manualy, then mock chroot EOL or deactivation) |p_end| | ||
no no yes -- no |p_red| ``deleted`` manually OR rolling deleted, and THEN EOLed/deactivated by Copr admin |p_end| | ||
no yes no yes no |p_yel| ``preserved`` mock chroot EOLed by Copr admin |p_end| | ||
no no no -- no |p_gra| ``deactivated`` deactivated by Copr admin, data preserved |p_end| | ||
========= ============ ======= ==================== ========= =========== | ||
|
||
There's also a chroot state ``expired``, which is a special state of | ||
the ``preserved`` state. It is "still preserved", but the time for removal is | ||
already there, namely ``now() >= delete_after``. | ||
|
||
Note that when ``e-mail notifications`` are ``yes``, the time for removal has | ||
come (``now() >= delete_after``) and we **were not** able to send the | ||
notification e-mail, we **don't** remove the chroot data. **No unexpected | ||
removals.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
frontend/coprs_frontend/alembic/versions/d23f84f87130_eol_rolling_builds.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
record last copr_chroot build, allow marking Rawhide as rolling | ||
Create Date: 2024-05-13 08:56:31.557843 | ||
""" | ||
|
||
import time | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.sql import text | ||
|
||
revision = 'd23f84f87130' | ||
down_revision = '9fec2c962fcd' | ||
|
||
def upgrade(): | ||
op.add_column('mock_chroot', sa.Column('rolling', sa.Boolean(), nullable=True)) | ||
op.add_column('copr_chroot', sa.Column('last_build_timestamp', sa.Integer(), nullable=True)) | ||
conn = op.get_bind() | ||
conn.execute( | ||
text("update copr_chroot set last_build_timestamp = :start_stamp;"), | ||
{"start_stamp": int(time.time())}, | ||
) | ||
op.create_index('copr_chroot_rolling_last_build_idx', 'copr_chroot', | ||
['mock_chroot_id', 'last_build_timestamp', 'delete_after'], | ||
unique=False) | ||
|
||
|
||
def downgrade(): | ||
op.drop_index('copr_chroot_rolling_last_build_idx', table_name='copr_chroot') | ||
op.drop_column('copr_chroot', 'last_build_timestamp') | ||
op.drop_column('mock_chroot', 'rolling') |
14 changes: 14 additions & 0 deletions
14
frontend/coprs_frontend/commands/eol_lifeless_rolling_chroots.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
copr-frontend eol-lifeless-rolling-chroots command | ||
""" | ||
|
||
import click | ||
from coprs.logic.outdated_chroots_logic import OutdatedChrootsLogic | ||
|
||
@click.command() | ||
def eol_lifeless_rolling_chroots(): | ||
""" | ||
Go through all rolling CoprChroots and check whether they shouldn't be | ||
scheduled for future removal. | ||
""" | ||
OutdatedChrootsLogic.trigger_rolling_eol_policy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.