Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(linstor): pre-flight check destination is a LINSTOR satellite before live migration#13077
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
Merged
DaanHoogland
merged 1 commit into
apache:main
from
jmsperu:feature/linstor-migration-preflightMay 19, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61 ...linstor/src/main/java/org/apache/cloudstack/storage/motion/LinstorDataMotionStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -314,6 +314,58 @@ private boolean needsExactSizeProp(VolumeInfo srcVolumeInfo) { | ||
| return true; | ||
| } | ||
| /** | ||
| * Verify that the destination KVM host is a registered LINSTOR satellite on the controller | ||
| * backing every destination pool involved in this migration. Throws CloudRuntimeException | ||
| * with a clear message when it isn't, instead of letting the resource creation later fail | ||
| * obscurely inside auto-placement. | ||
| * | ||
| * Best-effort: a transient controller error during this check does not block the migration | ||
| * — we log a warning and let the downstream resource-create surface the real issue. Only a | ||
| * confirmed "host not in node list" outcome aborts the migration up-front. | ||
| */ | ||
| private void verifyDestinationIsLinstorSatellite(Map<VolumeInfo, DataStore> volumeDataStoreMap, Host destHost) { | ||
| if (destHost == null || destHost.getName() == null) { | ||
| // Without a destination host name to match, the only sensible thing is to let the | ||
| // existing flow run and report whatever it would have reported. | ||
| return; | ||
| } | ||
| for (Map.Entry<VolumeInfo, DataStore> entry : volumeDataStoreMap.entrySet()) { | ||
| DataStore destDataStore = entry.getValue(); | ||
| StoragePoolVO destStoragePool = _storagePool.findById(destDataStore.getId()); | ||
| if (destStoragePool == null | ||
| || destStoragePool.getPoolType() != Storage.StoragePoolType.Linstor) { | ||
| continue; | ||
| } | ||
| DevelopersApi api = LinstorUtil.getLinstorAPI(destStoragePool.getHostAddress()); | ||
| try { | ||
| List<String> nodes = LinstorUtil.getLinstorNodeNames(api); | ||
| if (nodes == null) { | ||
| logger.warn("LINSTOR controller {} returned null node list; skipping pre-flight", | ||
| destStoragePool.getHostAddress()); | ||
| return; | ||
| } | ||
| if (!nodes.contains(destHost.getName())) { | ||
| throw new CloudRuntimeException(String.format( | ||
| "Cannot migrate to host '%s': it is not a registered LINSTOR satellite on " + | ||
| "controller %s (pool '%s'). Known satellites: %s. Either register the " + | ||
| "host with `linstor node create` or pick a different destination.", | ||
| destHost.getName(), | ||
| destStoragePool.getHostAddress(), | ||
| destStoragePool.getName(), | ||
| nodes)); | ||
| } | ||
| } catch (ApiException apiEx) { | ||
| // Don't block migration on a transient controller hiccup — log and let the | ||
| // downstream resource creation handle the real failure. | ||
| logger.warn("LINSTOR pre-flight check could not contact controller {}: {}; " + | ||
| "letting downstream resource creation proceed", | ||
| destStoragePool.getHostAddress(), apiEx.getBestMessage()); | ||
| return; | ||
| } | ||
rp- marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| } | ||
| @Override | ||
| public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMachineTO vmTO, Host srcHost, | ||
| Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) { | ||
| @@ -323,6 +375,15 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach | ||
| String.format("Invalid hypervisor type [%s]. Only KVM supported", srcHost.getHypervisorType())); | ||
| } | ||
| // Pre-flight: verify the destination KVM host is registered as a satellite on the | ||
| // LINSTOR controller backing each destination pool. Without this check, resource | ||
| // creation falls through to the resource-group's auto-placement filters and may | ||
| // either silently place the resource on the wrong node or fail with an opaque | ||
| // auto-place error from the LINSTOR API. Failing fast here gives operators a clear | ||
| // actionable message instead of having to correlate the live-migration failure with | ||
| // an unrelated LINSTOR controller log entry. | ||
| verifyDestinationIsLinstorSatellite(volumeDataStoreMap, destHost); | ||
rp- marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| String errMsg = null; | ||
| VMInstanceVO vmInstance = _vmDao.findById(vmTO.getId()); | ||
| vmTO.setState(vmInstance.getState()); | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.