From cbc0a1fc03365b83d5f2a481802dba99b364b172 Mon Sep 17 00:00:00 2001 From: Ben Luddy Date: Thu, 27 Jan 2022 16:28:51 -0500 Subject: [PATCH] Prop to 4.10 -- Stop corrupting resolver cache. (#2604) Signed-off-by: Ben Luddy Upstream-repository: operator-lifecycle-manager Upstream-commit: f42891859d429ee92da04869ecca56917afccaf2 --- .../controller/registry/resolver/resolver.go | 26 +++++++++++++++++-- .../controller/registry/resolver/resolver.go | 26 +++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/staging/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go b/staging/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go index 4905aa3765..c9a465854f 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go +++ b/staging/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go @@ -158,13 +158,35 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust errs = append(errs, err) continue } + + // copy consumed fields to avoid directly mutating cache + op = &cache.Entry{ + Name: op.Name, + Replaces: op.Replaces, + Skips: op.Skips, + SkipRange: op.SkipRange, + ProvidedAPIs: op.ProvidedAPIs, + RequiredAPIs: op.RequiredAPIs, + Version: op.Version, + SourceInfo: &cache.OperatorSourceInfo{ + Package: op.SourceInfo.Package, + Channel: op.SourceInfo.Channel, + StartingCSV: op.SourceInfo.StartingCSV, + Catalog: op.SourceInfo.Catalog, + DefaultChannel: op.SourceInfo.DefaultChannel, + Subscription: op.SourceInfo.Subscription, + }, + Properties: op.Properties, + BundlePath: op.BundlePath, + Bundle: op.Bundle, + } if len(installableOperator.Replaces) > 0 { - op.Replaces = installableOperator.Replaces // TODO: Don't mutate object from cache! + op.Replaces = installableOperator.Replaces } // lookup if this installable came from a starting CSV if _, ok := startingCSVs[csvName]; ok { - op.SourceInfo.StartingCSV = csvName // TODO: Don't mutate object from cache! + op.SourceInfo.StartingCSV = csvName } operators[csvName] = op diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go index 4905aa3765..c9a465854f 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/resolver.go @@ -158,13 +158,35 @@ func (r *SatResolver) SolveOperators(namespaces []string, csvs []*v1alpha1.Clust errs = append(errs, err) continue } + + // copy consumed fields to avoid directly mutating cache + op = &cache.Entry{ + Name: op.Name, + Replaces: op.Replaces, + Skips: op.Skips, + SkipRange: op.SkipRange, + ProvidedAPIs: op.ProvidedAPIs, + RequiredAPIs: op.RequiredAPIs, + Version: op.Version, + SourceInfo: &cache.OperatorSourceInfo{ + Package: op.SourceInfo.Package, + Channel: op.SourceInfo.Channel, + StartingCSV: op.SourceInfo.StartingCSV, + Catalog: op.SourceInfo.Catalog, + DefaultChannel: op.SourceInfo.DefaultChannel, + Subscription: op.SourceInfo.Subscription, + }, + Properties: op.Properties, + BundlePath: op.BundlePath, + Bundle: op.Bundle, + } if len(installableOperator.Replaces) > 0 { - op.Replaces = installableOperator.Replaces // TODO: Don't mutate object from cache! + op.Replaces = installableOperator.Replaces } // lookup if this installable came from a starting CSV if _, ok := startingCSVs[csvName]; ok { - op.SourceInfo.StartingCSV = csvName // TODO: Don't mutate object from cache! + op.SourceInfo.StartingCSV = csvName } operators[csvName] = op