Switch impersonatorconfig to all singleton queues.

We also no longer need an initial event, since we don't do anything unless the CredentialIssuer exists, so we'll always be triggered at the appropriate time.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-05-26 12:54:40 -05:00
parent b13c494f93
commit 1a4687a40a
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
3 changed files with 5 additions and 21 deletions

View File

@ -93,7 +93,6 @@ func NewImpersonatorConfigController(
servicesInformer corev1informers.ServiceInformer, servicesInformer corev1informers.ServiceInformer,
secretsInformer corev1informers.SecretInformer, secretsInformer corev1informers.SecretInformer,
withInformer pinnipedcontroller.WithInformerOptionFunc, withInformer pinnipedcontroller.WithInformerOptionFunc,
withInitialEvent pinnipedcontroller.WithInitialEventOptionFunc,
generatedLoadBalancerServiceName string, generatedLoadBalancerServiceName string,
generatedClusterIPServiceName string, generatedClusterIPServiceName string,
tlsSecretName string, tlsSecretName string,
@ -140,20 +139,18 @@ func NewImpersonatorConfigController(
), ),
withInformer( withInformer(
servicesInformer, servicesInformer,
pinnipedcontroller.NameAndNamespaceExactMatchFilterFactory(generatedLoadBalancerServiceName, namespace), pinnipedcontroller.SimpleFilterWithSingletonQueue(func(obj metav1.Object) bool {
return obj.GetNamespace() == namespace && obj.GetName() == generatedLoadBalancerServiceName
}),
controllerlib.InformerOption{}, controllerlib.InformerOption{},
), ),
withInformer( withInformer(
secretsInformer, secretsInformer,
pinnipedcontroller.SimpleFilter(func(obj metav1.Object) bool { pinnipedcontroller.SimpleFilterWithSingletonQueue(func(obj metav1.Object) bool {
return obj.GetNamespace() == namespace && secretNames.Has(obj.GetName()) return obj.GetNamespace() == namespace && secretNames.Has(obj.GetName())
}, nil), }),
controllerlib.InformerOption{}, controllerlib.InformerOption{},
), ),
// Be sure to run once even if the CredentialIssuer that the informer is watching doesn't exist so we can implement
// the default configuration behavior.
withInitialEvent(controllerlib.Key{Name: credentialIssuerResourceName}),
// TODO fix these controller options to make this a singleton queue
) )
} }

View File

@ -57,7 +57,6 @@ func TestImpersonatorConfigControllerOptions(t *testing.T) {
var r *require.Assertions var r *require.Assertions
var observableWithInformerOption *testutil.ObservableWithInformerOption var observableWithInformerOption *testutil.ObservableWithInformerOption
var observableWithInitialEventOption *testutil.ObservableWithInitialEventOption
var credIssuerInformerFilter controllerlib.Filter var credIssuerInformerFilter controllerlib.Filter
var servicesInformerFilter controllerlib.Filter var servicesInformerFilter controllerlib.Filter
var secretsInformerFilter controllerlib.Filter var secretsInformerFilter controllerlib.Filter
@ -66,7 +65,6 @@ func TestImpersonatorConfigControllerOptions(t *testing.T) {
it.Before(func() { it.Before(func() {
r = require.New(t) r = require.New(t)
observableWithInformerOption = testutil.NewObservableWithInformerOption() observableWithInformerOption = testutil.NewObservableWithInformerOption()
observableWithInitialEventOption = testutil.NewObservableWithInitialEventOption()
pinnipedInformerFactory := pinnipedinformers.NewSharedInformerFactory(nil, 0) pinnipedInformerFactory := pinnipedinformers.NewSharedInformerFactory(nil, 0)
sharedInformerFactory := kubeinformers.NewSharedInformerFactory(nil, 0) sharedInformerFactory := kubeinformers.NewSharedInformerFactory(nil, 0)
credIssuerInformer := pinnipedInformerFactory.Config().V1alpha1().CredentialIssuers() credIssuerInformer := pinnipedInformerFactory.Config().V1alpha1().CredentialIssuers()
@ -83,7 +81,6 @@ func TestImpersonatorConfigControllerOptions(t *testing.T) {
servicesInformer, servicesInformer,
secretsInformer, secretsInformer,
observableWithInformerOption.WithInformer, observableWithInformerOption.WithInformer,
observableWithInitialEventOption.WithInitialEvent,
generatedLoadBalancerServiceName, generatedLoadBalancerServiceName,
generatedClusterIPServiceName, generatedClusterIPServiceName,
tlsSecretName, tlsSecretName,
@ -240,14 +237,6 @@ func TestImpersonatorConfigControllerOptions(t *testing.T) {
}) })
}) })
}) })
when("starting up", func() {
it("asks for an initial event because the CredentialIssuer may not exist yet and it needs to run anyway", func() {
r.Equal(&controllerlib.Key{
Name: credentialIssuerResourceName,
}, observableWithInitialEventOption.GetInitialEventKey())
})
})
}, spec.Parallel(), spec.Report(report.Terminal{})) }, spec.Parallel(), spec.Report(report.Terminal{}))
} }
@ -531,7 +520,6 @@ func TestImpersonatorConfigControllerSync(t *testing.T) {
kubeInformers.Core().V1().Services(), kubeInformers.Core().V1().Services(),
kubeInformers.Core().V1().Secrets(), kubeInformers.Core().V1().Secrets(),
controllerlib.WithInformer, controllerlib.WithInformer,
controllerlib.WithInitialEvent,
loadBalancerServiceName, loadBalancerServiceName,
clusterIPServiceName, clusterIPServiceName,
tlsSecretName, tlsSecretName,

View File

@ -259,7 +259,6 @@ func PrepareControllers(c *Config) (func(ctx context.Context), error) {
informers.installationNamespaceK8s.Core().V1().Services(), informers.installationNamespaceK8s.Core().V1().Services(),
informers.installationNamespaceK8s.Core().V1().Secrets(), informers.installationNamespaceK8s.Core().V1().Secrets(),
controllerlib.WithInformer, controllerlib.WithInformer,
controllerlib.WithInitialEvent,
c.NamesConfig.ImpersonationLoadBalancerService, c.NamesConfig.ImpersonationLoadBalancerService,
c.NamesConfig.ImpersonationClusterIPService, c.NamesConfig.ImpersonationClusterIPService,
c.NamesConfig.ImpersonationTLSCertificateSecret, c.NamesConfig.ImpersonationTLSCertificateSecret,