Skip to content

Commit 3134efb

Browse files
authored
plugin-swift: handle null cache store (apache#11380)
Fixes apache#11315 (review) Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 1bfebd5 commit 3134efb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424

2525
import javax.inject.Inject;
2626

27-
import com.cloud.configuration.Config;
28-
import com.cloud.utils.SwiftUtil;
29-
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
30-
import org.apache.log4j.Logger;
31-
3227
import org.apache.cloudstack.api.ApiConstants;
3328
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
3429
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@@ -38,18 +33,21 @@
3833
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
3934
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
4035
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
36+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4137
import org.apache.cloudstack.storage.command.DownloadCommand;
4238
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
4339
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
4440
import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
4541
import org.apache.cloudstack.storage.to.TemplateObjectTO;
42+
import org.apache.log4j.Logger;
4643

4744
import com.cloud.agent.api.storage.DownloadAnswer;
4845
import com.cloud.agent.api.to.DataObjectType;
4946
import com.cloud.agent.api.to.DataStoreTO;
5047
import com.cloud.agent.api.to.SwiftTO;
48+
import com.cloud.configuration.Config;
5149
import com.cloud.storage.Storage.ImageFormat;
52-
import com.cloud.template.VirtualMachineTemplate;
50+
import com.cloud.utils.SwiftUtil;
5351
import com.cloud.utils.exception.CloudRuntimeException;
5452

5553
public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
@@ -101,8 +99,13 @@ public String createEntityExtractUrl(DataStore store, String installPath, ImageF
10199
@Override
102100
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
103101
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
104-
VirtualMachineTemplate tmpl = _templateDao.findById(data.getId());
105102
DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
103+
if (cacheStore == null) {
104+
String errMsg = String.format("No cache store found for scope: %s",
105+
dataStore.getScope().getScopeType().name());
106+
s_logger.error(errMsg);
107+
throw new CloudRuntimeException(errMsg);
108+
}
106109
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
107110
dcmd.setCacheStore(cacheStore.getTO());
108111
dcmd.setProxy(getHttpProxy());

0 commit comments

Comments
 (0)