-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[SolidFire] Fix inter-cluster VM migrations on zone-wide SolidFire pools #11633
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
Changes from all commits
b4c39ad
8b0b163
56241d3
e0e84ba
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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // | ||
| package com.cloud.agent.api; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class UnmountDatastoresCommand extends Command { | ||
| private List<String> datastorePools; | ||
|
|
||
| public UnmountDatastoresCommand() { | ||
|
|
||
| } | ||
|
|
||
| public UnmountDatastoresCommand(List<String> datastorePools) { | ||
| this.datastorePools = datastorePools; | ||
| } | ||
|
|
||
| public List<String> getDatastorePools() { | ||
| return datastorePools; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean executeInSequence() { | ||
| return false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,8 +49,10 @@ | |||||||||||||||||||||||||
| import javax.naming.ConfigurationException; | ||||||||||||||||||||||||||
| import javax.xml.datatype.XMLGregorianCalendar; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import com.cloud.agent.api.UnmountDatastoresCommand; | ||||||||||||||||||||||||||
| import com.cloud.capacity.CapacityManager; | ||||||||||||||||||||||||||
| import com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO; | ||||||||||||||||||||||||||
| import com.cloud.storage.ScopeType; | ||||||||||||||||||||||||||
| import com.vmware.vim25.FileInfo; | ||||||||||||||||||||||||||
| import com.vmware.vim25.FileQueryFlags; | ||||||||||||||||||||||||||
| import com.vmware.vim25.FolderFileInfo; | ||||||||||||||||||||||||||
|
|
@@ -74,6 +76,7 @@ | |||||||||||||||||||||||||
| import org.apache.commons.collections.CollectionUtils; | ||||||||||||||||||||||||||
| import org.apache.commons.collections.MapUtils; | ||||||||||||||||||||||||||
| import org.apache.commons.lang.ArrayUtils; | ||||||||||||||||||||||||||
| import org.apache.commons.lang.BooleanUtils; | ||||||||||||||||||||||||||
| import org.apache.commons.lang.math.NumberUtils; | ||||||||||||||||||||||||||
| import org.apache.commons.lang3.StringUtils; | ||||||||||||||||||||||||||
| import org.apache.log4j.Logger; | ||||||||||||||||||||||||||
|
|
@@ -619,6 +622,8 @@ public Answer executeRequest(Command cmd) { | |||||||||||||||||||||||||
| answer = execute((ListDataStoreObjectsCommand) cmd); | ||||||||||||||||||||||||||
| } else if (clz == PrepareForBackupRestorationCommand.class) { | ||||||||||||||||||||||||||
| answer = execute((PrepareForBackupRestorationCommand) cmd); | ||||||||||||||||||||||||||
| } else if (clz == UnmountDatastoresCommand.class) { | ||||||||||||||||||||||||||
| answer = execute((UnmountDatastoresCommand) cmd); | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| answer = Answer.createUnsupportedCommandAnswer(cmd); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
@@ -4624,6 +4629,11 @@ protected Answer execute(PrepareForMigrationCommand cmd) { | |||||||||||||||||||||||||
| prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic, false, cmd.getVirtualMachine().getType()); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| DiskTO[] disks = vm.getDisks(); | ||||||||||||||||||||||||||
| for (DiskTO disk : disks) { | ||||||||||||||||||||||||||
| prepareDatastoreForZoneWideManagedStorageInterClusterMigration(disk, hyperHost); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| List<Pair<String, Long>> secStoreUrlAndIdList = mgr.getSecondaryStorageStoresUrlAndIdList(Long.parseLong(_dcId)); | ||||||||||||||||||||||||||
| for (Pair<String, Long> secStoreUrlAndId : secStoreUrlAndIdList) { | ||||||||||||||||||||||||||
| String secStoreUrl = secStoreUrlAndId.first(); | ||||||||||||||||||||||||||
|
|
@@ -4645,6 +4655,29 @@ protected Answer execute(PrepareForMigrationCommand cmd) { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private void prepareDatastoreForZoneWideManagedStorageInterClusterMigration(DiskTO disk, VmwareHypervisorHost hyperHost) throws Exception { | ||||||||||||||||||||||||||
weizhouapache marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| Map<String, String> details = disk.getDetails(); | ||||||||||||||||||||||||||
| if (MapUtils.isEmpty(details) || !details.containsKey(DiskTO.SCOPE) || | ||||||||||||||||||||||||||
| !details.containsKey(DiskTO.MANAGED) && !details.containsKey(DiskTO.INTER_CLUSTER_MIGRATION)) { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| !details.containsKey(DiskTO.MANAGED) && !details.containsKey(DiskTO.INTER_CLUSTER_MIGRATION)) { | |
| (!details.containsKey(DiskTO.MANAGED) || !details.containsKey(DiskTO.INTER_CLUSTER_MIGRATION))) { |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a potential NumberFormatException if details.get(DiskTO.STORAGE_PORT) returns null or a non-numeric value. While the comment on line 4672 suggests details should not be null for managed storage, there's no explicit validation that STORAGE_PORT is present or valid before parsing. Consider adding a null check and validation before calling Integer.parseInt().
| _storageProcessor.prepareManagedDatastore(context, hyperHost, datastoreName, | |
| details.get(DiskTO.IQN), details.get(DiskTO.STORAGE_HOST), | |
| Integer.parseInt(details.get(DiskTO.STORAGE_PORT))); | |
| String storagePortString = details.get(DiskTO.STORAGE_PORT); | |
| if (StringUtils.isBlank(storagePortString) || !NumberUtils.isDigits(storagePortString)) { | |
| s_logger.warn(String.format("Skipping preparation of managed datastore %s due to invalid storage port value: %s", | |
| datastoreName, storagePortString)); | |
| return; | |
| } | |
| int storagePort = Integer.parseInt(storagePortString); | |
| _storageProcessor.prepareManagedDatastore(context, hyperHost, datastoreName, | |
| details.get(DiskTO.IQN), details.get(DiskTO.STORAGE_HOST), storagePort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing a RuntimeException wrapping AgentUnavailableException or OperationTimedoutException may cause the entire migration to fail unexpectedly. Consider logging the error and handling it gracefully instead of propagating it as a RuntimeException, since this is a cleanup operation that happens after the VM has successfully migrated. The migration has already succeeded at this point (line 2887), so failing here could leave the system in an inconsistent state.