Skip to content

Commit 0ddd00f

Browse files
committed
address fabricios review + address heuristics
1 parent 0e46501 commit 0ddd00f

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.apache.cloudstack.storage.command.CommandResult;
4545
import org.apache.cloudstack.storage.command.CopyCommand;
4646
import org.apache.cloudstack.storage.command.DeleteCommand;
47-
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
4847
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
4948
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
5049
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
@@ -127,8 +126,6 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
127126
AgentManager agentMgr;
128127
@Inject
129128
DataStoreManager dataStoreManager;
130-
@Inject
131-
ImageStoreDao imageStoreDao;
132129

133130
protected String _proxy = null;
134131

@@ -178,13 +175,10 @@ public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCal
178175
AsyncCallbackDispatcher<BaseImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this);
179176
caller.setContext(context);
180177
if (data.getType() == DataObjectType.TEMPLATE) {
181-
if (dataStoreManager.isRemovedOrReadonly(dataStore)) {
182-
DownloadAnswer ans = new DownloadAnswer("Data store is removed or in read-only mode", VMTemplateStorageResourceAssoc.Status.UNKNOWN);
183-
caller.complete(ans);
184-
return;
185-
}
186178
caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null));
187-
logger.debug("Downloading template [{}] to data store [{}].", data.getName(), dataStore.getName());
179+
if (logger.isDebugEnabled()) {
180+
logger.debug("Downloading template to data store {}", dataStore);
181+
}
188182
_downloadMonitor.downloadTemplateToStorage(data, caller);
189183
} else if (data.getType() == DataObjectType.VOLUME) {
190184
caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));

server/src/main/java/org/apache/cloudstack/storage/heuristics/HeuristicRuleHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public DataStore interpretHeuristicRule(String rule, HeuristicType heuristicType
272272
"returning a valid UUID.", scriptReturn, rule));
273273
}
274274

275+
if (dataStoreManager.isRemovedOrReadonly(dataStore)) {
276+
throw new CloudRuntimeException(String.format("DataStore [{}] returned by heuristic rule is marked as read-only.", dataStore));
277+
}
278+
275279
return dataStore;
276280
} catch (IOException ex) {
277281
String message = String.format("Error while executing script [%s].", rule);

0 commit comments

Comments
 (0)