Skip to content

Commit e8a04e2

Browse files
sureshanapartidhslove
authored andcommitted
PowerFlex/ScaleIO - Wait after SDC service start/restart/stop, and retry to fetch SDC id/guid (apache#11099)
* [PowerFlex/ScaleIO] Added wait time after SDC service start/restart/stop, and retries to fetch SDC id/guid * Added agent property 'powerflex.sdc.service.wait' for the time (in secs) to wait after SDC service start/restart/stop * code improvements
1 parent 2732e39 commit e8a04e2

File tree

5 files changed

+42
-63
lines changed

5 files changed

+42
-63
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -653,24 +653,10 @@ public Ternary<Boolean, Map<String, String>, String> prepareStorageClient(String
653653
if (!ScaleIOUtil.startSDCService()) {
654654
return new Ternary<>(false, null, "Couldn't start SDC service on host");
655655
}
656-
}
657-
658-
if (MapUtils.isNotEmpty(details) && details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_MDMS)) {
659-
// Assuming SDC service is started, add mdms
660-
String mdms = details.get(ScaleIOGatewayClient.STORAGE_POOL_MDMS);
661-
String[] mdmAddresses = mdms.split(",");
662-
if (mdmAddresses.length > 0) {
663-
if (ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
664-
return new Ternary<>(true, getSDCDetails(details), "MDM added, no need to prepare the SDC client");
665-
}
666-
667-
ScaleIOUtil.addMdms(mdmAddresses);
668-
if (!ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
669-
return new Ternary<>(false, null, "Failed to add MDMs");
670-
} else {
671-
logger.debug(String.format("MDMs %s added to storage pool %s", mdms, uuid));
672-
applyMdmsChangeWaitTime(details);
673-
}
656+
} else {
657+
logger.debug("SDC service is active on host, re-starting it");
658+
if (!ScaleIOUtil.restartSDCService()) {
659+
return new Ternary<>(false, null, "Couldn't restart SDC service on host");
674660
}
675661
}
676662

@@ -679,7 +665,7 @@ public Ternary<Boolean, Map<String, String>, String> prepareStorageClient(String
679665
return new Ternary<>(false, null, "Couldn't get the SDC details on the host");
680666
}
681667

682-
return new Ternary<>(true, sdcDetails, "Prepared client successfully");
668+
return new Ternary<>( true, sdcDetails, "Prepared client successfully");
683669
}
684670

685671
public Pair<Boolean, String> unprepareStorageClient(String uuid, Map<String, String> details) {
@@ -798,12 +784,12 @@ private Map<String, String> getSDCDetails(Map<String, String> details) {
798784
if (sdcId != null) {
799785
sdcDetails.put(ScaleIOGatewayClient.SDC_ID, sdcId);
800786
return sdcDetails;
801-
}
802-
803-
String sdcGuId = ScaleIOUtil.getSdcGuid();
804-
if (sdcGuId != null) {
805-
sdcDetails.put(ScaleIOGatewayClient.SDC_GUID, sdcGuId);
806-
return sdcDetails;
787+
} else {
788+
String sdcGuId = ScaleIOUtil.getSdcGuid();
789+
if (sdcGuId != null) {
790+
sdcDetails.put(ScaleIOGatewayClient.SDC_GUID, sdcGuId);
791+
return sdcDetails;
792+
}
807793
}
808794

809795
try {

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptorTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,34 @@ public void testPrepareStorageClient_SDCServiceNotEnabled() {
9292
Assert.assertEquals("SDC service not enabled on host", result.third());
9393
}
9494

95+
@Test
96+
public void testPrepareStorageClient_SDCServiceNotRestarted() {
97+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
98+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
99+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-active scini"))).thenReturn(0);
100+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(1);
101+
102+
Ternary<Boolean, Map<String, String>, String> result = scaleIOStorageAdaptor.prepareStorageClient(Storage.StoragePoolType.PowerFlex, poolUuid, new HashMap<>());
103+
104+
Assert.assertFalse(result.first());
105+
Assert.assertNull(result.second());
106+
Assert.assertEquals("Couldn't restart SDC service on host", result.third());
107+
}
108+
109+
@Test
110+
public void testPrepareStorageClient_SDCServiceRestarted() {
111+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
112+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
113+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-active scini"))).thenReturn(0);
114+
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(0);
115+
116+
Ternary<Boolean, Map<String, String>, String> result = scaleIOStorageAdaptor.prepareStorageClient(Storage.StoragePoolType.PowerFlex, poolUuid, new HashMap<>());
117+
118+
Assert.assertFalse(result.first());
119+
Assert.assertNull(result.second());
120+
Assert.assertEquals("Couldn't get the SDC details on the host", result.third());
121+
}
122+
95123
@Test
96124
public void testPrepareStorageClient_SDCServiceNotStarted() {
97125
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public String prepareSDC(Host host, DataStore dataStore) {
185185
}
186186

187187
int waitTimeInSecs = 15; // Wait for 15 secs (usual tests with SDC service start took 10-15 secs)
188-
if (isHostSdcConnected(sdcId, dataStore, waitTimeInSecs)) {
188+
if (hostSdcConnected(sdcId, dataStore, waitTimeInSecs)) {
189189
return sdcId;
190190
}
191191
}
@@ -249,7 +249,7 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId,
249249
}
250250

251251
if (StringUtils.isBlank(sdcId)) {
252-
logger.warn("Couldn't retrieve PowerFlex storage SDC details from the host: {}, add MDMs if On-demand connect disabled or try (re)install SDC & restart agent", host);
252+
logger.warn("Couldn't retrieve PowerFlex storage SDC details from the host: {}, add MDMs if not or try (re)install SDC & restart agent", host);
253253
return null;
254254
}
255255

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/provider/ScaleIOHostListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private String getSdcIdOfHost(HostVO host, DataStore dataStore) {
136136
}
137137

138138
if (StringUtils.isBlank(sdcId)) {
139-
String msg = String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, add MDMs if On-demand connect disabled or try (re)install SDC & restart agent", host);
139+
String msg = String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, add MDMs if not or try (re)install SDC & restart agent", host);
140140
logger.warn(msg);
141141
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "SDC details not found on host: " + host.getUuid(), msg);
142142
return null;

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/util/ScaleIOUtil.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -513,39 +513,4 @@ private static void waitForSdcServiceActionToComplete() {
513513
} catch (InterruptedException ignore) {
514514
}
515515
}
516-
517-
/**
518-
* Represents {@link ScaleIOUtil#DRV_CFG_FILE} MDM entry (SDC and Installation Ids are skipped).
519-
*/
520-
public static class MdmEntry {
521-
private String mdmId;
522-
private Collection<String> ips;
523-
524-
/**
525-
* MDM entry constructor.
526-
*
527-
* @param mdmId MDM Id
528-
* @param ips IP Addresses
529-
*/
530-
public MdmEntry(String mdmId, Collection<String> ips) {
531-
this.mdmId = mdmId;
532-
this.ips = ips;
533-
}
534-
535-
public String getMdmId() {
536-
return mdmId;
537-
}
538-
539-
public void setMdmId(String mdmId) {
540-
this.mdmId = mdmId;
541-
}
542-
543-
public Collection<String> getIps() {
544-
return ips;
545-
}
546-
547-
public void setIps(Collection<String> ips) {
548-
this.ips = ips;
549-
}
550-
}
551516
}

0 commit comments

Comments
 (0)