Skip to content

Commit 2a78099

Browse files
mprokopchuksureshanaparti
authored andcommitted
- Addressed code review comments: Added checking mdm removal response validation
1 parent c4251de commit 2a78099

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public void testUnprepareStorageClient_RemoveMDMFailed() {
194194
details.put(ScaleIOGatewayClient.STORAGE_POOL_MDMS, "1.1.1.1,2.2.2.2");
195195
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
196196
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
197+
when(Script.executeCommand(Mockito.eq("sed -i '/1.1.1.1\\,/d' /etc/emc/scaleio/drv_cfg.txt"))).thenReturn(new Pair<>(null, null));
197198
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(0);
198199
when(Script.runSimpleBashScript(Mockito.eq("/opt/emc/scaleio/sdc/bin/drv_cfg --query_mdms --file /etc/emc/scaleio/drv_cfg.txt|grep 1.1.1.1"))).thenReturn("MDM-ID 71fd458f0775010f SDC ID 4421a91a00000000 INSTALLATION ID 204930df2cbcaf8e IPs [0]-1.1.1.1 [1]-2.2.2.2");
199200
when(Script.executeCommand(Mockito.eq("/opt/emc/scaleio/sdc/bin/drv_cfg"))).thenReturn(new Pair<>(null, null));

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,19 @@ public static boolean removeMdms(String... mdmAddresses) {
213213
}
214214
// remove MDM via CLI if it is supported
215215
if (removeMdmCliSupported) {
216-
removeMdm(mdmAddress);
217216
if (removeMdm(mdmAddress)) {
218217
changesApplied = true;
219218
}
220219
} else {
221220
String command = String.format(REMOVE_MDM_CMD_TEMPLATE, mdmAddress, DRV_CFG_FILE);
222-
Script.runSimpleBashScript(command);
223-
// restart SDC needed only if configuration file modified manually (not by CLI)
224-
restartSDC = true;
225-
changesApplied = true;
221+
String stdErr = Script.executeCommand(command).second();
222+
if(StringUtils.isEmpty(stdErr)) {
223+
// restart SDC needed only if configuration file modified manually (not by CLI)
224+
restartSDC = true;
225+
changesApplied = true;
226+
} else {
227+
LOGGER.error(String.format("Failed to remove MDM %s from %s: %s", mdmAddress, DRV_CFG_FILE, stdErr));
228+
}
226229
}
227230
}
228231
if (restartSDC) {

0 commit comments

Comments
 (0)