Skip to content
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

[FlowAggregator] Fix live config updates for IPFIXExporter #6385

Conversation

antoninbas
Copy link
Contributor

In particular, updates to recordContents.podLabels and recordFormat were ignored, without any kind of warning.

In particular, updates to recordContents.podLabels and recordFormat
were ignored, without any kind of warning.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
if address == e.externalFlowCollectorAddr && protocol == e.externalFlowCollectorProto {
func (e *IPFIXExporter) UpdateOptions(opt *options.Options) {
config := opt.Config.FlowCollector
if reflect.DeepEqual(config, e.config) && opt.Config.RecordContents.PodLabels == e.includePodLabels {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unsupported changes could return false here and leads to "New IPFIXExporter configuration" log even nothing changes, for example, by updating enable. Could it be confusing?

According to the description "updates to recordContents.podLabels and recordFormat were ignored, without any kind of warning.", should it warn users that it's unsupported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is an update to enable, this code will never be executed:

if opt.Config.FlowCollector.Enable {
if fa.ipfixExporter == nil {
klog.InfoS("Enabling Flow-Collector")
fa.ipfixExporter = newIPFIXExporter(fa.k8sClient, opt, fa.registry)
fa.ipfixExporter.Start()
klog.InfoS("Enabled Flow-Collector")
} else {
fa.ipfixExporter.UpdateOptions(opt)
}
} else {
if fa.ipfixExporter != nil {
klog.InfoS("Disabling Flow-Collector")
fa.ipfixExporter.Stop()
fa.ipfixExporter = nil
klog.InfoS("Disabled Flow-Collector")
}
}

All other fields in opt.Config.FlowCollector are now handled correctly with this PR, which is why I used reflect.DeepEqual on the struct. I took a similar approach for the "LogExporter":
func (e *LogExporter) UpdateOptions(opt *options.Options) {
config := opt.Config.FlowLogger
if reflect.DeepEqual(e.config, config) {
return
}
klog.InfoS("Updating FlowLogger")
e.stop()
e.config = config
klog.InfoS("New FlowLogger configuration", "path", config.Path, "maxSize", config.MaxSize, "maxBackups", config.MaxBackups, "maxAge", config.MaxAge, "compress", *config.Compress, "prettyPrint", *config.PrettyPrint)
e.buildFilters()
e.start()
}

One could argue that this code is a bit clumsy. It may not have been a great idea to support live config updates for the Flow Aggregator in the first place...

According to the description "updates to recordContents.podLabels and recordFormat were ignored, without any kind of warning.", should it warn users that it's unsupported?

With this PR, these updates should now be supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for the explanation.

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@yuntanghsu yuntanghsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antoninbas
Copy link
Contributor Author

/test-all

@antoninbas antoninbas merged commit 2af4957 into antrea-io:main Jun 4, 2024
50 of 54 checks passed
@antoninbas antoninbas deleted the fa-fix-config-updates-for-ipfix-exporter branch June 4, 2024 04:11
@antoninbas antoninbas added the action/release-note Indicates a PR that should be included in release notes. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants