Skip to content

Commit

Permalink
NETOBSERV-1134: do not unregister plugin (#507)
Browse files Browse the repository at this point in the history
Plugin might be registered by different means; we shouldn't reconcile registration based on
the register field when it's false, as it would override any other mean to register it.
  • Loading branch information
jotak committed Jan 8, 2024
1 parent d1e9c04 commit 2326a5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions controllers/consoleplugin/consoleplugin_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ func (r *CPReconciler) checkAutoPatch(ctx context.Context, desired *flowslatest.
if reg && !registered {
console.Spec.Plugins = append(console.Spec.Plugins, constants.PluginName)
return r.Client.Update(ctx, &console)
} else if !reg && registered {
console.Spec.Plugins = helper.RemoveAllStrings(console.Spec.Plugins, constants.PluginName)
return r.Client.Update(ctx, &console)
}
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/flowcollector_controller_console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func flowCollectorConsolePluginSpecs() {
Enable: ptr.To(true),
Port: 9001,
ImagePullPolicy: "Never",
Register: ptr.To(true),
Register: ptr.To(false),
Autoscaler: flowslatest.FlowCollectorHPA{
Status: flowslatest.HPAStatusEnabled,
MinReplicas: ptr.To(int32(1)),
Expand Down Expand Up @@ -224,20 +224,20 @@ func flowCollectorConsolePluginSpecs() {
})

Context("Registering to the Console CR", func() {
It("Should be registered by default", func() {
It("Should start unregistered", func() {
Eventually(func() interface{} {
cr := operatorsv1.Console{}
if err := k8sClient.Get(ctx, consoleCRKey, &cr); err != nil {
return err
}
return cr.Spec.Plugins
}, timeout, interval).Should(Equal([]string{"netobserv-plugin"}))
}, timeout, interval).Should(BeEmpty())
})

It("Should be unregistered", func() {
By("Update CR to unregister")
updateCR(crKey, func(fc *flowslatest.FlowCollector) {
fc.Spec.ConsolePlugin.Register = ptr.To(false)
fc.Spec.ConsolePlugin.Register = ptr.To(true)
})

By("Expecting the Console CR to not have plugin registered")
Expand All @@ -247,7 +247,7 @@ func flowCollectorConsolePluginSpecs() {
return err
}
return cr.Spec.Plugins
}, timeout, interval).Should(BeEmpty())
}, timeout, interval).Should(Equal([]string{"netobserv-plugin"}))
})
})

Expand Down

0 comments on commit 2326a5f

Please sign in to comment.