[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-05-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16463649#comment-16463649
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-386556285
 
 
   I would leave it only for 4.12 due to its size. Only we seemed to have this 
issue so far.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
> Fix For: 4.12
>
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-05-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16463541#comment-16463541
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rhtyd commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs being 
created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-386533419
 
 
   @rafaelweingartner I scanned PRs merged on master but not 4.11 and came 
across this PR, since this is marked 'bug' do you think this would be useful 
for 4.11? If so, can you help create a backport PR for 4.11?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
> Fix For: 4.12
>
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-29 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16419576#comment-16419576
 ] 

ASF subversion and git services commented on CLOUDSTACK-10241:
--

Commit 060715e9f5f929804b7f515cfba0b4b130581876 in cloudstack's branch 
refs/heads/master from [~rafaelweingartner]
[ https://gitbox.apache.org/repos/asf?p=cloudstack.git;h=060715e ]

[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools (#2414)

* [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

Due to a race condition between multiple management servers, in some rare 
cases, CloudStack is creating multiple file SRs to the same secondary folder. 
This causes a problem when introducing the SR to the XenServer pools, as “there 
will be VDIs with duplicated UUIDs“. The VDIs are the same, but they are seen 
in different SRs, and therefore cause an error.

The solution to avoid race conditions between management servers is to use a 
deterministic srUuid for the file SR to be created (we are leaving XenServer 
with the burden of managing race conditions). The UUID is based on the SR file 
path and is generated using  UUID#nameUUIDFromBytes. Therefore, if there is an 
SR with the generated UUID, this means that some other management server has 
just created it. An exception will occur and it will contain a message saying 
'Db_exn.Uniqueness_constraint_violation'. In these unlikely events, we catch 
the exception and use the method retrieveAlreadyConfiguredSrWithoutException to 
get the SR that has already been created for the given mount point.


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16419574#comment-16419574
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner closed pull request #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
 
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index ee146a1f88c..2cecbea162c 100644
--- 
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ 
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -198,7 +198,7 @@ public String toString() {
 
 private final static int BASE_TO_CONVERT_BYTES_INTO_KILOBYTES = 1024;
 
-protected static final XenServerConnectionPool ConnPool = 
XenServerConnectionPool.getInstance();
+private static final XenServerConnectionPool ConnPool = 
XenServerConnectionPool.getInstance();
 // static min values for guests on xenserver
 private static final long mem_128m = 134217728L;
 
@@ -243,7 +243,7 @@ private static boolean isAlienVm(final VM vm, final 
Connection conn) throws XenA
 protected String _guestNetworkName;
 protected int _heartbeatInterval = 60;
 protected int _heartbeatTimeout = 120;
-protected final XsHost _host = new XsHost();
+protected XsHost _host = new XsHost();
 protected String _instance; // instance name (default is usually "VM")
 protected boolean _isOvs = false;
 protected String _linkLocalPrivateNetworkName;
diff --git 
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
index dea1752abd7..d809560ac22 100644
--- 
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
+++ 
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
@@ -18,6 +18,27 @@
  */
 package com.cloud.hypervisor.xenserver.resource;
 
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.cloudstack.storage.command.CopyCmdAnswer;
+import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.SnapshotObjectTO;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.xmlrpc.XmlRpcException;
+
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
@@ -37,26 +58,9 @@
 import com.xensource.xenapi.Task;
 import com.xensource.xenapi.Types;
 import com.xensource.xenapi.Types.BadServerResponse;
+import com.xensource.xenapi.Types.StorageOperations;
 import com.xensource.xenapi.Types.XenAPIException;
 import com.xensource.xenapi.VDI;
-import org.apache.cloudstack.storage.command.CopyCmdAnswer;
-import org.apache.cloudstack.storage.command.CopyCommand;
-import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-import org.apache.cloudstack.storage.to.SnapshotObjectTO;
-import org.apache.cloudstack.storage.to.TemplateObjectTO;
-import org.apache.cloudstack.storage.to.VolumeObjectTO;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.xmlrpc.XmlRpcException;
-
-import java.io.File;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
 
 public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
 private static final Logger s_logger = 
Logger.getLogger(XenServerStorageProcessor.class);
@@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String 

[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-29 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16419575#comment-16419575
 ] 

ASF subversion and git services commented on CLOUDSTACK-10241:
--

Commit 060715e9f5f929804b7f515cfba0b4b130581876 in cloudstack's branch 
refs/heads/master from [~rafaelweingartner]
[ https://gitbox.apache.org/repos/asf?p=cloudstack.git;h=060715e ]

[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools (#2414)

* [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

Due to a race condition between multiple management servers, in some rare 
cases, CloudStack is creating multiple file SRs to the same secondary folder. 
This causes a problem when introducing the SR to the XenServer pools, as “there 
will be VDIs with duplicated UUIDs“. The VDIs are the same, but they are seen 
in different SRs, and therefore cause an error.

The solution to avoid race conditions between management servers is to use a 
deterministic srUuid for the file SR to be created (we are leaving XenServer 
with the burden of managing race conditions). The UUID is based on the SR file 
path and is generated using  UUID#nameUUIDFromBytes. Therefore, if there is an 
SR with the generated UUID, this means that some other management server has 
just created it. An exception will occur and it will contain a message saying 
'Db_exn.Uniqueness_constraint_violation'. In these unlikely events, we catch 
the exception and use the method retrieveAlreadyConfiguredSrWithoutException to 
get the SR that has already been created for the given mount point.


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16417563#comment-16417563
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-376931360
 
 
   @rhtyd I will wait more 24 hours before merging this one to give you some 
extra time in cause you have objections. Tests results are green (tests 
executed by @DaanHoogland 14 days ago), and the reviews are positive.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16413227#comment-16413227
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-376010744
 
 
   @rhtyd do you want me to wait a little longer on this one?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409837#comment-16409837
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

blueorangutan commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-375372060
 
 
   @rhtyd a Trillian-Jenkins test job (centos7 mgmt + xenserver-65sp1) has been 
kicked to run smoke tests


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409834#comment-16409834
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rhtyd commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs being 
created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-375371878
 
 
   okay @rafaelweingartner, I'll review this soon.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409835#comment-16409835
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rhtyd commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs being 
created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-375371958
 
 
   @blueorangutan test centos7 xenserver-65sp1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409828#comment-16409828
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-375371248
 
 
   @rhtyd I would rather not. It is not a simple rebase to 4.11.
   I just tried and a lot of conflicts appeared, which would require some extra 
work to solve.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409801#comment-16409801
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rhtyd commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs being 
created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-375366161
 
 
   Thanks @rafaelweingartner since this is a bug fix, do you think it may be 
useful for 4.11 LTS?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409612#comment-16409612
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r176441369
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
+String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+return StringUtils.isNotBlank(result);
+}
 
-if (result == null || result.isEmpty()) {
-return false;
+/**
+ *  Creates the file SR for the given path. If there already exist a file 
SR for the path, we return the existing one.
+ *  This method uses a synchronized block to guarantee that only a single 
file SR is created per path.
+ *  If it is not possible to retrieve one file SR or to create one, a 
runtime exception will be thrown.
+ */
+protected SR createFileSR(Connection conn, String path) {
+String srPath = StringUtils.trim(path);
+synchronized (srPath) {
+SR sr = retrieveAlreadyConfiguredSrWithoutException(conn, srPath);
+if (sr == null) {
+sr = createNewFileSr(conn, srPath);
+}
+if (sr == null) {
+String hostUuid = this.hypervisorResource._host.getUuid();
+throw new CloudRuntimeException(String.format("Could not 
retrieve an already used file SR for path [%s] or create a new file SR on host 
[%s]", srPath, hostUuid));
+}
+return sr;
 }
-
-return true;
 }
 
-protected SR createFileSR(final Connection conn, final String path) {
+/**
+ * Creates a new file SR for the given path. If any of XenServer's checked 
exception occurs, we use method {@link #removeSrAndPbdIfPossible(Connection, 
SR, PBD)} to clean the created PBD and SR entries.
+ * To avoid race conditions between management servers, we are using a 
deterministic srUuid for the file SR to be created (we are leaving XenServer 
with the burden of managing race conditions). The UUID is based on the SR file 
path, and is generated using {@link UUID#nameUUIDFromBytes(byte[])}.
+ * If there is an SR with the generated UUID, this means that some other 
management server has just created it. An exception will occur and this 
exception will be an {@link InternalError}. The exception will contain {@link 
InternalError#message} a message saying 
'Db_exn.Uniqueness_constraint_violation'.
+ * For cases where the previous described error happens, we catch the 
exception and use the method {@link 
#retrieveAlreadyConfiguredSrWithoutException(Connection, String)}.
+ */
+protected SR createNewFileSr(Connection conn, String srPath) {
+String hostUuid = hypervisorResource.getHost().getUuid();
+s_logger.debug(String.format("Creating file SR for path [%s] on host 
[%s]", srPath, this.hypervisorResource._host.getUuid()));
 SR sr = null;
 PBD pbd = null;
-
 try {
-final String srname = path.trim();
-synchronized (srname.intern()) {
-final Set srs = SR.getByNameLabel(conn, 

[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409568#comment-16409568
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

GabrielBrascher commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r175882326
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
+String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+return StringUtils.isNotBlank(result);
+}
 
-if (result == null || result.isEmpty()) {
-return false;
+/**
+ *  Creates the file SR for the given path. If there already exist a file 
SR for the path, we return the existing one.
+ *  This method uses a synchronized block to guarantee that only a single 
file SR is created per path.
+ *  If it is not possible to retrieve one file SR or to create one, a 
runtime exception will be thrown.
+ */
+protected SR createFileSR(Connection conn, String path) {
+String srPath = StringUtils.trim(path);
+synchronized (srPath) {
+SR sr = retrieveAlreadyConfiguredSrWithoutException(conn, srPath);
+if (sr == null) {
+sr = createNewFileSr(conn, srPath);
+}
+if (sr == null) {
+String hostUuid = this.hypervisorResource._host.getUuid();
+throw new CloudRuntimeException(String.format("Could not 
retrieve an already used file SR for path [%s] or create a new file SR on host 
[%s]", srPath, hostUuid));
+}
+return sr;
 }
-
-return true;
 }
 
-protected SR createFileSR(final Connection conn, final String path) {
+/**
+ * Creates a new file SR for the given path. If any of XenServer's checked 
exception occurs, we use method {@link #removeSrAndPbdIfPossible(Connection, 
SR, PBD)} to clean the created PBD and SR entries.
+ * To avoid race conditions between management servers, we are using a 
deterministic srUuid for the file SR to be created (we are leaving XenServer 
with the burden of managing race conditions). The UUID is based on the SR file 
path, and is generated using {@link UUID#nameUUIDFromBytes(byte[])}.
+ * If there is an SR with the generated UUID, this means that some other 
management server has just created it. An exception will occur and this 
exception will be an {@link InternalError}. The exception will contain {@link 
InternalError#message} a message saying 
'Db_exn.Uniqueness_constraint_violation'.
+ * For cases where the previous described error happens, we catch the 
exception and use the method {@link 
#retrieveAlreadyConfiguredSrWithoutException(Connection, String)}.
+ */
+protected SR createNewFileSr(Connection conn, String srPath) {
+String hostUuid = hypervisorResource.getHost().getUuid();
+s_logger.debug(String.format("Creating file SR for path [%s] on host 
[%s]", srPath, this.hypervisorResource._host.getUuid()));
 SR sr = null;
 PBD pbd = null;
-
 try {
-final String srname = path.trim();
-synchronized (srname.intern()) {
-final Set srs = SR.getByNameLabel(conn, 

[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16398104#comment-16398104
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

blueorangutan commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372904377
 
 
   Trillian test result (tid-2355)
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 18301 seconds
   Marvin logs: 
https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr2414-t2355-kvm-centos7.zip
   Smoke tests completed. 67 look OK, 0 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397826#comment-16397826
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372852781
 
 
   @blueorangutan test


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397827#comment-16397827
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

blueorangutan commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372852794
 
 
   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has 
been kicked to run smoke tests


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397585#comment-16397585
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

blueorangutan commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372804066
 
 
   Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1774


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397519#comment-16397519
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174258152
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
 
 Review comment:
   :+1:


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397517#comment-16397517
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174258066
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
 
 Review comment:
   ok, short method with low cyclic complexity; makes sense


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397503#comment-16397503
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174255133
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
 
 Review comment:
   Because it is useless in this context.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397502#comment-16397502
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174254978
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
 
 Review comment:
   Of course, they are. However, here and in a lot of places in ACS, there is 
an indiscriminate use of the final keyword. It does not harm, but it is 
something I have to read when reviewing/coding, which does not aggregate/help. 
So, I remove when they are not needed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397495#comment-16397495
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372787156
 
 
   @blueorangutan package


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397496#comment-16397496
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

blueorangutan commented on issue #2414: [CLOUDSTACK-10241] Duplicated file SRs 
being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372787213
 
 
   @DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you 
posted as I make progress.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397494#comment-16397494
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174252867
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
 
 Review comment:
   final not allowed?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16397493#comment-16397493
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174253018
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
 
 Review comment:
   why removing the final?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-03-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16396896#comment-16396896
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-372653103
 
 
   @DaanHoogland I managed to separate the formatting from the code change 
itself. Now it should be easier to review.
   
   @khos2ow, @marcaurele and others, this might be of your interest as well (if 
you run XenServer). 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345495#comment-16345495
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on issue #2414: [CLOUDSTACK-10241] Duplicated file 
SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#issuecomment-361672678
 
 
   @DaanHoogland no problem! Thanks for the feedback so far. 
   Have you tried opening on Chrome? For me, it seems to work just fine.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345485#comment-16345485
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164820107
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessorTest.java
 ##
 @@ -0,0 +1,459 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.hypervisor.xenserver.resource;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.xmlrpc.XmlRpcException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InOrder;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
+import com.xensource.xenapi.PBD;
+import com.xensource.xenapi.PBD.Record;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types.InternalError;
+import com.xensource.xenapi.Types.XenAPIException;
+
+@RunWith(PowerMockRunner.class)
+public class Xenserver625StorageProcessorTest {
+
+@InjectMocks
+private Xenserver625StorageProcessor xenserver625StorageProcessor;
+
+@Mock
+private CitrixResourceBase citrixResourceBase;
+
+@Mock
+private Connection connectionMock;
+
+private String pathMock = "pathMock";
+
+@Before
+public void before() {
+xenserver625StorageProcessor = Mockito.spy(new 
Xenserver625StorageProcessor(citrixResourceBase));
+citrixResourceBase._host = Mockito.mock(XsHost.class);
+
Mockito.when(citrixResourceBase.getHost()).thenReturn(citrixResourceBase._host);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningEmpty() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, StringUtils.EMPTY);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningNull() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, null);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningSomething() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, "Soemthing");
 
 Review comment:
   Ah this one. It can actually be any string. instead of writing a fictitious 
directory, which though it would be misleading. Therefore, I decided to write 
anything... I will try to change this...


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition 

[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345482#comment-16345482
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164819588
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
 ##
 @@ -30,7 +31,7 @@
 
 @Before
 public void beforeTest() {
-super.citrixResourceBase = new Xenserver625Resource();
+super.citrixResourceBase = Mockito.spy(new Xenserver625Resource());
 
 Review comment:
   Oh, this one... It is because there is a hierarchy of test classes.. :(.. 
the property `citrixResourceBase` needs to be either a mock or spy object 
because of the testes executed in the super class. Therefore, needed to create 
a spy object whenever attributing an object to this property.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345474#comment-16345474
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner commented on a change in pull request #2414: 
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164818463
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
 ##
 @@ -17,7 +17,52 @@
 package com.cloud.hypervisor.xenserver.resource;
 
 Review comment:
   Sorry for that. It is a small change at lien 244. I removed a final keyword 
so I would be able to Spy an object to create unit test cases. I removed the 
formatting. It is my Eclipse, even though I configured it to format only edited 
lines, it keeps applying the standard on everything.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345205#comment-16345205
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164773896
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessorTest.java
 ##
 @@ -0,0 +1,459 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.hypervisor.xenserver.resource;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.xmlrpc.XmlRpcException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InOrder;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
+import com.xensource.xenapi.PBD;
+import com.xensource.xenapi.PBD.Record;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types.InternalError;
+import com.xensource.xenapi.Types.XenAPIException;
+
+@RunWith(PowerMockRunner.class)
+public class Xenserver625StorageProcessorTest {
+
+@InjectMocks
+private Xenserver625StorageProcessor xenserver625StorageProcessor;
+
+@Mock
+private CitrixResourceBase citrixResourceBase;
+
+@Mock
+private Connection connectionMock;
+
+private String pathMock = "pathMock";
+
+@Before
+public void before() {
+xenserver625StorageProcessor = Mockito.spy(new 
Xenserver625StorageProcessor(citrixResourceBase));
+citrixResourceBase._host = Mockito.mock(XsHost.class);
+
Mockito.when(citrixResourceBase.getHost()).thenReturn(citrixResourceBase._host);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningEmpty() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, StringUtils.EMPTY);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningNull() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, null);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningSomething() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, "Soemthing");
 
 Review comment:
   Soemthing on purpose or Something intended?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when 

[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345201#comment-16345201
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164773076
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
 ##
 @@ -30,7 +31,7 @@
 
 @Before
 public void beforeTest() {
-super.citrixResourceBase = new Xenserver625Resource();
+super.citrixResourceBase = Mockito.spy(new Xenserver625Resource());
 
 Review comment:
   i don't see this spy being used, why create it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16345196#comment-16345196
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164725447
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
 ##
 @@ -17,7 +17,52 @@
 package com.cloud.hypervisor.xenserver.resource;
 
 Review comment:
   did anything actually change in this class? the file has +761 −214 but i 
cannot find a 'real' change. if it is only formatting maybe put it in a 
separate commit.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CLOUDSTACK-10241) Duplicated file SRs being created in XenServer pools

2018-01-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16332671#comment-16332671
 ] 

ASF GitHub Bot commented on CLOUDSTACK-10241:
-

rafaelweingartner opened a new pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414
 
 
   Due to a race condition between multiple management servers, in some rare 
cases, CloudStack is creating multiple file SRs to the same secondary folder. 
This causes a problem when introducing the SR to the XenServer pools, as “there 
will be VDIs with duplicated UUIDs“. The VDIs are the same, but they are seen 
in different SRs, and therefore cause an error.
   
   The solution to avoid race conditions between management servers is to use a 
deterministic srUuid for the file SR to be created (we are leaving XenServer 
with the burden of managing race conditions). The UUID is based on the SR file 
path and is generated using  `UUID.nameUUIDFromBytes`. Therefore, if there is 
an SR with the generated UUID, this means that some other management server has 
just created it. An exception will occur and it will contain a message saying 
'Db_exn.Uniqueness_constraint_violation'. In these unlikely events, we catch 
the exception and use the method `retrieveAlreadyConfiguredSrWithoutException` 
to get the SR that has already been created for the given mount point.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Duplicated file SRs being created in XenServer pools
> 
>
> Key: CLOUDSTACK-10241
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10241
> Project: CloudStack
>  Issue Type: Bug
>  Security Level: Public(Anyone can view this level - this is the 
> default.) 
>Reporter: Rafael Weingärtner
>Assignee: Rafael Weingärtner
>Priority: Major
>
> Due to a race condition between multiple management servers, in some rare 
> cases, CloudStack is creating multiple file SRs to the same secondary folder. 
> This causes a problem when introducing the SR to the XenServer pools, as 
> “there will be VDIs with duplicated UUIDs“. The VDIs are the same, but they 
> are seen in different SRs, and therefore cause an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)