From 490c112c9ed4395cbb93bb5573601e6017e89a24 Mon Sep 17 00:00:00 2001 From: Adrian Clay Lake Date: Thu, 19 Dec 2024 15:56:01 +0000 Subject: [PATCH] feat: stop eol builds from releaseing --- src/image/release.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/image/release.py b/src/image/release.py index 1ba19e0e..fdc51b25 100755 --- a/src/image/release.py +++ b/src/image/release.py @@ -11,11 +11,18 @@ import re import subprocess from collections import defaultdict +from datetime import datetime, timezone + import yaml -from .utils.encoders import DateTimeEncoder -from .utils.schema.triggers import ImageSchema, KNOWN_RISKS_ORDERED + import src.shared.release_info as shared +from .utils.encoders import DateTimeEncoder +from .utils.schema.triggers import KNOWN_RISKS_ORDERED, ImageSchema + +# generate single date for consistent EOL checking +execution_timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + parser = argparse.ArgumentParser() parser.add_argument( "--image-trigger", @@ -101,7 +108,10 @@ print(f"Track {track} will be created for the 1st time") all_releases[track] = {} - if isinstance(upload_release_dict, dict) and "end-of-life" in upload_release_dict: + if ( + isinstance(upload_release_dict, dict) + and "end-of-life" in upload_release_dict + ): all_releases[track]["end-of-life"] = upload_release_dict["end-of-life"] print( @@ -155,6 +165,25 @@ print(f"Tag {follow_tag} is following tag {parent_tag}.") follow_tag = parent_tag + # check if any of the followed tags are eol + is_eol = False + for tag in [*followed_tags]: + + track = tag.split("_")[0] + + # check if eol data exists, if not skip ahead + if "end-of-life" not in all_releases[track]: + continue + + # TODO: we should be parsing the timetamp to unix time for comparison + # this can be dangerous if the timestamp formatting changes. Also see: + # oci-factory/tools/workflow-engine/charms/temporal-worker/oci_factory/activities/find_images_to_update.py + is_eol |= all_releases[track]["end-of-life"] < execution_timestamp + + # if we are eol, skip this release + if is_eol: + continue + if int(follow_tag) not in revision_to_track: msg = str( f"The tag {channel_tag} points to revision {follow_tag}, "