Hello,

I’m investigating an issue on CS 4.8.0 when registering an ISO with a
long URL (>255 chars). The only issue related to it that I could find
is https://issues.apache.org/jira/browse/CLOUDSTACK-9238.

Basically, the problem could be reproduced by entering an URL with
more that 255 chars in the ISO URL. The API fails with a parameter
error.

Since the database schema seems fine according to CLOUDSTACK-9238 - my
current database matches that at least - I tried to change the
Parameter annotation to length 2048 (see first patch below); Then the
API request is accepted, but the URL appears truncated in the SSVM
logs:

URL was: 
https://github-cloud.s3.amazonaws.com/releases/28796010/774188bc-18fc-11e6-8140-4cf8a5632e15.iso?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20160525%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20160525T125103Z&X-Amz-Expires=300&X-Amz-Signature=d40de63959eed194d0bbb7c702cf71d65a7aa91f427e33714fde64b76aebf6d8&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Drancheros.iso&response-content-type=application%2Foctet-stream

SSVM gets a 255-char truncated URL (the management server logs shows
that it sends only 255 chars also).

2016-05-25 12:51:16,961 DEBUG [cloud.agent.Agent]
(agentRequest-Handler-1:null) Request:Seq 57-4400016835940974604:  {
Cmd , MgmtId: 345049980494, via: 57, Ver: v1, Flags: 100011,
[{"org.apache.cloudstack.storage.command.DownloadCommand":{"hvm":true,"description":"ros","maxDownloadSizeInBytes":53687091200,"id":353,"resourceType":"TEMPLATE","installPath":"template/tmpl/2/353","_store":{"com.cloud.agent.api.to.NfsTO":{"_url":"nfs://10.87.80.250/cloudstack_secondary_z1","_role":"Image"}},"url":"https://github-cloud.s3.amazonaws.com/releases/28796010/774188bc-18fc-11e6-8140-4cf8a5632e15.iso?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20160525%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20160525T125103Z&X-Amz-Expires=30","format":"ISO","accountId":2,"name":"353-2-34ec5c80-b6ff-3d3d-8c09-7ac1f3755d3d","secUrl":"nfs://10.87.80.250/cloudstack_secondary_z1","wait":0}}]
}


I also tried setting the length of the fields in the *VO objects (see
second patch below), but I’m not exactly sure of what i’m doing there.

Does anyone have a hint at where to look to find where the string is
truncated and why ?


— Patch for API

diff -ru 
a/apache-cloudstack-4.8.0-src/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
b/apache-cloudstack-4.8.0-src/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
--- 
a/apache-cloudstack-4.8.0-src/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
2016-01-20 23:43:35.000000000 +0100
+++ 
b/apache-cloudstack-4.8.0-src/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
2016-05-25 09:40:25.000000000 +0200
@@ -78,7 +78,11 @@
                description = "the ID of the OS type that best
represents the OS of this ISO. If the ISO is bootable this parameter
needs to be passed")
     private Long osTypeId;

-    @Parameter(name = ApiConstants.URL, type = CommandType.STRING,
required = true, description = "the URL to where the ISO is currently
being hosted")
+    @Parameter(name = ApiConstants.URL,
+               type = CommandType.STRING,
+               required = true,
+               description = "the URL to where the ISO is currently
being hosted",
+               length = 2048)
     private String url;

     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID,
entityType = ZoneResponse.class,


— Patch for columns

diff -ru 
a/apache-cloudstack-4.8.0-src/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
b/apache-cloudstack-4.8.0-src/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
--- 
a/apache-cloudstack-4.8.0-src/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
2016-01-20 23:43:35.000000000 +0100
+++ 
b/apache-cloudstack-4.8.0-src/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
2016-05-25 14:12:18.000000000 +0200
@@ -95,7 +95,7 @@
     @Column(name = "install_path")
     private String installPath;

-    @Column(name = "url")
+    @Column(name = "url", length = 2048)
     private String downloadUrl;

     @Column(name = "download_url")

Thanks,
Best regards,
-- 
Aurélien Guillaume

Reply via email to