|
21 | 21 | import java.io.InputStreamReader; |
22 | 22 |
|
23 | 23 | import java.util.ArrayList; |
| 24 | +import java.util.Arrays; |
24 | 25 | import java.util.Collections; |
25 | 26 | import java.util.HashMap; |
26 | 27 | import java.util.List; |
|
53 | 54 | import com.linbit.linstor.api.model.ResourceConnectionModify; |
54 | 55 | import com.linbit.linstor.api.model.ResourceDefinition; |
55 | 56 | import com.linbit.linstor.api.model.ResourceGroup; |
| 57 | +import com.linbit.linstor.api.model.ResourceDefinitionModify; |
56 | 58 | import com.linbit.linstor.api.model.ResourceGroupSpawn; |
57 | 59 | import com.linbit.linstor.api.model.ResourceMakeAvailable; |
58 | 60 | import com.linbit.linstor.api.model.ResourceWithVolumes; |
@@ -268,17 +270,33 @@ private void allow2PrimariesIfInUse(DevelopersApi api, String rscName) throws Ap |
268 | 270 | String inUseNode = LinstorUtil.isResourceInUse(api, rscName); |
269 | 271 | if (inUseNode != null && !inUseNode.equalsIgnoreCase(localNodeName)) { |
270 | 272 | // allow 2 primaries for live migration, should be removed by disconnect on the other end |
271 | | - ResourceConnectionModify rcm = new ResourceConnectionModify(); |
272 | | - Properties props = new Properties(); |
273 | | - props.put("DrbdOptions/Net/allow-two-primaries", "yes"); |
274 | | - props.put("DrbdOptions/Net/protocol", "C"); |
275 | | - rcm.setOverrideProps(props); |
276 | | - ApiCallRcList answers = api.resourceConnectionModify(rscName, inUseNode, localNodeName, rcm); |
277 | | - if (answers.hasError()) { |
278 | | - s_logger.error(String.format( |
279 | | - "Unable to set protocol C and 'allow-two-primaries' on %s/%s/%s", |
280 | | - inUseNode, localNodeName, rscName)); |
281 | | - // do not fail here as adding allow-two-primaries property is only a problem while live migrating |
| 273 | + |
| 274 | + // if non hyperconverged setup, we have to set allow-two-primaries on the resource-definition |
| 275 | + // as there is no resource connection between diskless nodes. |
| 276 | + if (LinstorUtil.areResourcesDiskless(api, rscName, Arrays.asList(inUseNode, localNodeName))) { |
| 277 | + ResourceDefinitionModify rdm = new ResourceDefinitionModify(); |
| 278 | + Properties props = new Properties(); |
| 279 | + props.put("DrbdOptions/Net/allow-two-primaries", "yes"); |
| 280 | + props.put("DrbdOptions/Net/protocol", "C"); |
| 281 | + rdm.setOverrideProps(props); |
| 282 | + ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm); |
| 283 | + if (answers.hasError()) { |
| 284 | + s_logger.error(String.format("Unable to set protocol C and 'allow-two-primaries' on %s", rscName)); |
| 285 | + // do not fail here as adding allow-two-primaries property is only a problem while live migrating |
| 286 | + } |
| 287 | + } else { |
| 288 | + ResourceConnectionModify rcm = new ResourceConnectionModify(); |
| 289 | + Properties props = new Properties(); |
| 290 | + props.put("DrbdOptions/Net/allow-two-primaries", "yes"); |
| 291 | + props.put("DrbdOptions/Net/protocol", "C"); |
| 292 | + rcm.setOverrideProps(props); |
| 293 | + ApiCallRcList answers = api.resourceConnectionModify(rscName, inUseNode, localNodeName, rcm); |
| 294 | + if (answers.hasError()) { |
| 295 | + s_logger.error(String.format( |
| 296 | + "Unable to set protocol C and 'allow-two-primaries' on %s/%s/%s", |
| 297 | + inUseNode, localNodeName, rscName)); |
| 298 | + // do not fail here as adding allow-two-primaries property is only a problem while live migrating |
| 299 | + } |
282 | 300 | } |
283 | 301 | } |
284 | 302 | } |
@@ -318,19 +336,34 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S |
318 | 336 | } |
319 | 337 |
|
320 | 338 | private void removeTwoPrimariesRcProps(DevelopersApi api, String inUseNode, String rscName) throws ApiException { |
321 | | - ResourceConnectionModify rcm = new ResourceConnectionModify(); |
322 | 339 | List<String> deleteProps = new ArrayList<>(); |
323 | 340 | deleteProps.add("DrbdOptions/Net/allow-two-primaries"); |
324 | 341 | deleteProps.add("DrbdOptions/Net/protocol"); |
325 | | - rcm.deleteProps(deleteProps); |
326 | | - ApiCallRcList answers = api.resourceConnectionModify(rscName, localNodeName, inUseNode, rcm); |
327 | | - if (answers.hasError()) { |
328 | | - s_logger.error( |
329 | | - String.format("Failed to remove 'protocol' and 'allow-two-primaries' on %s/%s/%s: %s", |
330 | | - localNodeName, |
331 | | - inUseNode, |
332 | | - rscName, LinstorUtil.getBestErrorMessage(answers))); |
333 | | - // do not fail here as removing allow-two-primaries property isn't fatal |
| 342 | + |
| 343 | + { |
| 344 | + ResourceDefinitionModify rdm = new ResourceDefinitionModify(); |
| 345 | + rdm.deleteProps(deleteProps); |
| 346 | + ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm); |
| 347 | + if (answers.hasError()) { |
| 348 | + s_logger.error( |
| 349 | + String.format("Failed to remove 'protocol' and 'allow-two-primaries' on %s: %s", |
| 350 | + rscName, LinstorUtil.getBestErrorMessage(answers))); |
| 351 | + // do not fail here as removing allow-two-primaries property isn't fatal |
| 352 | + } |
| 353 | + } |
| 354 | + |
| 355 | + { |
| 356 | + ResourceConnectionModify rcm = new ResourceConnectionModify(); |
| 357 | + rcm.deleteProps(deleteProps); |
| 358 | + ApiCallRcList answers = api.resourceConnectionModify(rscName, localNodeName, inUseNode, rcm); |
| 359 | + if (answers.hasError()) { |
| 360 | + s_logger.error( |
| 361 | + String.format("Failed to remove 'protocol' and 'allow-two-primaries' on %s/%s/%s: %s", |
| 362 | + localNodeName, |
| 363 | + inUseNode, |
| 364 | + rscName, LinstorUtil.getBestErrorMessage(answers))); |
| 365 | + // do not fail here as removing allow-two-primaries property isn't fatal |
| 366 | + } |
334 | 367 | } |
335 | 368 | } |
336 | 369 |
|
|
0 commit comments