Skip to content

Commit 6360548

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 bc1b5fb commit 6360548

3 files changed

Lines changed: 15 additions & 47 deletions

File tree

api/src/main/java/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/main/java/com/cloud/storage/StorageManagerImpl.java

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

43-
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
44-
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
45-
import org.apache.log4j.Logger;
46-
import org.springframework.stereotype.Component;
4743
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
4844
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
4945
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
@@ -64,11 +60,13 @@
6460
import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
6561
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
6662
import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
63+
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
6764
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
6865
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
6966
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
7067
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
7168
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
69+
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
7270
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
7371
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
7472
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
@@ -82,8 +80,8 @@
8280
import org.apache.cloudstack.framework.config.ConfigKey;
8381
import org.apache.cloudstack.framework.config.Configurable;
8482
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
85-
import org.apache.cloudstack.storage.command.DettachCommand;
8683
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
84+
import org.apache.cloudstack.storage.command.DettachCommand;
8785
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
8886
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
8987
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
@@ -98,6 +96,8 @@
9896
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
9997
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
10098
import org.apache.cloudstack.storage.to.VolumeObjectTO;
99+
import org.apache.log4j.Logger;
100+
import org.springframework.stereotype.Component;
101101

102102
import com.cloud.agent.AgentManager;
103103
import com.cloud.agent.api.Answer;
@@ -887,11 +887,6 @@ public boolean deletePool(DeletePoolCmd cmd) {
887887
s_logger.warn("Unable to delete storage id: " + id + " due to it is not in Maintenance state");
888888
throw new InvalidParameterValueException("Unable to delete storage due to it is not in Maintenance state, id: " + id);
889889
}
890-
if (sPool.isLocal()) {
891-
s_logger.warn("Unable to delete local storage id:" + id);
892-
throw new InvalidParameterValueException("Unable to delete local storage id: " + id);
893-
}
894-
895890
Pair<Long, Long> vlms = _volsDao.getCountAndTotalByPool(id);
896891
if (forced) {
897892
if (vlms.first() > 0) {
@@ -1097,15 +1092,15 @@ public void cleanupStorage(boolean recurring) {
10971092
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
10981093
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
10991094
s_logger.debug("Storage pool garbage collector is skipping template with ID: " + templatePoolVO.getTemplateId() +
1100-
" on pool " + templatePoolVO.getPoolId() + " because it is not completely downloaded.");
1095+
" on pool " + templatePoolVO.getPoolId() + " because it is not completely downloaded.");
11011096
continue;
11021097
}
11031098

11041099
if (!templatePoolVO.getMarkedForGC()) {
11051100
templatePoolVO.setMarkedForGC(true);
11061101
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
11071102
s_logger.debug("Storage pool garbage collector has marked template with ID: " + templatePoolVO.getTemplateId() +
1108-
" on pool " + templatePoolVO.getPoolId() + " for garbage collection.");
1103+
" on pool " + templatePoolVO.getPoolId() + " for garbage collection.");
11091104
continue;
11101105
}
11111106

@@ -1523,8 +1518,6 @@ protected void runInContext() {
15231518

15241519
@Override
15251520
public void onManagementNodeJoined(List<? extends ManagementServerHost> nodeList, long selfNodeId) {
1526-
// TODO Auto-generated method stub
1527-
15281521
}
15291522

15301523
@Override
@@ -1915,21 +1908,6 @@ private HypervisorType getHypervisorType(Volume volume) {
19151908
return null;
19161909
}
19171910

1918-
private long getDataObjectSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool pool) {
1919-
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
1920-
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
1921-
1922-
if (storeDriver instanceof PrimaryDataStoreDriver) {
1923-
PrimaryDataStoreDriver primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver;
1924-
1925-
VolumeInfo volumeInfo = volFactory.getVolume(volume.getId());
1926-
1927-
return primaryStoreDriver.getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeInfo, pool);
1928-
}
1929-
1930-
return volume.getSize();
1931-
}
1932-
19331911
private long getBytesRequiredForTemplate(VMTemplateVO tmpl, StoragePool pool) {
19341912
DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(pool.getStorageProviderName());
19351913
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
@@ -1959,19 +1937,16 @@ public synchronized boolean registerHostListener(String providerName, Hypervisor
19591937

19601938
@Override
19611939
public Answer sendToPool(long poolId, Command cmd) throws StorageUnavailableException {
1962-
// TODO Auto-generated method stub
19631940
return null;
19641941
}
19651942

19661943
@Override
19671944
public Answer[] sendToPool(long poolId, Commands cmd) throws StorageUnavailableException {
1968-
// TODO Auto-generated method stub
19691945
return null;
19701946
}
19711947

19721948
@Override
19731949
public String getName() {
1974-
// TODO Auto-generated method stub
19751950
return null;
19761951
}
19771952

@@ -2034,7 +2009,7 @@ public ImageStore discoverImageStore(String name, String url, String providerNam
20342009
}
20352010
}
20362011

2037-
Map<String, Object> params = new HashMap();
2012+
Map<String, Object> params = new HashMap<>();
20382013
params.put("zoneId", zoneId);
20392014
params.put("url", url);
20402015
params.put("name", name);
@@ -2075,7 +2050,7 @@ public ImageStore discoverImageStore(String name, String url, String providerNam
20752050
}
20762051

20772052
@Override
2078-
public ImageStore migrateToObjectStore(String name, String url, String providerName, Map details) throws IllegalArgumentException, DiscoveryException,
2053+
public ImageStore migrateToObjectStore(String name, String url, String providerName, Map<String, String> details) throws DiscoveryException,
20792054
InvalidParameterValueException {
20802055
// check if current cloud is ready to migrate, we only support cloud with only NFS secondary storages
20812056
List<ImageStoreVO> imgStores = _imageStoreDao.listImageStores();
@@ -2342,7 +2317,7 @@ public void cleanupDownloadUrls(){
23422317
ImageStoreEntity secStore = (ImageStoreEntity) _dataStoreMgr.getDataStore(volumeOnImageStore.getDataStoreId(), DataStoreRole.Image);
23432318
secStore.deleteExtractUrl(volumeOnImageStore.getInstallPath(), volumeOnImageStore.getExtractUrl(), Upload.Type.VOLUME);
23442319

2345-
// Now expunge it from DB since this entry was created only for download purpose
2320+
// Now expunge it from DB since this entry was created only for download purpose
23462321
_volumeStoreDao.expunge(volumeOnImageStore.getId());
23472322
}catch(Throwable th){
23482323
s_logger.warn("Caught exception while deleting download url " +volumeOnImageStore.getExtractUrl() +

0 commit comments

Comments
 (0)