-
Notifications
You must be signed in to change notification settings - Fork 32
NETOBSERV-2225 - Deploy static plugin at operator startup #1345
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?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// force reconcile at startup | ||
go r.InitReconcile(ctx) | ||
|
||
return nil | ||
} | ||
|
||
func (r *FlowCollectorReconciler) InitReconcile(ctx context.Context) error { | ||
log := log.FromContext(ctx) | ||
log.Info("Initializing resources...") | ||
|
||
var err error | ||
for attempt := range initReconcileAttempts { | ||
// delay the reconcile calls to let some time to the cache to load | ||
time.Sleep(5 * time.Second) | ||
_, err = r.Reconcile(ctx, reconcile.Request{}) | ||
if err != nil { | ||
log.Error(err, "Error while doing initial reconcile", "attempt", attempt) | ||
} else { | ||
break | ||
} | ||
} | ||
return err | ||
} |
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.
☝️ I wonder if there is an out of box mechanism to trigger the loop after the cache loaded. That's why I'm using a sleep here and this will may work in all situations.
https://redhat-internal.slack.com/archives/C02939DP5L5/p1743518264445429
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.
If I remember correctly, when a reconcile loop is failing, you can also return a time value to reschedule the reconciliation.
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.
Yeah I gave a try with that without success.
I'm refactoring the code again to move the static content to another controller wich will be cleaner I guess. I will give another try with the reschedule time on the new controller 👍
c4c57e1
to
dbc4cbf
Compare
New images:
They will expire after two weeks. To deploy this build: # Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:40740e0 make deploy
# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-sha-40740e0 Or as a Catalog Source: apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: netobserv-dev
namespace: openshift-marketplace
spec:
sourceType: grpc
image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-40740e0
displayName: NetObserv development catalog
publisher: Me
updateStrategy:
registryPoll:
interval: 1m |
/test e2e-operator |
@jpinsonneau there seems to be an issue where plugin does become ready, despite pod is in Running state and no issues with Loki whatsoever:
the static plugin pod had this error:
I had monolithic loki configured in my flowcollector - anything I am missing for static console plugin config? |
@memodi are you using the proper plugin image mentionned above ? |
I was not, I didn't realize that's dependency. I'll try with it today. Thanks! |
New images:
They will expire after two weeks. To deploy this build: # Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:1c54f0e make deploy
# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-sha-1c54f0e Or as a Catalog Source: apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: netobserv-dev
namespace: openshift-marketplace
spec:
sourceType: grpc
image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-1c54f0e
displayName: NetObserv development catalog
publisher: Me
updateStrategy:
registryPoll:
interval: 1m |
@memodi FYI I did some changes to address #1345 (comment) comment Just tested and the behavior remains the same 😉 |
/jira NETOBSERV-2225 |
log := log.FromContext(ctx) | ||
log.Info("Initializing resources...") | ||
|
||
for attempt := range initReconcileAttempts { |
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.
btw, what happens if all 5 attempts fail? The static plugin wouldn't deploy, but the rest would work normally? Or does it make the controller CLBO or so ? (my understanding is it's the first, but just want to make sure)
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.
If the attempts fails, the static plugin will not be there at controller startup.
As soon as a reconcile loop is triggered, it will appears (ie creating a FlowCollector for example)
|
||
r.status.SetUnknown() | ||
defer r.status.Commit(ctx, r.Client) | ||
|
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.
After setting "Unknown", I think this controller should return if openshift isn't detected, right?
We could check it in Kind
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.
That's done in the static reconciler using HasConsolePlugin
function:
network-observability-operator/controllers/consoleplugin/consoleplugin_static_reconciler.go
Lines 40 to 77 in 1080b69
func (r *CPReconciler) reconcileStatic(ctx context.Context, desired *flowslatest.FlowCollector) error { | |
l := log.FromContext(ctx).WithName("console-plugin") | |
ctx = log.IntoContext(ctx, l) | |
// Retrieve current owned objects | |
err := r.Managed.FetchAll(ctx) | |
if err != nil { | |
return err | |
} | |
if r.ClusterInfo.HasConsolePlugin() { | |
if err = r.checkAutoPatch(ctx, desired, constants.StaticPluginName); err != nil { | |
return err | |
} | |
} | |
if r.ClusterInfo.HasConsolePlugin() { | |
// Create object builder | |
builder := newBuilder(r.Instance, &desired.Spec, constants.StaticPluginName) | |
if err = r.reconcilePlugin(ctx, &builder, &desired.Spec, constants.StaticPluginName, "NetObserv static plugin"); err != nil { | |
return err | |
} | |
if err = r.reconcileDeployment(ctx, &builder, &desired.Spec, constants.StaticPluginName, ""); err != nil { | |
return err | |
} | |
if err = r.reconcileServices(ctx, &builder, constants.StaticPluginName); err != nil { | |
return err | |
} | |
} else { | |
// delete any existing owned object | |
r.Managed.TryDeleteAll(ctx) | |
} | |
return nil | |
} |
If console plugin is not available, nothing is deployed and the status goes ready
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.
The static controller could deploy something else than the console plugin in future so I think it's better to keeps things separated here. WDYT ?
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.
ah ok, yes sounds good, thanks!
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.
Just a comment when not running on openshift, other than that lgtm
/restest |
/lgtm |
@jpinsonneau: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
1 similar comment
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description
Create the console plugin when FlowCollector doesn't exists to expose the new forms.
Suggested alternatives: #1346 & #1374See netobserv/network-observability-console-plugin#763 for the forms implementations
Dependencies
n/a
Checklist
If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.