Skip to content

Commit d18deee

Browse files
committed
pkg/cvo: Separate ConfigMap informer for openshift-config-managed
With c9fab43 (pkg/cvo: Fetch proxy CA certs from openshift-config-managed/trusted-ca-bundle, 2020-01-31, #311), I attempted to pivot to loading the TLS configration from the openshift-config-managed namespace. But I hadn't realized that cmConfigInformer was scoped to the openshift-config namespace, so attempts to retrieve trusted-ca-bundle failed via the "not found" no-op path regardless of whether the ConfigMap actually existed. With this commit, I create a new informer for the openshift-config-managed namespace, so we can successfully retrieve the ConfigMap when it exists. An alternative approach would be to drop the informers.WithNamespace filter. My impression is that having two namespace-filtered informers will be more efficient than a single unfiltered informer, but I'm not really sure.
1 parent 3401029 commit d18deee

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pkg/cvo/cvo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func New(
163163
cvInformer configinformersv1.ClusterVersionInformer,
164164
coInformer configinformersv1.ClusterOperatorInformer,
165165
cmConfigInformer informerscorev1.ConfigMapInformer,
166+
cmConfigManagedInformer informerscorev1.ConfigMapInformer,
166167
proxyInformer configinformersv1.ProxyInformer,
167168
client clientset.Interface,
168169
kubeClient kubernetes.Interface,
@@ -208,7 +209,7 @@ func New(
208209

209210
optr.proxyLister = proxyInformer.Lister()
210211
optr.cmConfigLister = cmConfigInformer.Lister().ConfigMaps(internal.ConfigNamespace)
211-
optr.cmConfigManagedLister = cmConfigInformer.Lister().ConfigMaps(internal.ConfigManagedNamespace)
212+
optr.cmConfigManagedLister = cmConfigManagedInformer.Lister().ConfigMaps(internal.ConfigManagedNamespace)
212213

213214
// make sure this is initialized after all the listers are initialized
214215
optr.upgradeableChecks = optr.defaultUpgradeableChecks()

pkg/start/start.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,10 @@ type Context struct {
380380
CVO *cvo.Operator
381381
AutoUpdate *autoupdate.Controller
382382

383-
CVInformerFactory externalversions.SharedInformerFactory
384-
OpenshiftConfigInformerFactory informers.SharedInformerFactory
385-
InformerFactory externalversions.SharedInformerFactory
383+
CVInformerFactory externalversions.SharedInformerFactory
384+
OpenshiftConfigInformerFactory informers.SharedInformerFactory
385+
OpenshiftConfigManagedInformerFactory informers.SharedInformerFactory
386+
InformerFactory externalversions.SharedInformerFactory
386387
}
387388

388389
// NewControllerContext initializes the default Context for the current Options. It does
@@ -395,14 +396,16 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
395396
opts.FieldSelector = fmt.Sprintf("metadata.name=%s", o.Name)
396397
})
397398
openshiftConfigInformer := informers.NewSharedInformerFactoryWithOptions(kubeClient, resyncPeriod(o.ResyncInterval)(), informers.WithNamespace(internal.ConfigNamespace))
399+
openshiftConfigManagedInformer := informers.NewSharedInformerFactoryWithOptions(kubeClient, resyncPeriod(o.ResyncInterval)(), informers.WithNamespace(internal.ConfigManagedNamespace))
398400

399401
sharedInformers := externalversions.NewSharedInformerFactory(client, resyncPeriod(o.ResyncInterval)())
400402

401403
coInformer := sharedInformers.Config().V1().ClusterOperators()
402404
ctx := &Context{
403-
CVInformerFactory: cvInformer,
404-
OpenshiftConfigInformerFactory: openshiftConfigInformer,
405-
InformerFactory: sharedInformers,
405+
CVInformerFactory: cvInformer,
406+
OpenshiftConfigInformerFactory: openshiftConfigInformer,
407+
OpenshiftConfigManagedInformerFactory: openshiftConfigManagedInformer,
408+
InformerFactory: sharedInformers,
406409

407410
CVO: cvo.New(
408411
o.NodeName,
@@ -414,6 +417,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
414417
cvInformer.Config().V1().ClusterVersions(),
415418
coInformer,
416419
openshiftConfigInformer.Core().V1().ConfigMaps(),
420+
openshiftConfigManagedInformer.Core().V1().ConfigMaps(),
417421
sharedInformers.Config().V1().Proxies(),
418422
cb.ClientOrDie(o.Namespace),
419423
cb.KubeClientOrDie(o.Namespace, useProtobuf),
@@ -447,5 +451,6 @@ func (c *Context) Start(ctx context.Context) {
447451
}
448452
c.CVInformerFactory.Start(ch)
449453
c.OpenshiftConfigInformerFactory.Start(ch)
454+
c.OpenshiftConfigManagedInformerFactory.Start(ch)
450455
c.InformerFactory.Start(ch)
451456
}

0 commit comments

Comments
 (0)