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, 28 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/35635/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 34335bd..451af02 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 @@ -373,7 +373,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); @@ -392,6 +394,17 @@ 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) + 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 3b874c1..08defd7 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 http://gerrit.ovirt.org/35635 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3f1f81c90d2ec727159a2ed4d147a0acffd60ab9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sahina Bose <sab...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches