@@ -43,8 +43,7 @@ public class LocalStorageMainAllocatorFlow extends NoRollbackFlow {
4343
4444 private class Result {
4545 List <PrimaryStorageVO > result ;
46- String errStr ;
47- List <ErrorCode > causes = new ArrayList <>();
46+ ErrorCode errorCode ;
4847 }
4948
5049 @ Transactional (readOnly = true )
@@ -77,7 +76,7 @@ private Result allocate(Map data) {
7776 query .setParameter ("hstate" , HostState .Enabled );
7877 query .setParameter ("hstatus" , HostStatus .Connected );
7978 query .setParameter ("ptype" , LocalStorageConstants .LOCAL_STORAGE_TYPE );
80- ret .errStr = i18n ("the required host[uuid:%s] cannot satisfy conditions[state: %s, status: %s, size > %s bytes]," +
79+ ret .errorCode = operr ("the required host[uuid:%s] cannot satisfy conditions[state: %s, status: %s, size > %s bytes]," +
8180 " or doesn't belong to a local primary storage satisfying conditions[state: %s, status: %s]," +
8281 " or its cluster doesn't attach to any local primary storage" ,
8382 spec .getRequiredHostUuid (),
@@ -105,7 +104,7 @@ private Result allocate(Map data) {
105104 query .setParameter ("hstate" , HostState .Enabled );
106105 query .setParameter ("hstatus" , HostStatus .Connected );
107106 query .setParameter ("ptype" , LocalStorageConstants .LOCAL_STORAGE_TYPE );
108- ret .errStr = i18n ("no local primary storage in zone[uuid:%s] can satisfy conditions[state: %s, status: %s]" +
107+ ret .errorCode = operr ("no local primary storage in zone[uuid:%s] can satisfy conditions[state: %s, status: %s]" +
109108 " or contain hosts satisfying conditions[state: %s, status: %s, size > %s bytes]" ,
110109 spec .getRequiredZoneUuid (),
111110 PrimaryStorageState .Enabled ,
@@ -131,7 +130,7 @@ private Result allocate(Map data) {
131130 query .setParameter ("hstatus" , HostStatus .Connected );
132131 query .setParameter ("ptype" , LocalStorageConstants .LOCAL_STORAGE_TYPE );
133132
134- ret .errStr = i18n ("no local primary storage can satisfy conditions[state: %s, status: %s]" +
133+ ret .errorCode = operr ("no local primary storage can satisfy conditions[state: %s, status: %s]" +
135134 " or contain hosts satisfying conditions[state: %s, status: %s, size > %s bytes]" ,
136135 PrimaryStorageState .Enabled ,
137136 PrimaryStorageStatus .Connected ,
@@ -173,13 +172,13 @@ private Result allocate(Map data) {
173172 LocalStorageHostRefVO ref = it .next ();
174173 if (!physicalCapacityMgr .checkCapacityByRatio (ref .getPrimaryStorageUuid (), ref .getTotalPhysicalCapacity (), ref .getAvailablePhysicalCapacity ())
175174 || !physicalCapacityMgr .checkRequiredCapacityByRatio (ref .getPrimaryStorageUuid (), ref .getTotalPhysicalCapacity (), spec .getTotalSize ())) {
176- ret . causes .add (operr ("{the physical capacity usage of the host[uuid:%s] has exceeded the threshold[%s]}" ,
175+ errs .add (operr ("{the physical capacity usage of the host[uuid:%s] has exceeded the threshold[%s]}" ,
177176 ref .getHostUuid (), physicalCapacityMgr .getRatio (ref .getPrimaryStorageUuid ())));
178177 it .remove ();
179178 }
180179 }
181180 if (candidateHosts .isEmpty ()) {
182- ret .errStr = i18n ("failed allocate localstorage" );
181+ ret .errorCode = operr ("failed allocate localstorage" ). withCause ( errs );
183182 }
184183 }
185184 Set <String > candidates = new HashSet <>();
@@ -289,7 +288,7 @@ public void run(FlowTrigger trigger, Map data) {
289288 return ;
290289 }
291290
292- ErrorCode err = ret .causes . isEmpty () ? operr ( ret . errStr ) : multiErr ( ret . causes , ret . errStr ) ;
291+ ErrorCode err = ret .errorCode ;
293292 trigger .fail (err );
294293 }
295294}
0 commit comments