Repository navigation
Prevent downloading templates to secondary storages that are in read-only
#13023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.20
Are you sure you want to change the base?
Changes from all commits
0d2f3d6
c6ff0f2
d46b59e
939e488
0e46501
0ddd00f
40e82c2
b1905ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ | |
| import org.apache.cloudstack.storage.command.DeleteCommand; | ||
| import org.apache.cloudstack.storage.datastore.DataObjectManager; | ||
| import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; | ||
| import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; | ||
| import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; | ||
| import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; | ||
| import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity; | ||
|
|
@@ -163,6 +164,8 @@ public class TemplateServiceImpl implements TemplateService { | |
| TemplateDataFactory imageFactory; | ||
| @Inject | ||
| StorageOrchestrationService storageOrchestrator; | ||
| @Inject | ||
| ImageStoreDao imageStoreDao; | ||
|
|
||
| class TemplateOpContext<T> extends AsyncRpcContext<T> { | ||
| final TemplateObject template; | ||
|
|
@@ -295,10 +298,14 @@ public void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId) { | |
| } | ||
|
|
||
| protected boolean shouldDownloadTemplateToStore(VMTemplateVO template, DataStore store) { | ||
| if (_storeMgr.isRemovedOrReadonly(store)) { | ||
| return false; | ||
| } | ||
|
GaOrtiga marked this conversation as resolved.
|
||
|
|
||
| Long zoneId = store.getScope().getScopeId(); | ||
| DataStore directedStore = _tmpltMgr.verifyHeuristicRulesForZone(template, zoneId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens to the template sync when the rule points at a read-only store? looks like this now throws mid loop and the rest of the templates for that store get skipped |
||
| if (directedStore != null && store.getId() != directedStore.getId()) { | ||
| logger.info("Template [{}] will not be download to image store [{}], as a heuristic rule is directing it to another store.", | ||
| logger.info("Template [{}] will not be downloaded to image store [{}], as a heuristic rule is directing it to another store.", | ||
| template.getUniqueName(), store.getName()); | ||
| return false; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,6 +272,10 @@ public DataStore interpretHeuristicRule(String rule, HeuristicType heuristicType | |
| "returning a valid UUID.", scriptReturn, rule)); | ||
| } | ||
|
|
||
| if (dataStoreManager.isRemovedOrReadonly(dataStore)) { | ||
| throw new CloudRuntimeException(String.format("DataStore [{}] returned by heuristic rule is marked as read-only.", dataStore)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be %s instead of {}? String.format leaves the {} as is so the store never shows up in the error |
||
| } | ||
|
|
||
| return dataStore; | ||
| } catch (IOException ex) { | ||
| String message = String.format("Error while executing script [%s].", rule); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.