-
Notifications
You must be signed in to change notification settings - Fork 386
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
[FlowAggregator] Fix live config updates for IPFIXExporter #6385
Conversation
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 { |
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.
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?
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 there is an update to enable
, this code will never be executed:
antrea/pkg/flowaggregator/flowaggregator.go
Lines 618 to 634 in 264372d
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": antrea/pkg/flowaggregator/exporter/log.go
Lines 150 to 161 in 264372d
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.
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 it, thanks for the explanation.
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.
LGTM
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.
LGTM
/test-all |
In particular, updates to recordContents.podLabels and recordFormat were ignored, without any kind of warning.