Using pulsar-admin golang pkg, but can not create tenant
ThinhLe30 opened this issue · 4 comments
I'm using the pkg: https://pkg.go.dev/github.com/apache/pulsar-client-go@v0.12.0/pulsaradmin to create tenant, namespace, topic for my pulsar cluster
Here is my docker-compose.yml file:
version: "3.1"
services:
standalone:
image: apachepulsar/pulsar:2.6.0
ports:
- 8080:8080
- 6650:6650
environment:
PULSAR_MEM: " -Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g"
command: bin/pulsar standalone
here is my pulsar-admin code:
cfg := &pulsaradmin.Config{
WebServiceURL: "http://localhost:8080",
BKWebServiceURL: "pulsar://localhost:6650",
}
pulsarAdmin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}
err = pulsarAdmin.Namespaces().CreateNamespace("seenow/image")
if err != nil {
panic(err)
}
and it's returned the error: panic: code: 500 reason: 500 Request failed.
and im checked the log in container: It's a NullPointerException
2024-02-22 09:19:40 02:19:40.490 [pulsar-web-69-14] WARN org.eclipse.jetty.server.HttpChannel - /admin/v2/tenants/seenow
2024-02-22 09:19:40 javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NullPointerException
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [org.eclipse.jetty-jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [org.eclipse.jetty-jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [org.eclipse.jetty-jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [org.eclipse.jetty-jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [org.eclipse.jetty-jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [org.eclipse.jetty-jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [org.eclipse.jetty-jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [org.eclipse.jetty-jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
2024-02-22 09:19:40 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
2024-02-22 09:19:40 at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
2024-02-22 09:19:40 at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
2024-02-22 09:19:40 Caused by: javax.servlet.ServletException: java.lang.NullPointerException
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:432) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.apache.pulsar.broker.web.ResponseHandlerFilter.doFilter(ResponseHandlerFilter.java:53) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.apache.pulsar.broker.intercept.BrokerInterceptor$BrokerInterceptorDisabled.onWebServiceRequest(BrokerInterceptor.java:73) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.apache.pulsar.broker.web.EventListenerFilter.doFilter(EventListenerFilter.java:46) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 ... 17 more
2024-02-22 09:19:40 Caused by: java.lang.NullPointerException
2024-02-22 09:19:40 at org.apache.pulsar.broker.admin.impl.TenantsBase.validateClusters(TenantsBase.java:230) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.apache.pulsar.broker.admin.impl.TenantsBase.createTenant(TenantsBase.java:104) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
2024-02-22 09:19:40 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
2024-02-22 09:19:40 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
2024-02-22 09:19:40 at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:183) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.internal.Errors.process(Errors.java:316) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.internal.Errors.process(Errors.java:298) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.internal.Errors.process(Errors.java:268) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289) ~[org.glassfish.jersey.core-jersey-common-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703) ~[org.glassfish.jersey.core-jersey-server-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229) ~[org.glassfish.jersey.containers-jersey-container-servlet-core-2.27.jar:?]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.apache.pulsar.broker.web.ResponseHandlerFilter.doFilter(ResponseHandlerFilter.java:53) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.apache.pulsar.broker.intercept.BrokerInterceptor$BrokerInterceptorDisabled.onWebServiceRequest(BrokerInterceptor.java:73) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.apache.pulsar.broker.web.EventListenerFilter.doFilter(EventListenerFilter.java:46) ~[org.apache.pulsar-pulsar-broker-2.6.0.jar:2.6.0]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[org.eclipse.jetty-jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) ~[org.eclipse.jetty-jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
2024-02-22 09:19:40 ... 17 more
It's weird because I'm still create namespace and topic but tenant
Can anyone help. Thanks a lot.
***Note
and the API in my docker file and in Official Document seem diffferent:
and the link: Doc
and in my log:
2024-02-22 09:19:40 02:19:40.504 [pulsar-web-69-14] INFO org.eclipse.jetty.server.RequestLog - 192.168.65.1 - - [22/Feb/2024:02:19:40 +0000] "PUT /admin/v2/tenants/seenow HTTP/1.1" 500 0 "-" "None" 84
missing /createTenant
Pulsar 2.6.0 is out of support. Could you upgrade your pulsar to the latest version like 3.0.2 or 3.2.0.
And for your code, you need to create your tenant first:
err = pulsarAdmin.Tenants().Create(utils.TenantData{Name: "seenow", AllowedClusters: []string{"standalone"}})
if err != nil {
assert.Nil(t, err)
}
Regarding the doc, it should be an issue. I have reported it to the main repo here: apache/pulsar#22094
Thanks a lot @RobertIndie, it's work. Im gonna close is issue. Wish u have a good day
UPDATE TO NEWEST PULSAR VERSION