Uh oh!
There was an error while loading. Please reload this page.
[CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools - #2414
Conversation
048a9cf to
0ffdb9aCompare
DaanHoogland
left a comment
There was a problem hiding this comment.
sorry @rafaelweingartner , i've been trying to review this in between other things but the diff Xenserver625StorageProcessor.java won't load :( i'll restart when i have that fixed . (firefox on mac problem?)
| @@ -17,7 +17,52 @@ | |||
| package com.cloud.hypervisor.xenserver.resource; | |||
There was a problem hiding this 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.
There was a problem hiding this 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.
| @Before | ||
| public void beforeTest() { | ||
| super.citrixResourceBase = new Xenserver625Resource(); | ||
| super.citrixResourceBase = Mockito.spy(new Xenserver625Resource()); |
There was a problem hiding this comment.
i don't see this spy being used, why create it?
There was a problem hiding this 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.
| @Test | ||
| public void makeDirectoryTestCallHostPlugingReturningSomething() { | ||
| boolean makeDirectoryReturn = configureAndExecuteMakeDirectoryMethodForTest(pathMock, "Soemthing"); |
There was a problem hiding this comment.
Soemthing on purpose or Something intended?
There was a problem hiding this 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...
dea3667 to
891a5c0Comparerafaelweingartner
commented
Jan 30, 2018
@DaanHoogland no problem! Thanks for the feedback so far. |
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.
891a5c0 to
1618cb6Comparerafaelweingartner
commented
Mar 13, 2018
@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). |
1618cb6 to
a9f1f6fComparea9f1f6f to
c7be953Compare| remoteDir); | ||
| if (results == null || results.isEmpty()) { | ||
| String result = hypervisorResource.callHostPluginAsync(conn, "cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", localDir, "remoteDir", remoteDir); |
There was a problem hiding this 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.
There was a problem hiding this comment.
ok, short method with low cyclic complexity; makes sense
| 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) { |
There was a problem hiding this comment.
Because it is useless in this context.
DaanHoogland
commented
Mar 13, 2018
@blueorangutan package |
blueorangutan
commented
Mar 13, 2018
@DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Mar 13, 2018
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1774 |
DaanHoogland
commented
Mar 13, 2018
@blueorangutan test |
blueorangutan
commented
Mar 13, 2018
@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
blueorangutan
commented
Mar 14, 2018
Trillian test result (tid-2355)
|
GabrielBrascher
left a comment
There was a problem hiding this comment.
Code LGTM, found just a typo in a Javadoc. Thanks for the work @rafaelweingartner !
| final String msg = "createFileSR failed! due to the following: " + ex.toString(); | ||
| /** | ||
| * This method will check if there is an already configured file SR for the given path. If by any chance we find more an one SR with the same name (mount point path) we throw a runtime exception because this situation should never happen. |
There was a problem hiding this comment.
If by any chance we find more an one SR with the same name -> more than one
yadvr
commented
Mar 22, 2018
Thanks @rafaelweingartner since this is a bug fix, do you think it may be useful for 4.11 LTS? |
rafaelweingartner
commented
Mar 22, 2018
@rhtyd I would rather not. It is not a simple rebase to 4.11. |
yadvr
commented
Mar 22, 2018
okay @rafaelweingartner, I'll review this soon. |
yadvr
commented
Mar 22, 2018
@blueorangutan test centos7 xenserver-65sp1 |
blueorangutan
commented
Mar 22, 2018
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + xenserver-65sp1) has been kicked to run smoke tests |
rafaelweingartner
commented
Mar 25, 2018
@rhtyd do you want me to wait a little longer on this one? |
rafaelweingartner
commented
Mar 28, 2018
@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. |
yadvr
commented
May 4, 2018
@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? |
rafaelweingartner
commented
May 4, 2018
I would leave it only for 4.12 due to its size. Only we seemed to have this issue so far. |
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 methodretrieveAlreadyConfiguredSrWithoutExceptionto get the SR that has already been created for the given mount point.