Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions doozer/doozerlib/backend/konflux_fbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,10 +1202,15 @@ def _update_channel(channel: Dict):
# FIXME: We try to mimic how `skips` field is updated by the old ET centric process.
# We should verify if this is correct.
skips = None
bundle_with_skips = next(
(it for it in channel['entries'] if it.get('skips')), None
) # Find which bundle has the skips field
if bundle_with_skips is not None:

# Detect whether existing entries form a replaces-based update graph
# (e.g. ACM). These graphs are deliberately managed — preserve them
# as-is and do NOT migrate skips onto the new head entry.
has_replaces_graph = any(e.get('replaces') for e in channel['entries'])

if has_replaces_graph:
logger.info("Channel has replaces-based update graph; preserving existing entries")
elif (bundle_with_skips := next((it for it in channel['entries'] if it.get('skips')), None)) is not None:
# the channel already has skips like
# ------------
# entries:
Expand All @@ -1223,6 +1228,13 @@ def _update_channel(channel: Dict):
# and add the bundle name of bundle_with_skips to the skips field
skips = set(bundle_with_skips.pop('skips'))
skips = (skips | {bundle_with_skips['name']}) - {olm_bundle_name}
# Also collect skips from any remaining entries (handles branching
# upgrade graphs where multiple entries independently define skips)
for other in channel['entries']:
if other is not bundle_with_skips and other.get('skips'):
skips.update(other.pop('skips'))
skips.add(other['name'])
skips.discard(olm_bundle_name)
elif len(channel['entries']) == 1:
# The channel only has one entry like
# ------------
Expand Down Expand Up @@ -1278,11 +1290,14 @@ def _update_channel(channel: Dict):
# Calculate replaces based on current head before appending
replaces = None
if not self.group.startswith('openshift-'):
# Find the current head - the entry that is not replaced by any other entry
bundle_with_replaces = [it for it in channel['entries']]
replaced_names = {it.get('replaces') for it in bundle_with_replaces if it.get('replaces')}
# Find the current head - the entry not superseded
# (not replaced or skipped) by any other entry
all_entries = list(channel['entries'])
superseded_names = {it.get('replaces') for it in all_entries if it.get('replaces')}
for it in all_entries:
superseded_names.update(it.get('skips', []))
current_head = next(
(it for it in bundle_with_replaces if it['name'] not in replaced_names), None
(it for it in all_entries if it['name'] not in superseded_names), None
)
if current_head:
# The new bundle should replace the current head
Expand Down
Loading
Loading