-
Notifications
You must be signed in to change notification settings - Fork 250
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
Feat: Add DefaultFilterSelector and DefaultOutputSelector to fluentd #804
Conversation
ffaa3fc
to
ba73087
Compare
@@ -36,6 +36,10 @@ const ( | |||
type FluentdSpec struct { | |||
// Fluentd global inputs. | |||
GlobalInputs []input.Input `json:"globalInputs,omitempty"` | |||
// Select cluster filter plugins used to filter for the default cluster output | |||
DefaultFilterSelector *metav1.LabelSelector `json:"defaultFilterSelector,omitempty"` |
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.
What is the processing logic for this? I don't see anything in the code that handles that field.
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.
This is handled in the controllers/fluentdconfig_controller.go file starting from line 140.
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.
This is handled in the controllers/fluentdconfig_controller.go file starting from line 140.
@Jakob3xD I cannot see how DefaultFilterSelector
/DefaultOutputSelector
and default_route
is handled in controllers/fluentdconfig_controller.go
filters, outputs, err := r.ListNamespacedLevelResources(ctx, fd.Namespace, fd.Spec.DefaultFilterSelector, fd.Spec.DefaultOutputSelector) | ||
if err != nil { | ||
r.Log.Info("List namespace level resources failed", "config", "default", "err", err.Error()) | ||
return ctrl.Result{}, err | ||
} | ||
if len(filters) > 0 || len(outputs) > 0 { | ||
// Combine the namespaced filter/output pluginstores in this fluentd config | ||
cfgResouces, errs := gpr.PatchAndFilterNamespacedLevelResources(sl, fmt.Sprintf("%s-%s-%s", fd.Kind, fd.Namespace, fd.Name), filters, outputs) | ||
if len(errs) > 0 { | ||
r.Log.Info("Patch and filter namespace level resources failed", "config", "default", "err", strings.Join(errs, ",")) | ||
return ctrl.Result{}, fmt.Errorf(strings.Join(errs, ",")) | ||
} | ||
|
||
// WithCfgResources will collect all plugins to generate main config | ||
err = gpr.WithCfgResources("@default", cfgResouces) | ||
if err != nil { | ||
r.Log.Info("Combine resources failed", "config", "default", "err", err.Error()) | ||
return ctrl.Result{}, err | ||
} | ||
// Add the default route to the main routing plugin | ||
gpr.MainRouterPlugins.InsertPairs("default_route", "@default") | ||
} | ||
|
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.
@benjaminhuo @wenchajun this code block handles the the newly defined default selectors.
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.
Got you. Sorry, my bad it's folded by default.
Thanks anyway for this great enhancement! @Jakob3xD
Signed-off-by: Jakob Hahn <[email protected]>
Signed-off-by: Jakob Hahn <[email protected]>
Signed-off-by: Jakob Hahn <[email protected]>
Signed-off-by: Jakob Hahn <[email protected]>
… for fluentd Signed-off-by: Jakob Hahn <[email protected]>
Signed-off-by: Jakob Hahn <[email protected]>
9ddfe1b
to
b70a222
Compare
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #800
Does this PR introduced a user-facing change?
Additional documentation, usage docs, etc.: