1717
1818package org .apache .cloudstack .storage .datastore .util ;
1919
20+ import com .cloud .agent .properties .AgentProperties ;
21+ import com .cloud .agent .properties .AgentPropertiesFileHandler ;
2022import org .apache .logging .log4j .Logger ;
2123import org .apache .logging .log4j .LogManager ;
2224
@@ -60,6 +62,14 @@ public class ScaleIOUtil {
6062 private static final String SDC_SERVICE_ENABLE_CMD = "systemctl enable scini" ;
6163
6264 public static final String CONNECTED_SDC_COUNT_STAT = "ConnectedSDCCount" ;
65+
66+ /**
67+ * Time (in seconds) to wait after SDC service 'scini' start/restart/stop.<br>
68+ * Data type: Integer.<br>
69+ * Default value: <code>3</code>
70+ */
71+ public static final AgentProperties .Property <Integer > SDC_SERVICE_ACTION_WAIT = new AgentProperties .Property <>("powerflex.sdc.service.wait" , 3 );
72+
6373 /**
6474 * Cmd for querying volumes in SDC
6575 * Sample output for cmd: drv_cfg --query_vols:
@@ -219,7 +229,7 @@ public static boolean startSDCService() {
219229 if (exitValue != 0 ) {
220230 return false ;
221231 }
222- waitForSecs ( 3 );
232+ waitForSdcServiceActionToComplete ( );
223233 return true ;
224234 }
225235
@@ -228,7 +238,7 @@ public static boolean stopSDCService() {
228238 if (exitValue != 0 ) {
229239 return false ;
230240 }
231- waitForSecs ( 1 );
241+ waitForSdcServiceActionToComplete ( );
232242 return true ;
233243 }
234244
@@ -237,16 +247,19 @@ public static boolean restartSDCService() {
237247 if (exitValue != 0 ) {
238248 return false ;
239249 }
240- waitForSecs ( 3 );
250+ waitForSdcServiceActionToComplete ( );
241251 return true ;
242252 }
243253
244- private static void waitForSecs (long waitTimeInSecs ) {
254+ private static void waitForSdcServiceActionToComplete () {
255+ // Wait for the SDC service to settle after start/restart/stop and reaches a stable state
256+ int waitTimeInSecs = AgentPropertiesFileHandler .getPropertyValue (SDC_SERVICE_ACTION_WAIT );
245257 if (waitTimeInSecs < 0 ) {
246- waitTimeInSecs = 1 ;
258+ waitTimeInSecs = SDC_SERVICE_ACTION_WAIT . getDefaultValue () ;
247259 }
248260 try {
249- Thread .sleep (waitTimeInSecs * 1000 );
261+ LOGGER .debug (String .format ("Waiting for %d secs after SDC service action, to reach a stable state" , waitTimeInSecs ));
262+ Thread .sleep (waitTimeInSecs * 1000L );
250263 } catch (InterruptedException ignore ) {
251264 }
252265 }
0 commit comments