-
Notifications
You must be signed in to change notification settings - Fork 43
NETOBSERV-2402: Adding lokistack status to console plugin configmap #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "context" | ||
| "fmt" | ||
|
|
||
| lokiv1 "github.com/grafana/loki/operator/apis/loki/v1" | ||
| osv1 "github.com/openshift/api/console/v1" | ||
| securityv1 "github.com/openshift/api/security/v1" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
|
|
@@ -12,6 +13,7 @@ import ( | |
| ctrl "sigs.k8s.io/controller-runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
| "sigs.k8s.io/controller-runtime/pkg/handler" | ||
| "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
|
||
| flowslatest "github.com/netobserv/network-observability-operator/api/flowcollector/v1beta2" | ||
|
|
@@ -68,6 +70,11 @@ func Start(ctx context.Context, mgr *manager.Manager) (manager.PostCreateHook, e | |
| log.Info("CNO not detected: using ovnKubernetes config and reconciler") | ||
| } | ||
|
|
||
| if mgr.ClusterInfo.HasLokiStack() { | ||
| builder.Watches(&lokiv1.LokiStack{}, &handler.EnqueueRequestForObject{}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally, we would enqueue only when our configured lokistack is affected, not all lokistacks
Comment on lines
+73
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from Claude review:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not think about making a k8s query inside the handler to filter Lokistacks. The approach I thought was to wait for the flowcollector to be created and start a dedicated controller with a static flowcollector name. This was adding a lot of complexity and I was not sure if it was worth it. This looks like a more simple solution, to the price of a k8s querry in the handler function. @jotak what do you think ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we need to overcomplicate things here. It's basically my comment here: #2142 (comment) ; having a couple of false-positive reconcile events is not so important; we're talking about lokistack objects, it's not expected to have many, and they don't change often. btw I think claude answer is wrong the enqueue request is not for a flow-collector named after the loki stack, it's for any flow-collector? (
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we really want to narrow down to our configured lokistack, in other situation we just keep in controller state the last-time seen element that we want to check (we do that in a couple of places for flowcollector.spec.namespace iirc); we could do the same with the configured lokistack. |
||
| log.Info("LokiStack CRD detected") | ||
| } | ||
|
|
||
| ctrl, err := builder.Build(&r) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not tested, but looking at the code I think there's a problem here:
In
reconcileConfigMap, thelokiStackobject is created and can have the following values:&lokiv1.LokiStack{}when not in LokiStack modeSo in this last situation, the returned value would be
pending, which seems incorrect?IMO, what we could do:
Also, I'm not sure it's useful to check for the presence of the LokiStack API: if it's configured in LokiStack mode BUT the API is not present, the config is wrong, so it's ok to just display the error message that would come up when trying to fetch LokiStack?
wdyt?