You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/12/02 21:54:35 UTC

[1/3] git commit: updated refs/heads/4.6 to 5b7d935

Repository: cloudstack
Updated Branches:
  refs/heads/4.6 cb50eb8e1 -> 5b7d935ab


CLOUDSTACK-9022: keep Destroyed volumes for sometime


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9077c9a5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9077c9a5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9077c9a5

Branch: refs/heads/4.6
Commit: 9077c9a5b47224b2d00978ff67e9af6957ec589b
Parents: e675250
Author: Wei Zhou <w....@tech.leaseweb.com>
Authored: Tue Nov 3 17:04:55 2015 +0100
Committer: Wei Zhou <w....@tech.leaseweb.com>
Committed: Mon Nov 30 20:43:13 2015 +0100

----------------------------------------------------------------------
 engine/schema/src/com/cloud/storage/dao/VolumeDao.java    |  3 +++
 .../schema/src/com/cloud/storage/dao/VolumeDaoImpl.java   | 10 ++++++++++
 server/src/com/cloud/configuration/Config.java            |  1 +
 server/src/com/cloud/storage/StorageManagerImpl.java      |  9 ++++++---
 4 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index 4959ce4..a05dc1f 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.storage.dao;
 
+import java.util.Date;
 import java.util.List;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -79,6 +80,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
 
     List<VolumeVO> listVolumesToBeDestroyed();
 
+    List<VolumeVO> listVolumesToBeDestroyed(Date date);
+
     ImageFormat getImageFormat(Long volumeId);
 
     List<VolumeVO> findReadyRootVolumesByInstance(long instanceId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index f573847..d53471f 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -331,6 +331,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
         AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
         AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getState(), Op.EQ);
         AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), Op.NEQ);
+        AllFieldsSearch.and("updateTime", AllFieldsSearch.entity().getUpdated(), SearchCriteria.Op.LT);
         AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), Op.EQ);
         AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), Op.EQ);
         AllFieldsSearch.done();
@@ -483,6 +484,15 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
     }
 
     @Override
+    public List<VolumeVO> listVolumesToBeDestroyed(Date date) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("state", Volume.State.Destroy);
+        sc.setParameters("updateTime", date);
+
+        return listBy(sc);
+    }
+
+    @Override
     public boolean updateState(com.cloud.storage.Volume.State currentState, Event event, com.cloud.storage.Volume.State nextState, Volume vo, Object data) {
 
         Long oldUpdated = vo.getUpdatedCount();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 182ec50..d9abecd 100644
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -672,6 +672,7 @@ public enum Config {
             "86400",
             "The interval (in seconds) to wait before running the storage cleanup thread.",
             null),
+    StorageCleanupDelay("Advanced", StorageManager.class, Integer.class, "storage.cleanup.delay", "86400", "Determines how long (in seconds) to wait before actually expunging destroyed volumes. The default value = the default value of storage.cleanup.interval.", null),
     StorageCleanupEnabled("Advanced", StorageManager.class, Boolean.class, "storage.cleanup.enabled", "true", "Enables/disables the storage cleanup thread.", null),
     UpdateWait("Advanced", AgentManager.class, Integer.class, "update.wait", "600", "Time to wait (in seconds) before alerting on a updating agent", null),
     XapiWait("Advanced", AgentManager.class, Integer.class, "xapiwait", "60", "Time (in seconds) to wait for XAPI to return", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index ba39e1f..595cf14 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -301,6 +301,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     boolean _templateCleanupEnabled = true;
     int _storageCleanupInterval;
     int _storagePoolAcquisitionWaitSeconds = 1800; // 30 minutes
+    int _storageCleanupDelay;
     int _downloadUrlCleanupInterval;
     int _downloadUrlExpirationInterval;
     // protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
@@ -470,9 +471,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
         String time = configs.get("storage.cleanup.interval");
         _storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
+        time = configs.get("storage.cleanup.delay");
+        _storageCleanupDelay = NumbersUtil.parseInt(time, _storageCleanupInterval);
 
-        s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", template cleanup enabled: " +
-                _templateCleanupEnabled);
+        s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", delay: " + _storageCleanupDelay  +
+                ", template cleanup enabled: " + _templateCleanupEnabled);
 
         String cleanupInterval = configs.get("extract.url.cleanup.interval");
         _downloadUrlCleanupInterval = NumbersUtil.parseInt(cleanupInterval, 7200);
@@ -1111,7 +1114,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
                     cleanupSecondaryStorage(recurring);
 
