twonote / radosgw-admin4j

A Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨
https://twonote.github.io/radosgw-admin4j
Apache License 2.0
61 stars 33 forks source link

how to create User? #44

Closed Antirecord closed 2 years ago

Antirecord commented 2 years ago

Good afternoon, I'm trying to create a user through the client: RgwAdmin rgwAdmin = new RgwAdminBuilder() .accessKey(accessKey) .secretKey(secretKey) .endpoint(endpoint) .build(); rgwAdmin.createUser("testuser");

As a result, this method returns null, I looked inside this method:

public User createUser(String userId, Map<String, String> options) { HttpUrl.Builder urlBuilder = HttpUrl.parse(this.endpoint).newBuilder().addPathSegment("user").addQueryParameter("uid", userId).addQueryParameter("display-name", userId); appendParameters(options, urlBuilder); Request request = (new Request.Builder()).put(emptyBody).url(urlBuilder.build()).build(); String resp = this.safeCall(request); return (User)gson.fromJson(resp, User.class);

Inside this method, the response (resp) field returns an empty string, what could be the reason for this, please tell me?

hrchu commented 2 years ago

what's your Ceph version?

Antirecord commented 2 years ago

what's your Ceph version?

ceph version ceph version 16.2.5 (0883bdea7337b95e4b611c768c0279868462204a) pacific (stable)

Antirecord commented 2 years ago

help me please

hrchu commented 2 years ago

I cannot reproduce the issue in all active Ceph versions. Anyway, I believe the problem is due to the server returning nothing here, so the lib has no choice but returns a null to you.

I recommend you to check endpoint is correct or not. You can check it manually by curl, e.g., image

Antirecord commented 2 years ago

I cannot reproduce the issue in all active Ceph versions. Anyway, I believe the problem is due to the server returning nothing here, so the lib has no choice but returns a null to you.

I recommend you to check endpoint is correct or not. You can check it manually by curl, e.g.,

tcp dump of my request

PUT /user?uid=testuserzelimkhan&display-name=testuserzelimkhan HTTP/1.1 Authorization: AWS {hidden-access-key}:{hidden} Date: Tue, 16 Aug 2022 10:06:27 GMT Content-Length: 0 Host: [hidden]:8080 Connection: Keep-Alive Accept-Encoding: gzip User-Agent: okhttp/3.14.9

HTTP/1.1 200 OK x-amz-request-id: [hidden] Content-Length: 0 Date: Tue, 16 Aug 2022 10:06:28 GMT Connection: Keep-Alive

Antirecord commented 2 years ago

request admin/info :

{"Code":"MethodNotAllowed","RequestId":"tx0000000000000000000f9-0062fb9461-242df-default","HostId":"242df-default-default"}

Antirecord commented 2 years ago

Should the endpoint for creating buckets on the aws s3 java client match the endpoint on the rados gw java client?

hrchu commented 2 years ago

Nope. Default endpoints should be something like:

Try RgwAdminBuilder().endpoint("http://YOUR IP:PORT/admin")

Antirecord commented 2 years ago

Nope. Default endpoints should be something like:

Try RgwAdminBuilder().endpoint("http://YOUR IP:PORT/admin")

I didn't know that /admin should be added to the endpoint

Issue solved, thanks a lot.