Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,24 @@ public Ternary<Boolean, Map<String, String>, String> prepareStorageClient(String
if (!ScaleIOUtil.startSDCService()) {
return new Ternary<>(false, null, "Couldn't start SDC service on host");
}
} else {
logger.debug("SDC service is active on host, re-starting it");
if (!ScaleIOUtil.restartSDCService()) {
return new Ternary<>(false, null, "Couldn't restart SDC service on host");
}

if (MapUtils.isNotEmpty(details) && details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_MDMS)) {
// Assuming SDC service is started, add mdms
String mdms = details.get(ScaleIOGatewayClient.STORAGE_POOL_MDMS);
String[] mdmAddresses = mdms.split(",");
if (mdmAddresses.length > 0) {
if (ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Ternary<>(true, getSDCDetails(details), "MDM added, no need to prepare the SDC client");
}

ScaleIOUtil.addMdms(mdmAddresses);
if (!ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Ternary<>(false, null, "Failed to add MDMs");
} else {
logger.debug(String.format("MDMs %s added to storage pool %s", mdms, uuid));
applyMdmsChangeWaitTime(details);
}
}
}

Expand Down Expand Up @@ -784,12 +798,12 @@ private Map<String, String> getSDCDetails(Map<String, String> details) {
if (sdcId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_ID, sdcId);
return sdcDetails;
} else {
String sdcGuId = ScaleIOUtil.getSdcGuid();
if (sdcGuId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_GUID, sdcGuId);
return sdcDetails;
}
}

String sdcGuId = ScaleIOUtil.getSdcGuid();
if (sdcGuId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_GUID, sdcGuId);
return sdcDetails;
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,6 @@ public void testPrepareStorageClient_SDCServiceNotEnabled() {
Assert.assertEquals("SDC service not enabled on host", result.third());
}

@Test
public void testPrepareStorageClient_SDCServiceNotRestarted() {
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-active scini"))).thenReturn(0);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(1);

Ternary<Boolean, Map<String, String>, String> result = scaleIOStorageAdaptor.prepareStorageClient(poolUuid, new HashMap<>());

Assert.assertFalse(result.first());
Assert.assertNull(result.second());
Assert.assertEquals("Couldn't restart SDC service on host", result.third());
}

@Test
public void testPrepareStorageClient_SDCServiceRestarted() {
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-active scini"))).thenReturn(0);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(0);

Ternary<Boolean, Map<String, String>, String> result = scaleIOStorageAdaptor.prepareStorageClient(poolUuid, new HashMap<>());

Assert.assertFalse(result.first());
Assert.assertNull(result.second());
Assert.assertEquals("Couldn't get the SDC details on the host", result.third());
}

@Test
public void testPrepareStorageClient_SDCServiceNotStarted() {
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
Expand Down
Loading