-                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed();
+                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed(new Date(System.currentTimeMillis() - ((long) _storageCleanupDelay << 10)));
                     for (VolumeVO vol : vols) {
                         try {
                             volService.expungeVolumeAsync(volFactory.getVolume(vol.getId()));


[3/3] git commit: updated refs/heads/4.6 to 5b7d935

Posted by re...@apache.org.
Merge pull request #1145 from ustcweizhou/storage-cleanup-delay-4.6

[4.6.1] CLOUDSTACK-9022: keep Destroyed volumes for sometimefor now, the Destroyed volumes will be expunged in Storage cleanup thread, no matter when they are destroyed.
In Expunging vm thread, we expunge the Destroyed vms which have been destroyed at least 'expunge.delay' seconds. We add the similar configuration for volumes.

same to #1029 , for 4.6

* pr/1145:
  CLOUDSTACK-9022: move storage.cleanup related global configurations to StorageManager
  CLOUDSTACK-9022: keep Destroyed volumes for sometime

This closes #1029

Signed-off-by: Remi Bergsma <gi...@remi.nl>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5b7d935a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5b7d935a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5b7d935a

Branch: refs/heads/4.6
Commit: 5b7d935ab0b35bec936785e44023ac0d8552e72b
Parents: cb50eb8 4ed1e0d
Author: Remi Bergsma <gi...@remi.nl>
Authored: Wed Dec 2 21:52:46 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Wed Dec 2 21:53:11 2015 +0100

----------------------------------------------------------------------
 .../src/com/cloud/storage/dao/VolumeDao.java    |  3 ++
 .../com/cloud/storage/dao/VolumeDaoImpl.java    | 10 ++++++
 server/src/com/cloud/configuration/Config.java  |  9 -----
 .../src/com/cloud/storage/StorageManager.java   |  8 +++++
 .../com/cloud/storage/StorageManagerImpl.java   | 36 +++++++++++---------
 5 files changed, 41 insertions(+), 25 deletions(-)
----------------------------------------------------------------------



[2/3] git commit: updated refs/heads/4.6 to 5b7d935

Posted by re...@apache.org.
CLOUDSTACK-9022: move storage.cleanup related global configurations to StorageManager


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4ed1e0d5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4ed1e0d5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4ed1e0d5

Branch: refs/heads/4.6
Commit: 4ed1e0d5f809d1bb2845b6e076d55eeb1ce3f0f4
Parents: 9077c9a
Author: Wei Zhou <w....@tech.leaseweb.com>
Authored: Wed Nov 4 09:27:32 2015 +0100
Committer: Wei Zhou <w....@tech.leaseweb.com>
Committed: Mon Nov 30 20:44:05 2015 +0100

----------------------------------------------------------------------
 server/src/com/cloud/configuration/Config.java  | 10 ------
 .../src/com/cloud/storage/StorageManager.java   |  8 +++++
 .../com/cloud/storage/StorageManagerImpl.java   | 37 ++++++++++----------
 3 files changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ed1e0d5/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index d9abecd..f13ebf5 100644
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -664,16 +664,6 @@ public enum Config {
             "600",
             "Time in seconds between retries to stop or destroy a vm",
             null),
-    StorageCleanupInterval(
-            "Advanced",
-            StorageManager.class,
-            Integer.class,
-            "storage.cleanup.interval",
-            "86400",
-            "The interval (in seconds) to wait before running the storage cleanup thread.",
-            null),
-    StorageCleanupDelay("Advanced", StorageManager.class, Integer.class, "storage.cleanup.delay", "86400", "Determines how long (in seconds) to wait before actually expunging destroyed volumes. The default value = the default value of storage.cleanup.interval.", null),
-    StorageCleanupEnabled("Advanced", StorageManager.class, Boolean.class, "storage.cleanup.enabled", "true", "Enables/disables the storage cleanup thread.", null),
     UpdateWait("Advanced", AgentManager.class, Integer.class, "update.wait", "600", "Time to wait (in seconds) before alerting on a updating agent", null),
     XapiWait("Advanced", AgentManager.class, Integer.class, "xapiwait", "60", "Time (in seconds) to wait for XAPI to return", null),
     MigrateWait("Advanced", AgentManager.class, Integer.class, "migratewait", "3600", "Time (in seconds) to wait for VM migrate finish", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ed1e0d5/server/src/com/cloud/storage/StorageManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java
index 5487e2e..a399a08 100644
--- a/server/src/com/cloud/storage/StorageManager.java
+++ b/server/src/com/cloud/storage/StorageManager.java
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
 import com.cloud.agent.api.Answer;
@@ -39,6 +40,13 @@ import com.cloud.utils.Pair;
 import com.cloud.vm.VMInstanceVO;
 
 public interface StorageManager extends StorageService {
+    static final ConfigKey<Integer> StorageCleanupInterval = new ConfigKey<Integer>(Integer.class, "storage.cleanup.interval", "Advanced", "86400",
+            "The interval (in seconds) to wait before running the storage cleanup thread.", false, ConfigKey.Scope.Global, null);
+    static final ConfigKey<Integer> StorageCleanupDelay = new ConfigKey<Integer>(Integer.class, "storage.cleanup.delay", "Advanced", "86400",
+            "Determines how long (in seconds) to wait before actually expunging destroyed volumes. The default value = the default value of storage.cleanup.interval.", false, ConfigKey.Scope.Global, null);
+    static final ConfigKey<Boolean> StorageCleanupEnabled = new ConfigKey<Boolean>(Boolean.class, "storage.cleanup.enabled", "Advanced", "true",
+            "Enables/disables the storage cleanup thread.", false, ConfigKey.Scope.Global, null);
+
     /**
      * Returns a comma separated list of tags for the specified storage pool
      * @param poolId

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ed1e0d5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 595cf14..b8890bf 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -79,6 +79,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
@@ -190,7 +192,7 @@ import com.cloud.vm.dao.VMInstanceDao;
 
 @Component
 @Local(value = {StorageManager.class, StorageService.class})
-public class StorageManagerImpl extends ManagerBase implements StorageManager, ClusterManagerListener {
+public class StorageManagerImpl extends ManagerBase implements StorageManager, ClusterManagerListener, Configurable {
     private static final Logger s_logger = Logger.getLogger(StorageManagerImpl.class);
 
     protected String _name;
@@ -297,11 +299,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
     protected SearchBuilder<StoragePoolVO> LocalStorageSearch;
 
     ScheduledExecutorService _executor = null;
-    boolean _storageCleanupEnabled;
     boolean _templateCleanupEnabled = true;
-    int _storageCleanupInterval;
     int _storagePoolAcquisitionWaitSeconds = 1800; // 30 minutes
-    int _storageCleanupDelay;
     int _downloadUrlCleanupInterval;
     int _downloadUrlExpirationInterval;
     // protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
@@ -463,18 +462,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
         _agentMgr.registerForHostEvents(new StoragePoolMonitor(this, _storagePoolDao), true, false, true);
 
-        String storageCleanupEnabled = configs.get("storage.cleanup.enabled");
-        _storageCleanupEnabled = (storageCleanupEnabled == null) ? true : Boolean.parseBoolean(storageCleanupEnabled);
-
         String value = _configDao.getValue(Config.StorageTemplateCleanupEnabled.key());
         _templateCleanupEnabled = (value == null ? true : Boolean.parseBoolean(value));
 
-        String time = configs.get("storage.cleanup.interval");
-        _storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
-        time = configs.get("storage.cleanup.delay");
-        _storageCleanupDelay = NumbersUtil.parseInt(time, _storageCleanupInterval);
-
-        s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", delay: " + _storageCleanupDelay  +
+        s_logger.info("Storage cleanup enabled: " + StorageCleanupEnabled.value() + ", interval: " + StorageCleanupInterval.value() + ", delay: " + StorageCleanupDelay.value()  +
                 ", template cleanup enabled: " + _templateCleanupEnabled);
 
         String cleanupInterval = configs.get("extract.url.cleanup.interval");
@@ -528,10 +519,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
     @Override
     public boolean start() {
-        if (_storageCleanupEnabled) {
+        if (StorageCleanupEnabled.value()) {
             Random generator = new Random();
-            int initialDelay = generator.nextInt(_storageCleanupInterval);
-            _executor.scheduleWithFixedDelay(new StorageGarbageCollector(), initialDelay, _storageCleanupInterval, TimeUnit.SECONDS);
+            int initialDelay = generator.nextInt(StorageCleanupInterval.value());
+            _executor.scheduleWithFixedDelay(new StorageGarbageCollector(), initialDelay, StorageCleanupInterval.value(), TimeUnit.SECONDS);
         } else {
             s_logger.debug("Storage cleanup is not enabled, so the storage cleanup thread is not being scheduled.");
         }
@@ -543,7 +534,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
     @Override
     public boolean stop() {
-        if (_storageCleanupEnabled) {
+        if (StorageCleanupEnabled.value()) {
             _executor.shutdown();
         }
         return true;
@@ -1114,7 +1105,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
 
                     cleanupSecondaryStorage(recurring);
 
-                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed(new Date(System.currentTimeMillis() - ((long) _storageCleanupDelay << 10)));
+                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed(new Date(System.currentTimeMillis() - ((long) StorageCleanupDelay.value() << 10)));
                     for (VolumeVO vol : vols) {
                         try {
                             volService.expungeVolumeAsync(volFactory.getVolume(vol.getId()));
@@ -2306,4 +2297,14 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         }
         return 0L;
     }
+
+    @Override
+    public String getConfigComponentName() {
+        return StorageManager.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {StorageCleanupInterval, StorageCleanupDelay, StorageCleanupEnabled};
+    }
 }