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

Support timestamp filter in antctl supportbundle command #2389

Merged
merged 1 commit into from Aug 24, 2021

Conversation

hangyan
Copy link
Member

@hangyan hangyan commented Jul 13, 2021

This PR is based on #1560, besides conflict fixes, the additional
changes are:

  1. fix a command args help string error
  2. revert the interface changes and use struct fields
  3. create a func to do timefilter cal

Co-authored-by: Weiqiang Tang weiqiangt@vmware.com
Signed-off-by: Hang Yan yhang@vmware.com

@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2021

Codecov Report

Merging #2389 (0ced809) into main (9e112d4) will increase coverage by 4.74%.
The diff coverage is 57.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2389      +/-   ##
==========================================
+ Coverage   60.57%   65.31%   +4.74%     
==========================================
  Files         286      286              
  Lines       23053    26506    +3453     
==========================================
+ Hits        13964    17312    +3348     
+ Misses       7624     7598      -26     
- Partials     1465     1596     +131     
Flag Coverage Δ
e2e-tests 56.26% <45.90%> (?)
kind-e2e-tests 47.52% <40.38%> (-0.11%) ⬇️
unit-tests 41.40% <23.07%> (-0.32%) ⬇️

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

Impacted Files Coverage Δ
pkg/log/log_file.go 72.41% <50.00%> (+1.36%) ⬆️
pkg/support/dump.go 62.50% <50.00%> (-2.62%) ⬇️
pkg/support/dump_others.go 58.82% <66.66%> (+8.82%) ⬆️
...kg/apiserver/registry/system/supportbundle/rest.go 75.75% <100.00%> (+1.19%) ⬆️
pkg/controller/egress/ipallocator/allocator.go 65.00% <0.00%> (-15.42%) ⬇️
pkg/controller/networkpolicy/endpoint_querier.go 77.64% <0.00%> (-13.79%) ⬇️
pkg/apis/controlplane/v1beta1/conversion.go 72.51% <0.00%> (-12.19%) ⬇️
pkg/legacyapis/core/v1alpha2/register.go 69.23% <0.00%> (-10.77%) ⬇️
pkg/apis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
pkg/legacyapis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
... and 274 more

@hangyan
Copy link
Member Author

hangyan commented Jul 13, 2021

@mengdie-song @tnqn

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, a minor comment

pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
mengdie-song
mengdie-song previously approved these changes Jul 19, 2021
Copy link
Contributor

@mengdie-song mengdie-song 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

@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.

Sorry for the late review.
Have you given any thought to using an arbitrary time stamp instead?

BTW, some commits are not signed.

pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
Copy link
Contributor

@abhiraut abhiraut left a comment

Choose a reason for hiding this comment

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

Sorry for the late review.
Have you given any thought to using an arbitrary time stamp instead?

BTW, some commits are not signed.

I have seen usages of timestamp in log filters and can perhaps perform more advanced queries like last 5 hours or between certain timestamps.

pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
@hangyan hangyan force-pushed the antctl-supportbundle-date-filter-new branch 2 times, most recently from 99380f2 to 4ee6f22 Compare July 21, 2021 01:37
@hangyan
Copy link
Member Author

hangyan commented Jul 21, 2021

Sorry for the late review.
Have you given any thought to using an arbitrary time stamp instead?
BTW, some commits are not signed.

I have seen usages of timestamp in log filters and can perhaps perform more advanced queries like last 5 hours or between certain timestamps.

Use timestamp certainly is better, only require some extra work(reading logs file and extract the required parts).

Copy link
Contributor

@abhiraut abhiraut left a comment

Choose a reason for hiding this comment

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

1 comment otherwise lgtm, but perhaps others may want to chime in on whether to support timestamps or days is fine as a filter

pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
@hangyan hangyan force-pushed the antctl-supportbundle-date-filter-new branch 2 times, most recently from 60a358e to 74b4ab6 Compare August 18, 2021 01:06
@hangyan hangyan changed the title Support days filter in antctl supportbundle command Support timestamp filter in antctl supportbundle command Aug 18, 2021
Copy link
Contributor

@mengdie-song mengdie-song left a comment

Choose a reason for hiding this comment

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

Thanks for the change!

