slok / sloth-common-sli-plugins

Sloth common SLI plugins collection
36 stars 13 forks source link

Unable to add new plugins #70

Open ishantanu opened 1 year ago

ishantanu commented 1 year ago

Hello,

I am trying add a new test plugin in the repository. This is just a test plugin because I wanted to check how adding new plugins work.

However, I keep getting the below error whenever I try to add a new plugin:

error: "validate" command failed: could not create file SLI plugin repository: could not load plugins: could not load "plugins\\x\\y\\plugin.go" plugin: invalid plugin source code, could not get package name

Where /x/y could be anything. I was following this guide - https://sloth.dev/usage/plugins/#developing-plugins.

Even if I add try to use the below code, as an example, it shows the same error:

package testplugin

import "context"

const (
  SLIPluginVersion = "prometheus/v1"
  SLIPluginID      = "test_plugin"
)

func SLIPlugin(ctx context.Context, meta, labels, options map[string]string) (string, error) {
  return "rate(my_raw_error_ratio_query{}[{{.window}}])", nil
}

I am not sure why this is happening as I am following the documented procedure.

Also, the validation of existing plugins work fine.

$ sloth validate -p ./plugins -i ./test/integration/ --debug
DEBU[0000] Debug level is enabled                        version=v0.10.0
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/traefik/v2/latency plugin-path="plugins\\traefik\\v2\\latency\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/coredns/latency plugin-path="plugins\\coredns\\latency\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d 
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/kubernetes/apiserver/latency plugin-path="plugins\\kubernetes\\apiserver\\latency\\plugin.go" svc=storage.FileSLIPlugin 
version=v0.10.0 window=30d
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/kubernetes/kooper/availability plugin-path="plugins\\kubernetes\\kooper\\availability\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/noop plugin-path="plugins\\noop\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/traefik/v2/availability plugin-path="plugins\\traefik\\v2\\availability\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d
DEBU[0000] SLI plugin loaded                             plugin-id=sloth-common/traefik/v1/latency plugin-path="plugins\\traefik\\v1\\latency\\plugin.go" svc=storage.FileSLIPlugin version=v0.10.0 window=30d
error: "validate" command failed: could not create file SLI plugin repository: could not load plugins: could not load "plugins\\x\\y\\plugin.go" plugin: invalid plugin source code, could not get package name

So, I guess, I must be doing something wrong.

Edit: This seems to be happening only on a windows environment. The same thing works fine on a linux systems.

slok commented 1 year ago

Hi @ishantanu!

Maybe its the same problem as we see on https://github.com/slok/sloth/issues/406

Could you confirm, please?

Thanks!

slok commented 1 year ago

Nevermind! I just checked that its you also :facepalm: I need some rest, sorry about that!

ishantanu commented 11 months ago

Hello, Just checking if there's any update on this. The issue is still the same on Windows environment.