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

Change antctl traceflow command to output results at timeout/failure #1879

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

jianjuns
Copy link
Contributor

@jianjuns jianjuns commented Feb 17, 2021

Output the Traceflow results, as long as there are any results returned,
so users can know the progress of the Traceflow session even the antctl
command is timeout, or the Traceflow operation fails.

Example output:

$antctl traceflow -S kube-system/coredns-74ff55c5b-6sz9g -D 1.2.3.4
name: kube-system-coredns-74ff55c5b-6sz9g-to-172.100.0.33-2rx5fdlg
phase: Running
source: kube-system/coredns-74ff55c5b-6sz9g
destination: 1.2.3.4
results:
- node: k8s1
  timestamp: 1613590444
  observations:
  - component: SpoofGuard
    action: Forwarded
  - component: Forwarding
    componentInfo: Output
    action: Forwarded

Error: timeout waiting for Traceflow done

// Still output the Traceflow results if any.
if res == nil || len(res.Status.Results) == 0 {
return errors.New("timeout waiting for Traceflow results")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we still return a timeout error eventually after outputting the (partial?) result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do that too. In your mind should antctl exit with an error in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I believe so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Updated the code.

Copy link
Contributor Author

@jianjuns jianjuns Feb 23, 2021

Choose a reason for hiding this comment

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

if err := output(res); err != nil { should not override err?
It is a new err variable defined in the if block.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, sorry, you're right... Become careless after holiday :(

antoninbas
antoninbas previously approved these changes Feb 20, 2021
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.

LGTM

}); err != nil {
})
if err == wait.ErrWaitTimeout {
err = errors.New("timeout waiting for Traceflow done")
Copy link
Contributor

@lzhecheng lzhecheng Feb 23, 2021

Choose a reason for hiding this comment

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

Please correct me if my understanding is wrong.
It seems error "timeout waiting for Traceflow done" is only for L156 to return. On L162, its value is overwritten by output(). Does it really output "timeout waiting for Traceflow done" after outputting partial traceflow result?
I think we can update code like below:

        var timeoutErr error
	if err == wait.ErrWaitTimeout {
		timeoutErr = errors.New("timeout waiting for Traceflow done")
		// Still output the Traceflow results if any.
		if res == nil {
			return timeoutErr
		}
	} else if err != nil {
		return fmt.Errorf("error when retrieving Traceflow: %w", err)
	}

	if err := output(res); err != nil {
		return fmt.Errorf("error when outputing result: %w", err)
	}

	return timeoutErr

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a mistake. Plesae ignore.

return fmt.Errorf("error when retrieving Traceflow: %w", err)
}

return nil
if err := output(res); err != nil {
return fmt.Errorf("error when outputing result: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("error when outputing result: %w", err)
return fmt.Errorf("error when outputting result: %w", err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed.

Output the Traceflow results, as long as there are any results returned,
so users can know the progress of the Traceflow session even the antctl
command is timeout, or the Traceflow operation fails.
Copy link
Contributor

@lzhecheng lzhecheng left a comment

Choose a reason for hiding this comment

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

LGTM

@jianjuns
Copy link
Contributor Author

/test-all

@codecov-io
Copy link

codecov-io commented Feb 23, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@f93242a). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1879   +/-   ##
=======================================
  Coverage        ?   45.27%           
=======================================
  Files           ?      199           
  Lines           ?    17227           
  Branches        ?        0           
=======================================
  Hits            ?     7799           
  Misses          ?     8390           
  Partials        ?     1038           
Flag Coverage Δ
e2e-tests 43.50% <0.00%> (?)
kind-e2e-tests 42.02% <0.00%> (?)

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

@jianjuns jianjuns merged commit c07c21e into antrea-io:main Feb 23, 2021
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.

5 participants