Skip to content

Commit 2fcc326

Browse files
[v1.22.x] Bugfix: Generate just the extra FBC for run bundle-upgrade (#5917)
1 parent cc1e350 commit 2fcc326

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
For run bundle-upgrade, generate just the extra FBC of the bundle instead of rendering the entire index and appending bundle contents to it.
6+
7+
# kind is one of:
8+
# - addition
9+
# - change
10+
# - deprecation
11+
# - removal
12+
# - bugfix
13+
kind: "bugfix"
14+
15+
# Is this a breaking change?
16+
breaking: false
17+
18+
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
19+
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
20+
#
21+
# The generator auto-detects the PR number from the commit
22+
# message in which this file was originally added.
23+
#
24+
# What is the pull request number (without the "#")?
25+
# pull_request_override: 0

internal/olm/operator/registry/index_image.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,13 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
280280
existingBundles[bundle.Name] = bundle.Package
281281
}
282282

283+
extraDeclConfig := &declarativeconfig.DeclarativeConfig{}
283284
// declcfg contains all the bundles we need to insert to form the new FBC
284285
entries := []declarativeconfig.ChannelEntry{} // Used when generating a new channel
285286
for i, bundle := range declcfg.Bundles {
286287
// if it is not present in the bundles array or belongs to a different package, we can add it
287288
if _, present := existingBundles[bundle.Name]; !present || existingBundles[bundle.Name] != bundle.Package {
288-
originalDeclCfg.Bundles = append(originalDeclCfg.Bundles, bundle)
289+
extraDeclConfig.Bundles = append(extraDeclConfig.Bundles, bundle)
289290
}
290291

291292
// constructing a new entry to add
@@ -300,20 +301,21 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
300301

301302
// either add it to a new channel or an existing channel
302303
if channelExists {
303-
originalDeclCfg.Channels[channelIndex].Entries = append(originalDeclCfg.Channels[channelIndex].Entries, entry)
304+
extraDeclConfig.Channels[channelIndex].Entries = []declarativeconfig.ChannelEntry{entry}
304305
} else {
305306
entries = append(entries, entry)
306307
}
307308
}
308309

309310
// create a new channel if it does not exist
310311
if !channelExists {
311-
originalDeclCfg.Channels = append(originalDeclCfg.Channels, declarativeconfig.Channel{
312+
channel := declarativeconfig.Channel{
312313
Schema: fbcutil.SchemaChannel,
313314
Name: f.ChannelName,
314315
Package: f.Package,
315316
Entries: entries,
316-
})
317+
}
318+
extraDeclConfig.Channels = []declarativeconfig.Channel{channel}
317319
}
318320

319321
// check if package already exists
@@ -327,14 +329,15 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
327329

328330
// only add the new package if it does not already exist
329331
if !packagePresent {
330-
originalDeclCfg.Packages = append(originalDeclCfg.Packages, declarativeconfig.Package{
332+
packageBlob := declarativeconfig.Package{
331333
Schema: fbcutil.SchemaPackage,
332334
Name: f.Package,
333335
DefaultChannel: f.ChannelName,
334-
})
336+
}
337+
extraDeclConfig.Packages = []declarativeconfig.Package{packageBlob}
335338
}
336339

337-
return originalDeclCfg, nil
340+
return extraDeclConfig, nil
338341
}
339342

340343
// UpdateCatalog links a new registry pod in catalog source by updating the address and annotations,

0 commit comments

Comments
 (0)