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

Added functionality for running the same trace request again with the same parameters. #2202

Merged
merged 3 commits into from Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/octant/cmd/antrea-octant-plugin/main.go
Expand Up @@ -73,7 +73,7 @@ func main() {
a := newAntreaOctantPlugin()

capabilities := &plugin.Capabilities{
ActionNames: []string{addTfAction, addLiveTfAction, showGraphAction},
ActionNames: []string{addTfAction, addLiveTfAction, showGraphAction, runTraceAgainAction},
IsModule: true,
}

Expand Down
40 changes: 36 additions & 4 deletions plugins/octant/cmd/antrea-octant-plugin/traceflow.go
Expand Up @@ -36,9 +36,10 @@ import (
)

var (
addTfAction = "traceflow/addTf"
addLiveTfAction = "traceflow/addLiveTf"
showGraphAction = "traceflow/showGraphAction"
addTfAction = "traceflow/addTf"
addLiveTfAction = "traceflow/addLiveTf"
showGraphAction = "traceflow/showGraphAction"
runTraceAgainAction = "traceflow/runTraceAgain"
)

const (
Expand Down Expand Up @@ -95,7 +96,7 @@ func getDstType(tf *crdv1alpha1.Traceflow) string {
return ""
}

// actionHandler handlers clicks and actions from "Start New Trace", "Start New Live-traffic Trace" and "Generate Trace Graph" buttons.
// actionHandler handlers clicks and actions from "Start New Trace", "Start New Live-traffic Trace", "Generate Trace Graph", and "Run Trace Again" buttons
func (p *antreaOctantPlugin) actionHandler(request *service.ActionRequest) error {
actionName, err := request.Payload.String("action")
if err != nil {
Expand Down Expand Up @@ -313,6 +314,26 @@ func (p *antreaOctantPlugin) actionHandler(request *service.ActionRequest) error
return nil
}
return nil
case runTraceAgainAction:
// Check if traceflow has been run before
if p.lastTf == nil {
alert := action.CreateAlert(action.AlertTypeError,
`Failed to run traceflow again: Use 'START NEW TRACE' or 'START NEW LIVE-TRAFFIC TRACE' to
run a traceflow before attempting to run a traceflow again.`,
action.DefaultAlertExpiration)
request.DashboardClient.SendAlert(request.Context(), request.ClientID, alert)
return nil
}
tf := &crdv1alpha1.Traceflow{}
tf.Spec = p.lastTf.Spec

// Get name of new traceflow
temporaryRune := []rune(p.lastTf.Name)
tf.Name = string(temporaryRune[0:len(p.lastTf.Name)-15])
tf.Name += time.Now().Format(TIME_FORMAT_YYYYMMDD_HHMMSS)

p.createTfCR(tf, request, context.Background(), tf.Name)
return nil
default:
log.Fatalf("Failed to find defined handler after receiving action request for %s\n", pluginName)
return nil
Expand Down Expand Up @@ -702,10 +723,21 @@ func (p *antreaOctantPlugin) traceflowHandler(request service.Request) (componen
Title: "Generate Trace Graph",
Form: graphForm,
}

// Run the previous traceflow again.
traceAgainForm := component.Form{Fields: []component.FormField{
component.NewFormFieldHidden("action", runTraceAgainAction),
}}
runTraceAgain := component.Action{
Name: "Run Trace Again",
Title: "Run Trace Again",
Form: traceAgainForm,
}
card.SetBody(component.NewText(""))
card.AddAction(addTf)
card.AddAction(addLiveTf)
card.AddAction(genGraph)
card.AddAction(runTraceAgain)

graphCard := component.NewCard(component.TitleFromString("Antrea Traceflow Graph"))
if p.lastTf.Name != "" {
Expand Down