Skip to content

Commit 121fac5

Browse files
authored
(bugfix): run bundle and run bundle-upgrade - update registry pod index directory and extraDeclConfig (operator-framework#5894)
* update registry pod index directory The registry pod index directory now includes the CatalogSource name to prevent conflicts between indexes in the same directory Signed-off-by: Bryce Palmer <[email protected]> * copy channel from original and always add package Signed-off-by: Bryce Palmer <[email protected]> * copy Other metadata from original DC Signed-off-by: Bryce Palmer <[email protected]>
1 parent 34f6b42 commit 121fac5

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

internal/olm/operator/registry/fbcindex/fbc_registry_pod.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (f *FBCRegistryPod) init(cfg *operator.Configuration, cs *v1alpha1.CatalogS
8181
}
8282

8383
if f.FBCIndexRootDir == "" {
84-
f.FBCIndexRootDir = "/configs"
84+
f.FBCIndexRootDir = fmt.Sprintf("/%s-configs", cs.Name)
8585
}
8686

8787
f.cfg = cfg

internal/olm/operator/registry/index_image.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
246246
return nil, fmt.Errorf("bundle image should contain at least one bundle blob")
247247
}
248248

249+
extraDeclConfig := &declarativeconfig.DeclarativeConfig{}
250+
// declcfg contains all the bundles we need to insert to form the new FBC
251+
entries := []declarativeconfig.ChannelEntry{} // Used when generating a new channel
252+
249253
// Checking if the existing file-based catalog (before upgrade) contains the bundle and channel that we intend to insert.
250254
// If the bundle already exists, we error out. If the channel already exists, we store the index of the channel. This
251255
// index will be used to access the channel from the declarative config object
@@ -270,6 +274,8 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
270274
return nil, err
271275
}
272276

277+
extraDeclConfig.Channels = append(extraDeclConfig.Channels, channel)
278+
273279
break // We only want to search through the specific channel
274280
}
275281
}
@@ -280,9 +286,6 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
280286
existingBundles[bundle.Name] = bundle.Package
281287
}
282288

283-
extraDeclConfig := &declarativeconfig.DeclarativeConfig{}
284-
// declcfg contains all the bundles we need to insert to form the new FBC
285-
entries := []declarativeconfig.ChannelEntry{} // Used when generating a new channel
286289
for i, bundle := range declcfg.Bundles {
287290
// if it is not present in the bundles array or belongs to a different package, we can add it
288291
if _, present := existingBundles[bundle.Name]; !present || existingBundles[bundle.Name] != bundle.Package {
@@ -318,24 +321,16 @@ func upgradeFBC(ctx context.Context, f *fbcutil.FBCContext, originalDeclCfg *dec
318321
extraDeclConfig.Channels = []declarativeconfig.Channel{channel}
319322
}
320323

321-
// check if package already exists
322-
packagePresent := false
323-
for _, packageName := range originalDeclCfg.Packages {
324-
if packageName.Name == f.Package {
325-
packagePresent = true
326-
break
327-
}
324+
// always add the package as we are starting with a new empty DeclarativeConfig
325+
packageBlob := declarativeconfig.Package{
326+
Schema: fbcutil.SchemaPackage,
327+
Name: f.Package,
328+
DefaultChannel: f.ChannelName,
328329
}
330+
extraDeclConfig.Packages = []declarativeconfig.Package{packageBlob}
329331

330-
// only add the new package if it does not already exist
331-
if !packagePresent {
332-
packageBlob := declarativeconfig.Package{
333-
Schema: fbcutil.SchemaPackage,
334-
Name: f.Package,
335-
DefaultChannel: f.ChannelName,
336-
}
337-
extraDeclConfig.Packages = []declarativeconfig.Package{packageBlob}
338-
}
332+
// copy over any other FBC metadata
333+
extraDeclConfig.Others = originalDeclCfg.Others
339334

340335
return extraDeclConfig, nil
341336
}

0 commit comments

Comments
 (0)