vmware-archive / octant

Highly extensible platform for developers to better understand the complexity of Kubernetes clusters.
https://octant.dev
Apache License 2.0
6.27k stars 489 forks source link

ClientID field is missing when handling an action in plugins #1427

Closed ZhangYW18 closed 4 years ago

ZhangYW18 commented 4 years ago

What steps did you take and what happened: I was trying to send an alert when handling an action request in plugins:

func actionHandler(request *service.ActionRequest) error {
    ......
    alert := action.CreateAlert(action.AlertTypeError, fmt.Sprintf("alert message"), action.DefaultAlertExpiration)
    request.DashboardClient.SendAlert(request.Context(), request.ClientID, alert)
    ......
}

And I found out that the alerter did not work. I added some logs and found out that the ClientID field in ActionRequest is an empty string. Sending alerts need a ClientID from requests.

What did you expect to happen: The alerter should work when sending alerts via action in plugins.

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

Environment:

GuessWhoSamFoo commented 4 years ago

One potential cause for this is not having any instances of Octant open when the action is triggered (https://github.com/vmware-tanzu/octant/pull/1216/files#diff-0d285ad793518e8fc352a379555e166aR387).

The sample plugin uses PrintRequest which currently is working, but I can try to look into ActionRequest tomorrow. A gist or link to a repo can also help debug

ZhangYW18 commented 4 years ago

@GuessWhoSamFoo You can reproduce this bug via the following modified version of Octant sample plugin: https://github.com/ZhangYW18/octant/blob/master/cmd/octant-sample-plugin/main.go

wwitzel3 commented 4 years ago

I confirmed this in both the JS and Go plugin runtimes. The clientID is missing from ActionRequest.