4949
5050import javax .inject .Inject ;
5151import javax .naming .ConfigurationException ;
52+ import java .time .Duration ;
53+ import java .time .Instant ;
5254import java .util .EnumSet ;
5355import java .util .HashSet ;
5456import java .util .LinkedHashMap ;
@@ -84,11 +86,19 @@ public class OntapAsupManager extends ManagerBase implements Configurable {
8486 OntapStorageConstants .ASUP_INTERVAL_CONFIG_KEY ,
8587 String .valueOf (OntapStorageConstants .ASUP_DEFAULT_INTERVAL_SECONDS ),
8688 OntapStorageConstants .ASUP_INTERVAL_DESCRIPTION ,
87- false , ConfigKey .Scope .Global );
89+ true , ConfigKey .Scope .Global );
8890
8991 /** Time (in seconds) to wait while acquiring the single-emitter global lock. */
9092 private static final int ASUP_LOCK_TIMEOUT_SECONDS = 5 ;
9193
94+ /**
95+ * Fixed wakeup interval (ms) for {@link OntapAsupPollTask}. The task wakes on this
96+ * cadence and checks whether the configured push interval ({@link #AsupIntervalSeconds})
97+ * has elapsed. This decouples the scheduler's fixed delay from the live config value,
98+ * so changes made in the CloudStack UI take effect without a management-server restart.
99+ */
100+ static final long ASUP_POLL_CHECK_INTERVAL_MS = 60_000L ;
101+
92102 /**
93103 * Volume states that guarantee a physical object exists on the ONTAP FlexVolume.
94104 * States like {@link Volume.State#Allocated} have a CloudStack DB row pointing to this
@@ -109,6 +119,13 @@ public class OntapAsupManager extends ManagerBase implements Configurable {
109119 /** Serializes the structured event-description payloads to JSON. */
110120 private final ObjectMapper objectMapper = new ObjectMapper ();
111121
122+ /**
123+ * Timestamp of the last successful ASUP push. Starts at {@link Instant#EPOCH} so the
124+ * very first wakeup always fires immediately. {@code volatile} ensures the poll-task
125+ * thread's write is visible without synchronization overhead.
126+ */
127+ volatile Instant lastPushTime = Instant .EPOCH ;
128+
112129 @ Inject
113130 private PrimaryDataStoreDao storagePoolDao ;
114131 @ Inject
@@ -510,13 +527,26 @@ public ConfigKey<?>[] getConfigKeys() {
510527 /**
511528 * Background poll task that runs the ASUP push within a managed CloudStack context.
512529 *
513- * <p>Submitted once to the shared {@link BackgroundPollManager} during the configure-phase;
514- * the poll manager owns the thread and invokes this task every {@link #getDelay()} ms.</p>
530+ * <p>Wakes every {@link #ASUP_POLL_CHECK_INTERVAL_MS} ms. On each wakeup it reads
531+ * the live value of {@link #AsupIntervalSeconds} and only pushes if enough time has
532+ * elapsed since {@link #lastPushTimeMs}. This means changing the interval in the
533+ * CloudStack UI takes effect within one check cycle — no restart required.</p>
515534 */
516535 protected class OntapAsupPollTask extends ManagedContextRunnable implements BackgroundPollTask {
517536 @ Override
518537 protected void runInContext () {
519538 try {
539+ int intervalSeconds = AsupIntervalSeconds .value () != null
540+ ? AsupIntervalSeconds .value () : OntapStorageConstants .ASUP_DEFAULT_INTERVAL_SECONDS ;
541+ if (intervalSeconds <= 0 ) {
542+ intervalSeconds = OntapStorageConstants .ASUP_DEFAULT_INTERVAL_SECONDS ;
543+ }
544+ Duration configuredInterval = Duration .ofSeconds (intervalSeconds );
545+ Instant now = Instant .now ();
546+ if (Duration .between (lastPushTime , now ).compareTo (configuredInterval ) < 0 ) {
547+ return ; // configured interval has not elapsed yet
548+ }
549+ lastPushTime = now ;
520550 pushAsupForAllStoragePools ();
521551 } catch (Exception e ) {
522552 logger .warn ("ONTAP ASUP: unexpected error during periodic push: {}" , e .getMessage ());
@@ -525,12 +555,7 @@ protected void runInContext() {
525555
526556 @ Override
527557 public Long getDelay () {
528- int intervalSeconds = AsupIntervalSeconds .value () != null
529- ? AsupIntervalSeconds .value () : OntapStorageConstants .ASUP_DEFAULT_INTERVAL_SECONDS ;
530- if (intervalSeconds <= 0 ) {
531- intervalSeconds = OntapStorageConstants .ASUP_DEFAULT_INTERVAL_SECONDS ;
532- }
533- return intervalSeconds * 1000L ;
558+ return ASUP_POLL_CHECK_INTERVAL_MS ;
534559 }
535560 }
536561}
0 commit comments