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

Update Flow aggregate field httpVals #334

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

tushartathgur
Copy link
Contributor

if exporter sends httpval1 in first export and sends httpvals2 in second we should append both before sending further.
Also the function should take care of deduplicating same TxID items.

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #334 (e23c6b5) into main (d5ea241) will decrease coverage by 0.29%.
The diff coverage is 54.54%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #334      +/-   ##
==========================================
- Coverage   73.01%   72.73%   -0.29%     
==========================================
  Files          19       19              
  Lines        2831     2853      +22     
==========================================
+ Hits         2067     2075       +8     
- Misses        597      604       +7     
- Partials      167      174       +7     
Flag Coverage Δ
integration-tests 50.65% <0.00%> (-3.17%) ⬇️
unit-tests 71.74% <54.54%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
pkg/intermediate/aggregate.go 71.89% <54.54%> (-1.47%) ⬇️

Copy link
Contributor

@heanlan heanlan left a comment

Choose a reason for hiding this comment

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

Could you also update the aggregate_test.go file to include httpVals?

pkg/intermediate/aggregate.go Outdated Show resolved Hide resolved
pkg/intermediate/aggregate.go Outdated Show resolved Hide resolved
@@ -984,3 +993,29 @@ func isCorrelationRequired(flowType uint8, record entities.Record) bool {
}
return false
}

func fillHttpVals(incomingHttpVals, existingHttpVals string) (string, error) {
incomingHttpValsJson := make(map[int32]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgive me if it is a dumb question. Transaction iD should be the same for the same event in different nodes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes transaction ID should be same

Copy link
Member

@antoninbas antoninbas Nov 14, 2023

Choose a reason for hiding this comment

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

I think that's a key point, and the commit message should probably mention it.
Given that the HTTP values from both Nodes should eventually be consistent, I wonder if there is real value in that "complex" aggregation logic, or if we should just use the "latest" record (like we do for some other fields) and simply override the aggregated value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not able to reproduce it in my local setup, but the thought behind this design is if multiple exporters send the httpvals with different or overlapping TxIDs, we should deduplicate it.
if we only take the latest record for aggregation, we may not get all the TxIDs in a aggregated output given the aggregation interval is bigger than the exporter interval.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we won't be able to use the "latest" record in the current design.
The records from our Flow Exporter only contain partial httpVals as this field is reset after the connection is exported from the FE.
If we want to use the latest record in the FA, we might need to do the aggregation in the FE instead, which could end up increasing the packet size, transferred from FE to FA, by time?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @yuntanghsu, that makes sense.

pkg/intermediate/aggregate.go Outdated Show resolved Hide resolved
pkg/intermediate/aggregate.go Outdated Show resolved Hide resolved
Copy link
Member

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

This is fine by me. But I'll defer to @heanlan and @yuntanghsu for approval.

return "", fmt.Errorf("error parsing JSON: %v", err)
}
}
if len(existingHttpValsJson) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

the check is not useful: if the length is 0, the the loop will simply not execute

existingVal := existingIeWithValue.GetStringValue()
updatedHttpVals, err := fillHttpVals(incomingVal, existingVal)
if err != nil {
klog.Errorf("httpVals could not be updated from jsons, err: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
klog.Errorf("httpVals could not be updated from jsons, err: %v", err)
klog.Errorf("httpVals could not be updated: %v", err)

@@ -984,3 +995,29 @@ func isCorrelationRequired(flowType uint8, record entities.Record) bool {
}
return false
}

func fillHttpVals(incomingHttpVals, existingHttpVals string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a unit test for this function to make sure we correlate two HttpVals correctly?

existingHttpVals: "",
updatedHttpVals: "{\"1\":\"{hostname:10.10.0.1,url:/public/,http_user_agent:curl/7.74.0,http_content_type:text/html,http_method:GET,protocol:HTTP/1.1,status:200,length:153}\"}",
}, {
name: "overlapping httpVals empty",
Copy link
Member

Choose a reason for hiding this comment

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

nit: this is the only test case name that you didn't capitalize

also what does "empty" mean in this test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allow me to change the name , "empty" just got copied from the last test case, I will change it too

if exporter sends httpval1 in first export and sends httpvals2 in second
we should append both before sending further.
Also the function should take care of deduplicating same TxID items.

Signed-off-by: Tushar Tathgur <tathgurt@tathgurtPNQHP.vmware.com>
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

@heanlan heanlan merged commit 092fb4b into vmware:main Dec 6, 2023
7 of 9 checks passed
heanlan pushed a commit to heanlan/go-ipfix that referenced this pull request Dec 7, 2023
if exporter sends httpval1 in first export and sends httpvals2 in second
we should append both before sending further.
Also the function should take care of deduplicating same TxID items.

Signed-off-by: Tushar Tathgur <tathgurt@tathgurtPNQHP.vmware.com>
Co-authored-by: Tushar Tathgur <tathgurt@tathgurtPNQHP.vmware.com>
heanlan pushed a commit that referenced this pull request Dec 7, 2023
if exporter sends httpval1 in first export and sends httpvals2 in second
we should append both before sending further.
Also the function should take care of deduplicating same TxID items.

Signed-off-by: Tushar Tathgur <tathgurt@tathgurtPNQHP.vmware.com>
Co-authored-by: Tushar Tathgur <tathgurt@tathgurtPNQHP.vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants