vdjurovic
Intern
Intern
  • UID6046
  • Fans0
  • Follows0
  • Posts4
Reads:68621Replies:6

Errors in ApsaraDB API

Created#
More Posted time:Aug 3, 2018 22:11 PM
I'm having problems with some endpoints related to ApsaraDB API. I'm wondering if anyone can give me some guidance about this.
Basically, I'm seeing 3 issues, which may somehow be related:
1. When trying to list databases on SQL Server instanced, I'm getting the following error:



{"RequestId":"218EFAAF-663B-4E10-B7AC-68EA174CA024","HostId":"rds.eu-central-1.aliyuncs.com","Code":"InternalError","Message":"The request processing has failed due to some unknown error, exception or failure."}


with HTTP 500 status code. The request I'm sending is:

GET https://rds.aliyuncs.com/?AccessKeyId=xxxx&Action=DescribeDatabases&DBInstanceId=rm-4xo64l2167q82oub5&Format=JSON&SignatureMethod=HMAC-SHA1&SignatureNonce=19fc88d3-4d62-4e09-a7fe-e79794439e85&SignatureVersion=1.0&Timestamp=2018-08-03T13%3A46%3A36Z&Version=2014-08-15&Signature=ehRMgMhFxMxG4OolHH19aL%2BcQTY%3D

2. Running the same command for MySQL and PostgreSQL instances returns empty list, although few databases exist. User account has complete access to instances. Sending request:

GET https://rds.aliyuncs.com/?AccessKeyId=xxxxxx&Action=DescribeDatabases&DBInstanceId=rm-4xovfqg5773zd9i6y&Format=JSON&SignatureMethod=HMAC-SHA1&SignatureNonce=acbc21ba-cd31-4f2f-a6fc-5fd8cc86018f&SignatureVersion=1.0&Timestamp=2018-08-03T13%3A46%3A36Z&Version=2014-08-15&Signature=W3tNcn%2FDbGgCqMftv8KvUrJyL5k%3D


3. Same thing when trying to list backups, getting empty list. Also, user account has full access

GET https://rds.aliyuncs.com/?AccessKeyId=xxxx&Action=DescribeBackups&DBInstanceId=rm-4xovfqg5773zd9i6y&EndTime=2018-08-03T13%3A46Z&Format=JSON&SignatureMethod=HMAC-SHA1&SignatureNonce=d4e14823-bc35-4831-bbd5-6457895462ea&SignatureVersion=1.0&StartTime=2018-08-03T13%3A44Z&Timestamp=2018-08-03T13%3A46%3A40Z&Version=2014-08-15&Signature=P2WPHfJz1V0%2FxaqEaGHmFipIbKk%3D


Can somebody tell me what to look for? This look slike a biug in API to me, especially first issue. Or could it be some configuration problem?

JohnHanley
Engineer
Engineer
  • UID5606
  • Fans3
  • Follows1
  • Posts75
1st Reply#
Posted time:Aug 4, 2018 1:25 AM
A server 500 error means that there is something wrong with your request that the Alibaba backend could not process.


I have working code in Python that uses the REST API for RDS and many other Alibaba services. I have not seen an API bug yet with RDS.


Q) What language are your using?
Q) Are you including the Host and Date HTTP headers?
Q) Which version of SQL Server?



Several items that I noticed:


1) Your "HostId" does not look right. Double check that you are specifying the HTTP Host header as "Host: rds.aliyuncs.com".


2) "Format=JSON". Alibaba's REST API is case sensitive. This should be "Format=json". However, this does not cause a 500 error.


3) You are not specifiying the region. This is required. The documentation does not specify this (bug), but always include the region in your API calls. Example "RegionId=ap-southeast-1". However, this does not cause a 500 error.


Here is a valid string from my code. I changed the AccessKeyId, DBIstanceId and signature.


GET /?Format=json&AccessKeyId=LTAIabcdefg&SignatureMethod=HMAC-SHA1&SignatureType=&SignatureVersion=1.0&SignatureNonce=4f558fdc-3184-423a-9ade-03ce56b1b1e7&Timestamp=2018-08-03T17%3A10%3A22Z&Version=2014-08-15&RegionId=us-west-1&Action=DescribeDatabases&DBInstanceId=rm-abcdefg&Signature=abcdefg%3D

