Skip to content

Commit 623572b

Browse files
authored
Stop corrupting resolver cache. (#2604)
Signed-off-by: Ben Luddy <[email protected]>
1 parent 39e73d5 commit 623572b

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

pkg/controller/registry/resolver/resolver.go

+24-2
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,35 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust
159159
errs = append(errs, err)
160160
continue
161161
}
162+
163+
// copy consumed fields to avoid directly mutating cache
164+
op = &cache.Entry{
165+
Name: op.Name,
166+
Replaces: op.Replaces,
167+
Skips: op.Skips,
168+
SkipRange: op.SkipRange,
169+
ProvidedAPIs: op.ProvidedAPIs,
170+
RequiredAPIs: op.RequiredAPIs,
171+
Version: op.Version,
172+
SourceInfo: &cache.OperatorSourceInfo{
173+
Package: op.SourceInfo.Package,
174+
Channel: op.SourceInfo.Channel,
175+
StartingCSV: op.SourceInfo.StartingCSV,
176+
Catalog: op.SourceInfo.Catalog,
177+
DefaultChannel: op.SourceInfo.DefaultChannel,
178+
Subscription: op.SourceInfo.Subscription,
179+
},
180+
Properties: op.Properties,
181+
BundlePath: op.BundlePath,
182+
Bundle: op.Bundle,
183+
}
162184
if len(installableOperator.Replaces) > 0 {
163-
op.Replaces = installableOperator.Replaces // TODO: Don't mutate object from cache!
185+
op.Replaces = installableOperator.Replaces
164186
}
165187

166188
// lookup if this installable came from a starting CSV
167189
if _, ok := startingCSVs[csvName]; ok {
168-
op.SourceInfo.StartingCSV = csvName // TODO: Don't mutate object from cache!
190+
op.SourceInfo.StartingCSV = csvName
169191
}
170192

171193
operators[csvName] = op

0 commit comments

Comments
 (0)