pkg/support/dump.go Outdated Show resolved Hide resolved
pkg/support/dump.go Show resolved Hide resolved
pkg/support/dump.go Outdated Show resolved Hide resolved
pkg/antctl/raw/supportbundle/command.go Outdated Show resolved Hide resolved
pkg/support/dump.go Outdated Show resolved Hide resolved
pkg/support/dump.go Outdated Show resolved Hide resolved
pkg/support/dump.go Outdated Show resolved Hide resolved
@@ -184,6 +256,8 @@ type agentDumper struct {
ovsCtlClient ovsctl.OVSCtlClient
aq agentquerier.AgentQuerier
npq querier.AgentNetworkPolicyInfoQuerier
// days is for log filter
Copy link
Member

Choose a reason for hiding this comment

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

wrong comment

return err
}
return fileCopy(d.fs, path.Join(basedir, "logs", "ovs"), logDir, "ovs")
return directoryCopy(d.fs, path.Join(basedir, "logs", "ovs"), logDir, "ovs", timeFilter)
Copy link
Member

Choose a reason for hiding this comment

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

I just thought of ovs log has different time format:

2020-11-24T10:00:56.837Z|00036|memory|INFO|415440 kB peak resident set size after 10.0 seconds
2020-11-24T10:00:56.837Z|00037|memory|INFO|handlers:35 ofconns:1 ports:2 revalidators:13 rules:37 udpif keys:1
2020-11-24T10:01:00.680Z|00038|connmgr|INFO|br-int<->unix#0: 34 flow_mods 10 s ago (33 adds, 1 deletes)

So the timeFilter won't work

Copy link
Member Author

@hangyan hangyan Aug 19, 2021

Choose a reason for hiding this comment

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

I have checked the code again. This was by design, alougth i'm not sure it's a good choice. The timefilter is based on the timestamp records in the log filename, which was generated by klog. If no timestamp found in the filename, the whole log file is returned, and it applied to the ovs logs. I assumed it's much smaller than the agent/controller log and does not need to do timestamp filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

A bad assumption i guess.

@@ -0,0 +1,21 @@
package support
Copy link
Member

Choose a reason for hiding this comment

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

Add license header

return err
}
// Dump kubelet logs.
if err := fileCopy(d.fs, path.Join(basedir, "logs", "kubelet"), antreaWindowsKubeletLogDir, "kubelet"); err != nil {
if err := directoryCopy(d.fs, path.Join(basedir, "logs", "kubelet"), antreaWindowsKubeletLogDir, "kubelet", timeFilter); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Does kubelet have same time format?

Copy link
Member Author

Choose a reason for hiding this comment

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

kubelet has the same format.

@hangyan
Copy link
Member Author

hangyan commented Aug 20, 2021

@tnqn All updated, please take a look if you got time.

tnqn
tnqn previously approved these changes Aug 20, 2021
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, thanks

@hangyan
Copy link
Member Author

hangyan commented Aug 21, 2021

Thanks for the review

@tnqn
Copy link
Member

tnqn commented Aug 23, 2021

/test-all
Will wait for @mengdie-song's confirmation on her comment.

mengdie-song
mengdie-song previously approved these changes Aug 24, 2021
Copy link
Contributor

@mengdie-song mengdie-song left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/support/dump.go Show resolved Hide resolved
This PR is based on antrea-io#1560, besides conflict fixes, the additional
changes are:
1. change days filter to timestamp filter
2. revert the interface changes and use struct fields

Co-authored-by: Weiqiang Tang <weiqiangt@vmware.com>
Signed-off-by: Hang Yan <yhang@vmware.com>
@hangyan hangyan dismissed stale reviews from mengdie-song and tnqn via 0ced809 August 24, 2021 02:54
@hangyan hangyan force-pushed the antctl-supportbundle-date-filter-new branch from 5972d51 to 0ced809 Compare August 24, 2021 02:54
@hangyan
Copy link
Member Author

hangyan commented Aug 24, 2021

merge conflict are fixed

@tnqn
Copy link
Member

tnqn commented Aug 24, 2021

/test-all

@tnqn tnqn merged commit 1d148ad into antrea-io:main Aug 24, 2021
antoninbas pushed a commit that referenced this pull request Oct 20, 2022
This PR is based on #1560, besides conflict fixes, the additional
changes are:
1. change days filter to timestamp filter
2. revert the interface changes and use struct fields

Co-authored-by: Weiqiang Tang <weiqiangt@vmware.com>
Signed-off-by: Hang Yan <yhang@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants