Skip to content

Commit f3b3487

Browse files
[CLOUDSTACK-10214] Unable to remove local primary storage
When enabling the use of local storage ACS will automatically load all local storage configured in the Host and start using them as primary storage to deploy user VMs (if the service offering allows to do so). However, if the operator wants to remove the local storage ACS will throw an exception saying that the removal of local storage is not allowed.Therefore, if one wants to remove a local storage, he/she needs to do a manual intervention in the database and hosts. This limitation was removed, as it was only a logical restriction.
1 parent b16dcb7 commit f3b3487

3 files changed

Lines changed: 16 additions & 49 deletions

File tree

api/src/com/cloud/storage/StorageService.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,16 @@ public interface StorageService {
9090

9191
boolean deleteSecondaryStagingStore(DeleteSecondaryStagingStoreCmd cmd);
9292

93-
ImageStore discoverImageStore(String name, String url, String providerName, Long zoneId, Map details) throws IllegalArgumentException, DiscoveryException,
94-
InvalidParameterValueException;
93+
ImageStore discoverImageStore(String name, String url, String providerName, Long zoneId, Map details) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
9594

96-
97-
/**
95+
/**
9896
* Migrate existing NFS to use object store.
9997
* @param name object store name.
100-
* @param url object store url.
98+
* @param url object store URL.
10199
* @param providerName object store provider Name.
102100
* @param details object store other details
103101
* @return Object store created.
104-
* @throws IllegalArgumentException
105-
* @throws DiscoveryException
106-
* @throws InvalidParameterValueException
107102
*/
108-
ImageStore migrateToObjectStore(String name, String url, String providerName, Map details) throws IllegalArgumentException, DiscoveryException,
109-
InvalidParameterValueException;
110-
103+
ImageStore migrateToObjectStore(String name, String url, String providerName, Map<String, String> details) throws DiscoveryException;
111104

112105
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ cloudmonkey
2121
# Marvin dependencies are installed via its bundle
2222

2323
# Install the SolidFire SDK for Python
24-
solidfire-sdk-python
24+
solidfire-sdk-python

server/src/com/cloud/storage/StorageManagerImpl.java

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
import javax.inject.Inject;
4141
import javax.naming.ConfigurationException;
4242

43-
import com.cloud.hypervisor.Hypervisor;
44-
45-
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
46-
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
47-
import org.apache.log4j.Logger;
48-
import org.springframework.stereotype.Component;
4943
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
5044
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
5145
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
@@ -66,11 +60,13 @@
6660
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
6761
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
6862
import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
63+
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
6964
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
7065
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
7166
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
7267
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
7368
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
69+
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
7470
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
7571
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
7672
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
@@ -84,8 +80,8 @@
8480
import org.apache.cloudstack.framework.config.ConfigKey;
8581
import org.apache.cloudstack.framework.config.Configurable;
8682
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
87-
import org.apache.cloudstack.storage.command.DettachCommand;
8883
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
84+
import org.apache.cloudstack.storage.command.DettachCommand;
8985
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
9086
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
9187
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
@@ -100,6 +96,8 @@
10096
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
10197
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
10298
import org.apache.cloudstack.storage.to.VolumeObjectTO;
99+
import org.apache.log4j.Logger;
100+
import org.springframework.stereotype.Component;
103101

104102
import com.cloud.agent.AgentManager;
105103
import com.cloud.agent.api.Answer;
@@ -143,6 +141,7 @@
143141
import com.cloud.host.HostVO;
144142
import com.cloud.host.Status;
145143
import com.cloud.host.dao.HostDao;
144+
import com.cloud.hypervisor.Hypervisor;
146145
import com.cloud.hypervisor.Hypervisor.HypervisorType;
147146
import com.cloud.hypervisor.HypervisorGuruManager;
148147
import com.cloud.offering.DiskOffering;
@@ -861,11 +860,6 @@ public boolean deletePool(DeletePoolCmd cmd) {
861860
s_logger.warn("Unable to delete storage id: " + id + " due to it is not in Maintenance state");
862861
throw new InvalidParameterValueException("Unable to delete storage due to it is not in Maintenance state, id: " + id);
863862
}
864-
if (sPool.isLocal()) {
865-
s_logger.warn("Unable to delete local storage id:" + id);
866-
throw new InvalidParameterValueException("Unable to delete local storage id: " + id);
867-
}
868-
869863
Pair<Long, Long> vlms = _volsDao.getCountAndTotalByPool(id);
870864
if (forced) {
871865
if (vlms.first() > 0) {
@@ -1071,15 +1065,15 @@ public void cleanupStorage(boolean recurring) {
10711065
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
10721066
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
10731067
s_logger.debug("Storage pool garbage collector is skipping template with ID: " + templatePoolVO.getTemplateId() +
1074-
" on pool " + templatePoolVO.getPoolId() + " because it is not completely downloaded.");
1068+
" on pool " + templatePoolVO.getPoolId() + " because it is not completely downloaded.");
10751069
continue;
10761070
}
10771071

10781072
if (!templatePoolVO.getMarkedForGC()) {
10791073
templatePoolVO.setMarkedForGC(true);
10801074
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
10811075
s_logger.debug("Storage pool garbage collector has marked template with ID: " + templatePoolVO.getTemplateId() +
1082-
" on pool " + templatePoolVO.getPoolId() + " for garbage collection.");
1076+
" on pool " + templatePoolVO.getPoolId() + " for garbage collection.");
10831077
continue;
10841078
}
10851079

@@ -1484,8 +1478,6 @@ protected void runInContext() {
14841478

14851479
@Override
14861480
public void onManagementNodeJoined(List<? extends ManagementServerHost> nodeList, long selfNodeId) {
1487-
// TODO Auto-generated method stub
1488-
14891481
}
14901482

14911483
@Override
@@ -1876,21 +1868,6 @@ private HypervisorType getHypervisorType(Volume volume) {
18761868
return null;
18771869
}
18781870

1879-
private long getDataObjectSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
1880-
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
1881-
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
1882-
1883-
if (storeDriver instanceof PrimaryDataStoreDriver) {
1884-
PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver;
1885-
1886-
VolumeInfo volumeInfo = volFactory.getVolume(volume.getId());
1887-
1888-
return primaryStoreDriver.getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeInfo, pool);
1889-
}
1890-
1891-
return volume.getSize();
1892-
}
1893-
18941871
private long getBytesRequiredForTemplate(VMTemplateVO tmpl, StoragePool pool) {
18951872
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
18961873
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
@@ -1920,19 +1897,16 @@ public synchronized boolean registerHostListener(String providerName, Hypervisor
19201897

19211898
@Override
19221899
public Answer sendToPool(long poolId, Command cmd) throws StorageUnavailableException {
1923-
// TODO Auto-generated method stub
19241900
return null;
19251901
}
19261902

19271903
@Override
19281904
public Answer[] sendToPool(long poolId, Commands cmd) throws StorageUnavailableException {
1929-
// TODO Auto-generated method stub
19301905
return null;
19311906
}
19321907

19331908
@Override
19341909
public String getName() {
1935-
// TODO Auto-generated method stub
19361910
return null;
19371911
}
19381912

@@ -1995,7 +1969,7 @@ public ImageStore discoverImageStore(String name, String url, String providerNam
19951969
}
19961970
}
19971971

1998-
Map<String, Object> params = new HashMap();
1972+
Map<String, Object> params = new HashMap<>();
19991973
params.put("zoneId", zoneId);
20001974
params.put("url", url);
20011975
params.put("name", name);
@@ -2036,7 +2010,7 @@ public ImageStore discoverImageStore(String name, String url, String providerNam
20362010
}
20372011

20382012
@Override
2039-
public ImageStore migrateToObjectStore(String name, String url, String providerName, Map details) throws IllegalArgumentException, DiscoveryException,
2013+
public ImageStore migrateToObjectStore(String name, String url, String providerName, Map<String, String> details) throws DiscoveryException,
20402014
InvalidParameterValueException {
20412015
// check if current cloud is ready to migrate, we only support cloud with only NFS secondary storages
20422016
List<ImageStoreVO> imgStores = _imageStoreDao.listImageStores();
@@ -2303,7 +2277,7 @@ public void cleanupDownloadUrls(){
23032277
ImageStoreEntity secStore = (ImageStoreEntity) _dataStoreMgr.getDataStore(volumeOnImageStore.getDataStoreId(), DataStoreRole.Image);
23042278
secStore.deleteExtractUrl(volumeOnImageStore.getInstallPath(), volumeOnImageStore.getExtractUrl(), Upload.Type.VOLUME);
23052279

2306-
// Now expunge it from DB since this entry was created only for download purpose
2280+
// Now expunge it from DB since this entry was created only for download purpose
23072281
_volumeStoreDao.expunge(volumeOnImageStore.getId());
23082282
}catch(Throwable th){
23092283
s_logger.warn("Caught exception while deleting download url " +volumeOnImageStore.getExtractUrl() +

0 commit comments

Comments
 (0)