JohnHanley
Engineer
Engineer
  • UID5606
  • Fans3
  • Follows1
  • Posts75
2nd Reply#
Posted time:Aug 4, 2018 3:38 AM
Update: I was able to reproduce this error with the CreateDBInstance API. This is just coincidence as I am working on a project using RDS to process big data. This project creates an RDS instance, processes a bunch of data, generates a report and is then terminated.

What I found may help you.

The issue was that the documentation for CreateDBInstance is not entirely correct. In my case I was specifying the VSwitchID. This generated the 500 error just like yours. I played around and figured out that I had to specify the ZoneID. Once I did that the 500 error disappeared.

The ZoneID does not apply to your problem, this is just an example of an unexpected error caused by incorrect documentation. I plan to document this in detail for Alibaba so that either the documenation can be improved or the error message.

vdjurovic
Intern
Intern
  • UID6046
  • Fans0
  • Follows0
  • Posts4
3rd Reply#
Posted time:Aug 4, 2018 4:35 AM
Hi, John


thanks for the updates. Here are the answers to your original questions:


1) using Kotlin
2) I didn't include them originally. Tried after your suggestions, but getting the same thing
3) SQL Server 2012 EE BASIC


instance regions and zone is Germany 1 (Frankfurt), ZoneA. Using eu-central-1 as RegionId


After changes per your suggestions, my request now looks like this:



GET https://rds.aliyuncs.com/?AccessKeyId=xxxxxx&Action=DescribeDatabases&DBInstanceId=rm-4xozag7bw08k005n9&Format=json&RegionId=eu-central-1&SignatureMethod=HMAC-SHA1&SignatureNonce=c8f17b74-c44e-4db6-b18c-2c744895cab9&SignatureVersion=1.0&Timestamp=2018-08-03T20%3A12%3A50Z&Version=2014-08-15&Signature=jPpeOy7BsY6QvmJKOYOO0sGTzfQ%3D

Still getting the same error.

To me, this seems like a bug, either in documentation or server code. If request is missing a parameter or is malformed, server should return 400 error.

The way it is now, it seems like request validation passes, but then server call fails because it is expecting something that is not there.

vdjurovic
Intern
Intern
  • UID6046
  • Fans0
  • Follows0
  • Posts4
4Floor#
Posted time:Aug 6, 2018 19:25 PM
One more update. I tried this with official Alibaba Cloud Java SDK, and getting the sam error. This is the code I use:



       DefaultProfile profile = DefaultProfile.getProfile("eu-central-1", "xxxx", "yyyyy");
       IAcsClient client = new DefaultAcsClient(profile);
       DescribeDatabasesRequest dbreq = new DescribeDatabasesRequest();
       dbreq.setDBInstanceId("instance-id");
       
       try {
           DescribeDatabasesResponse dbresponse = client.getAcsResponse(dbreq);
           System.out.println("databases: " + dbresponse.getDatabases());
       } catch(Exception ex) {
           ex.printStackTrace();
       }


And gettting the following error:

com.aliyuncs.exceptions.ServerException: InternalError : The request processing has failed due to some unknown error, exception or failure.
RequestId : ED50F049-1F80-4D5D-B787-E4BCF0524659
at com.aliyuncs.DefaultAcsClient.parseAcsResponse(DefaultAcsClient.java:201)
at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:124)
at com.mycompany.alibaba.ecs.AlibabaEcs.main(AlibabaEcs.java:100)


Again, this error occurs only for SQL Server instance. For MySQL and PostgreSQL databases, I get a empty database list, although databases exist.

JohnHanley
Engineer
Engineer
  • UID5606
  • Fans3
  • Follows1
  • Posts75
5Floor#
Posted time:Aug 6, 2018 23:03 PM
I am not getting your error, but I am getting similar errors so I am leaning towards an Alibaba back-end bug.

I went to the office this weekend on this issue and spun up some test RDS instances and then started created test cases to nail down what is happening. I will continue on this later today. I am creating test cases in both Python and Java (with Scala). I will update this thread once I have figured out exactly what I think is wrong. I can then forward this to Alibaba to get their input.

Alibaba has been very fast to fix issues if provided with a test case that they can verify.

vdjurovic
Intern
Intern
  • UID6046
  • Fans0
  • Follows0
  • Posts4
6Floor#
Posted time:Aug 7, 2018 0:49 AM
Great. Thanks a lot for your help.
Guest