You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2024/09/04 08:09:53 UTC
(cloudstack) 01/02: Merge remote-tracking branch 'origin/4.19'
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 60c9c9adb6723cdff0b1f66002886f7faad56579
Merge: 39152323e3b a851ee375c1
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Wed Sep 4 12:38:07 2024 +0530
Merge remote-tracking branch 'origin/4.19'
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
.../api/response/StoragePoolResponse.java | 12 +++++
.../storage/image/TemplateServiceImpl.java | 5 --
plugins/storage/volume/linstor/CHANGELOG.md | 12 +++++
.../kvm/storage/LinstorStorageAdaptor.java | 57 +++++++++++++++-------
.../storage/datastore/util/LinstorUtil.java | 11 +++--
.../api/query/dao/StoragePoolJoinDaoImpl.java | 13 +++++
.../configuration/ConfigurationManagerImpl.java | 14 ++++++
.../com/cloud/storage/VolumeApiServiceImpl.java | 6 ++-
.../apache/cloudstack/snapshot/SnapshotHelper.java | 22 ++++++---
.../SecondaryStorageManagerImpl.java | 5 ++
systemvm/debian/opt/cloud/bin/cs/CsFile.py | 1 -
systemvm/debian/opt/cloud/bin/cs_vpnusers.py | 2 -
ui/src/views/setting/ConfigurationValue.vue | 2 +-
.../main/java/com/cloud/utils/net/NetUtils.java | 12 +++++
.../java/com/cloud/utils/net/NetUtilsTest.java | 11 +++++
15 files changed, 145 insertions(+), 40 deletions(-)
diff --cc engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index 39d4618f81c,c040e1a7ad6..518a3869833
--- a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@@ -530,14 -529,9 +530,9 @@@ public class TemplateServiceImpl implem
// download.
for (VMTemplateVO tmplt : toBeDownloaded) {
if (tmplt.getUrl() == null) { // If url is null, skip downloading
- s_logger.info("Skip downloading template " + tmplt.getUniqueName() + " since no url is specified.");
+ logger.info("Skip downloading template " + tmplt.getUniqueName() + " since no url is specified.");
continue;
}
- // if this is private template, skip sync to a new image store
- if (isSkipTemplateStoreDownload(tmplt, zoneId)) {
- logger.info("Skip sync downloading private template " + tmplt.getUniqueName() + " to a new image store");
- continue;
- }
// if this is a region store, and there is already an DOWNLOADED entry there without install_path information, which
// means that this is a duplicate entry from migration of previous NFS to staging.
diff --cc plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java
index 5d037d63433,83a84a91622..cc411543c44
--- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java
+++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java
@@@ -242,15 -239,19 +244,19 @@@ public class LinstorStorageAdaptor impl
* @throws ApiException if any problem connecting to the Linstor controller
*/
private void allow2PrimariesIfInUse(DevelopersApi api, String rscName) throws ApiException {
- if (LinstorUtil.isResourceInUse(api, rscName)) {
+ String inUseNode = LinstorUtil.isResourceInUse(api, rscName);
+ if (inUseNode != null && !inUseNode.equalsIgnoreCase(localNodeName)) {
// allow 2 primaries for live migration, should be removed by disconnect on the other end
- ResourceDefinitionModify rdm = new ResourceDefinitionModify();
+ ResourceConnectionModify rcm = new ResourceConnectionModify();
Properties props = new Properties();
props.put("DrbdOptions/Net/allow-two-primaries", "yes");
- rdm.setOverrideProps(props);
- ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm);
+ props.put("DrbdOptions/Net/protocol", "C");
+ rcm.setOverrideProps(props);
+ ApiCallRcList answers = api.resourceConnectionModify(rscName, inUseNode, localNodeName, rcm);
if (answers.hasError()) {
- logger.error("Unable to set 'allow-two-primaries' on {} ", rscName);
- s_logger.error(String.format(
++ logger.error(String.format(
+ "Unable to set protocol C and 'allow-two-primaries' on %s/%s/%s",
+ inUseNode, localNodeName, rscName));
// do not fail here as adding allow-two-primaries property is only a problem while live migrating
}
}
@@@ -290,6 -291,23 +296,23 @@@
return true;
}
+ private void removeTwoPrimariesRcProps(DevelopersApi api, String inUseNode, String rscName) throws ApiException {
+ ResourceConnectionModify rcm = new ResourceConnectionModify();
+ List<String> deleteProps = new ArrayList<>();
+ deleteProps.add("DrbdOptions/Net/allow-two-primaries");
+ deleteProps.add("DrbdOptions/Net/protocol");
+ rcm.deleteProps(deleteProps);
+ ApiCallRcList answers = api.resourceConnectionModify(rscName, localNodeName, inUseNode, rcm);
+ if (answers.hasError()) {
- s_logger.error(
++ logger.error(
+ String.format("Failed to remove 'protocol' and 'allow-two-primaries' on %s/%s/%s: %s",
+ localNodeName,
+ inUseNode,
+ rscName, LinstorUtil.getBestErrorMessage(answers)));
+ // do not fail here as removing allow-two-primaries property isn't fatal
+ }
+ }
+
private boolean tryDisconnectLinstor(String volumePath, KVMStoragePool pool)
{
if (volumePath == null) {
@@@ -319,9 -337,18 +342,18 @@@
if (optRsc.isPresent()) {
+ Resource rsc = optRsc.get();
try {
- Resource rsc = optRsc.get();
+ String inUseNode = LinstorUtil.isResourceInUse(api, rsc.getName());
+ if (inUseNode != null && !inUseNode.equalsIgnoreCase(localNodeName)) {
+ removeTwoPrimariesRcProps(api, inUseNode, rsc.getName());
+ }
+ } catch (ApiException apiEx) {
- s_logger.error(apiEx.getBestMessage());
++ logger.error(apiEx.getBestMessage());
+ // do not fail here as removing allow-two-primaries property or deleting diskless isn't fatal
+ }
+ try {
// if diskless resource remove it, in the worst case it will be transformed to a tiebreaker
if (rsc.getFlags() != null &&
rsc.getFlags().contains(ApiConsts.FLAG_DRBD_DISKLESS) &&
@@@ -329,19 -356,8 +361,8 @@@
ApiCallRcList delAnswers = api.resourceDelete(rsc.getName(), localNodeName);
logLinstorAnswers(delAnswers);
}
-
- // remove allow-two-primaries
- ResourceDefinitionModify rdm = new ResourceDefinitionModify();
- rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries"));
- ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm);
- if (answers.hasError()) {
- logger.error(
- String.format("Failed to remove 'allow-two-primaries' on %s: %s",
- rsc.getName(), LinstorUtil.getBestErrorMessage(answers)));
- // do not fail here as removing allow-two-primaries property isn't fatal
- }
} catch (ApiException apiEx) {
- s_logger.error(apiEx.getBestMessage());
+ logger.error(apiEx.getBestMessage());
// do not fail here as removing allow-two-primaries property or deleting diskless isn't fatal
}
diff --cc plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
index 8fdba049603,b857b4ebb83..49b8655ed63
--- a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
+++ b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
@@@ -199,10 -198,13 +199,13 @@@ public class LinstorUtil
List<Resource> rscs = api.resourceList(rscName, null, null);
if (rscs != null) {
return rscs.stream()
- .anyMatch(rsc -> rsc.getState() != null && Boolean.TRUE.equals(rsc.getState().isInUse()));
+ .filter(rsc -> rsc.getState() != null && Boolean.TRUE.equals(rsc.getState().isInUse()))
+ .map(Resource::getNodeName)
+ .findFirst()
+ .orElse(null);
- }
- s_logger.error("isResourceInUse: null returned from resourceList");
+ }
+ LOGGER.error("isResourceInUse: null returned from resourceList");
- return false;
+ return null;
}
/**
diff --cc server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
index fce4b3496fc,9df33b47257..47be195ad23
--- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
@@@ -307,7 -303,10 +307,9 @@@ import com.google.common.base.Precondit
import com.google.common.collect.Sets;
import com.googlecode.ipv6.IPv6Network;
+ import static com.cloud.configuration.Config.SecStorageAllowedInternalDownloadSites;
+
public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, Configurable {
- public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class);
public static final String PERACCOUNT = "peraccount";
public static final String PERZONE = "perzone";
@@@ -1320,6 -1316,18 +1322,18 @@@
}
}
+ if (type.equals(String.class)) {
+ if (name.equalsIgnoreCase(SecStorageAllowedInternalDownloadSites.key()) && StringUtils.isNotEmpty(value)) {
+ final String[] cidrs = value.split(",");
+ for (final String cidr : cidrs) {
+ if (!NetUtils.isValidIp4(cidr) && !NetUtils.isValidIp6(cidr) && !NetUtils.getCleanIp4Cidr(cidr).equals(cidr)) {
- s_logger.error(String.format("Invalid CIDR %s value specified for the config %s", cidr, name));
++ logger.error(String.format("Invalid CIDR %s value specified for the config %s", cidr, name));
+ throw new InvalidParameterValueException(String.format("Invalid CIDR %s value specified for the config %s", cidr, name));
+ }
+ }
+ }
+ }
+
if (configuration == null ) {
//range validation has to be done per case basis, for now
//return in case of Configkey parameters
diff --cc services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 08af3ee02eb,cd6f23923e1..ec1e8a81979
--- a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@@ -399,6 -403,9 +401,9 @@@ public class SecondaryStorageManagerImp
String[] cidrs = _allowedInternalSites.split(",");
for (String cidr : cidrs) {
if (NetUtils.isValidIp4Cidr(cidr) || NetUtils.isValidIp4(cidr) || !cidr.startsWith("0.0.0.0")) {
+ if (NetUtils.getCleanIp4Cidr(cidr).equals(cidr)) {
- s_logger.warn(String.format("Invalid CIDR %s in %s", cidr, SecStorageAllowedInternalDownloadSites.key()));
++ logger.warn(String.format("Invalid CIDR %s in %s", cidr, SecStorageAllowedInternalDownloadSites.key()));
+ }
allowedCidrs.add(cidr);
}
}