Server Plugin on Documentation does not work?

27 views
Skip to first unread message

Alberto Garcia Taravillo

unread,
Apr 10, 2025, 11:10:15 AMApr 10
to KrakenD Community
Hi,

I'm following documentation to include a dummy handler plugin, it gets loaded but seems the handler does not execute never
This is the main.go file:
examples/plugins/handler at main · krakend/examples · GitHub

My config:
{
   "version": 3,
   "plugin": {
      "pattern": ".so",
      "folder": "/etc/krakend/plugins"
   },
   "host": ["http://localhost:8080/"],
   "debug_endpoint": true,
   "endpoints": [
      {
         "endpoint": "/example",
         "backend": [
            {
               "url_pattern": "/__debug/"
            }
         ]
      }
   ],
   "extra_config": {
      "plugin/http-server": {
         "name": ["my-handler-plugin"],
         "my-handler-plugin": {
            "someOption": "some-value"
         }
      }
   }
}


And the logs shows the plugin is correctly loaded but if you pay attention the log message when the options are being read does not appear

2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: Starting KrakenD v2.8.0
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: Working directory is /etc/krakend
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [SERVICE: Plugin Loader] Starting loading process
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [SERVICE: Executor Plugin] plugin #0 (/etc/krakend/plugins/krakend-server-example.so): plugin: symbol ClientRegisterer not found in plugin krakend-server-example
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [PLUGIN: my-handler-plugin] Example handler plugin loaded
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: [SERVICE: Handler Plugin] Total plugins loaded: 1
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [SERVICE: Modifier Plugin] plugin #0 (/etc/krakend/plugins/krakend-server-example.so): plugin: symbol ModifierRegisterer not found in plugin krakend-server-example
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [SERVICE: Plugin Loader] Loading process completed
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: Starting the KrakenD instance
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [ENDPOINT: /test/:id] Building the proxy pipe
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [BACKEND: /__health] Building the backend pipe
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [ENDPOINT: /test/:id] Building the http handler
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND DEBUG: [ENDPOINT: /test/:id][JWTSigner] Signer disabled
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: [ENDPOINT: /test/:id][JWTValidator] Validator disabled for this endpoint
2025-04-10 16:46:42 2025/04/10 14:46:42 KRAKEND INFO: [SERVICE: Gin] Listening on port: 8080
2025-04-10 16:46:47 2025/04/10 14:46:47 KRAKEND DEBUG: [SERVICE: Telemetry] Registering usage stats for Cluster ID PYlBFoSGeuCKjqWCCBiZwD9b3H3oJBhuMooDDlpQBD0=
2025-04-10 16:46:42 Parsing configuration file: /etc/krakend/krakend.json
2025-04-10 16:46:49 [GIN] 2025/04/10 - 14:46:49 | 404 |       4.617µs |      172.18.0.1 | GET      "/example  "


The file .so it's on the folder.

the dockerfile used

FROM krakend/builder:2.8.0 AS krakend-server-example

COPY ./plugins/krakend-server-example /app/krakend-server-example
WORKDIR /app/krakend-server-example
RUN go mod tidy
RUN go build -buildmode=plugin -o krakend-server-example.so .

FROM devopsfaith/krakend:2.8.0

COPY --from=krakend-server-example /app/krakend-server-example/krakend-server-example.so /etc/krakend/plugins/krakend-server-example.so

Any suggestion? is something missing in the docs?

Thanks

Daniel Ortiz

unread,
Apr 10, 2025, 11:19:05 AMApr 10
to KrakenD Community, alber...@gmail.com
Hi Alberto,

If you check the code, you will see the option is called "option". Will fix the generic example to avoid confusion.

Best regards.

Alberto Garcia Taravillo

unread,
Apr 10, 2025, 12:48:20 PMApr 10
to KrakenD Community, Daniel Ortiz, alber...@gmail.com
Hi,

Thanks for you reply :)

Sorry the doc is ok, no need to update anything. I just copy/paste the extra config from the comment that seems to be deprecated, my bad. 
In any case....
Copy/paste all the files from the example: handler.go, krakend.json and then build with the dockerfile shown and the handler does not reach. The *.so file is placed into the folder. 
If there's an error in the options I assume the message fmt.Errorf("%s plugin disabled: config not found", pluginName) would appear but does not . 
I've added even a debug message at the start of the handler:

func (r registerer) registerHandlers(_ context.Context, extra map[string]interface{}, h http.Handler) (http.Handler, error) {
    logger.Debug("Handler executing...")
   

It's like handler does not execute.
Any reason for this behaviour? Something that helps to identify the root cause? 

2025-04-10 18:11:05 Parsing configuration file: /etc/krakend/krakend.json
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: Starting KrakenD v2.8.0
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: Working directory is /etc/krakend
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [SERVICE: Plugin Loader] Starting loading process
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [SERVICE: Executor Plugin] plugin #0 (/etc/krakend/plugins/krakend-server-example.so): plugin: symbol ClientRegisterer not found in plugin krakend-server-example
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [PLUGIN: my-handler-plugin] Example handler plugin loaded
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: [SERVICE: Handler Plugin] Total plugins loaded: 1
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [SERVICE: Modifier Plugin] plugin #0 (/etc/krakend/plugins/krakend-server-example.so): plugin: symbol ModifierRegisterer not found in plugin krakend-server-example
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [SERVICE: Plugin Loader] Loading process completed
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [SERVICE: Gin] Debug enabled
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: Starting the KrakenD instance
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [ENDPOINT: /example] Building the proxy pipe
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [BACKEND: /__debug/] Building the backend pipe
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [ENDPOINT: /example] Building the http handler
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND DEBUG: [ENDPOINT: /example][JWTSigner] Signer disabled
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: [ENDPOINT: /example][JWTValidator] Validator disabled for this endpoint
2025-04-10 18:11:05 2025/04/10 16:11:05 KRAKEND INFO: [SERVICE: Gin] Listening on port: 8080
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] Method: GET
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] URL: /__debug/
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] Query: map[]
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] Params: [{param /}]
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] Headers: map[Accept-Encoding:[gzip] Content-Type:[application/json] User-Agent:[KrakenD Version 2.8.0] X-Forwarded-For:[172.18.0.1] X-Forwarded-Host:[localhost:8080]]
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [ENDPOINT: /__debug/*] Body:
2025-04-10 18:11:10 [GIN] 2025/04/10 - 16:11:10 | 200 |     136.766µs |      172.18.0.1 | GET      "/__debug/"
2025-04-10 18:11:10 [GIN] 2025/04/10 - 16:11:10 | 200 |    1.415593ms |      172.18.0.1 | GET      "/example"
2025-04-10 18:11:10 2025/04/10 16:11:10 KRAKEND DEBUG: [SERVICE: Telemetry] Registering usage stats for Cluster ID Zjh/2gxYqjR+LNfnK40zwytAmZMxcbteUqhUuaOcR1E=

David Hontecillas

unread,
Apr 10, 2025, 4:22:20 PMApr 10
to KrakenD Community, alber...@gmail.com, Daniel Ortiz
Also, the name of the plugin is "krakend-server-example", and in your config you are using "my-handler-plugin" . 

Try to change the config to match the name of the plugin.

Alberto Garcia Taravillo

unread,
Apr 15, 2025, 11:36:20 AMApr 15
to KrakenD Community, David Hontecillas, alber...@gmail.com, Daniel Ortiz
My bad.
There was a lot of bad copy/paste
Reply all
Reply to author
Forward
0 new messages