Sahina Bose has uploaded a new change for review. Change subject: engine: Allow simultaneous add of gluster host ......................................................................
engine: Allow simultaneous add of gluster host If multiple hosts are being provisioned using Foreman and being added to the cluster, then this should be allowed The peer probe of hosts to the cluster, will happen when the host finished installation and first moves to UP state Change-Id: I3f1f81c90d2ec727159a2ed4d147a0acffd60ab9 Bug-Url: https://bugzilla.redhat.com/1142779 Signed-off-by: Sahina Bose <sab...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVdsCommandTest.java 2 files changed, 29 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/41861/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java index b11cbc7..ccaea2e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java @@ -66,7 +66,7 @@ @NonTransactiveCommandAttribute(forceCompensation = true) public class AddVdsCommand<T extends AddVdsActionParameters> extends VdsCommand<T> { - private AuditLogType errorType = AuditLogType.USER_FAILED_ADD_VDS; + private final AuditLogType errorType = AuditLogType.USER_FAILED_ADD_VDS; /** * Constructor for command creation when compensation is applied on startup @@ -372,7 +372,9 @@ } if (returnValue && isGlusterSupportEnabled()) { - if (clusterHasServers()) { + // allow simultaneous installation of hosts, but if a host has completed install, only + // allow addition of another host if it can be peer probed to cluster. + if (clusterHasNonInitializingServers()) { VDS upServer = getClusterUtils().getUpServer(getVdsGroupId()); if (upServer == null) { returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_GLUSTER_HOST_TO_PEER_PROBE); @@ -391,6 +393,18 @@ return getClusterUtils().hasServers(getVdsGroupId()); } + private boolean clusterHasNonInitializingServers() { + for (VDS vds : getVdsDAO().getAllForVdsGroup(getVdsGroupId())) { + if (vds.getStatus() != VDSStatus.Installing && + vds.getStatus() != VDSStatus.InstallingOS && + vds.getStatus() != VDSStatus.PendingApproval && + vds.getStatus() != VDSStatus.Initializing && + vds.getStatus() != VDSStatus.InstallFailed) + return true; + } + return false; + } + protected ClusterUtils getClusterUtils() { return ClusterUtils.getInstance(); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVdsCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVdsCommandTest.java index 97eff80..905c592 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVdsCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVdsCommandTest.java @@ -8,7 +8,9 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import org.junit.Before; import org.junit.ClassRule; @@ -22,6 +24,7 @@ import org.ovirt.engine.core.bll.utils.GlusterUtil; import org.ovirt.engine.core.common.action.AddVdsActionParameters; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.compat.Guid; @@ -121,11 +124,21 @@ when(commandMock.getGlusterDBUtils()).thenReturn(glusterDBUtils); when(clusterUtils.hasServers(any(Guid.class))).thenReturn(clusterHasServers); + when(vdsDaoMock.getAllForVdsGroup(any(Guid.class))).thenReturn(mockVdsInDb(clusterHasServers ? VDSStatus.Maintenance + : VDSStatus.Initializing)); when(clusterUtils.getUpServer(any(Guid.class))).thenReturn(upServer); commandMock.log = this.log; } + private List<VDS> mockVdsInDb(VDSStatus status) { + List<VDS> vdsList = new ArrayList<>(); + VDS vds = new VDS(); + vds.setStatus(status); + vdsList.add(vds); + return vdsList; + } + @Test public void canDoActionVirtOnlySucceeds() throws Exception { setupVirtMock(); -- To view, visit https://gerrit.ovirt.org/41861 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3f1f81c90d2ec727159a2ed4d147a0acffd60ab9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Sahina Bose <sab...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches