This is an automated email from the ASF dual-hosted git repository. dahn pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit f7b7339bcfb2aeb2c5d5efc30c4b855da28ff359 Merge: 8af08ddafbc 5b7c86aa452 Author: Daan Hoogland <d...@onecht.net> AuthorDate: Thu Nov 7 11:33:50 2024 +0100 Merge branch '4.19' .../motion/StorageSystemDataMotionStrategy.java | 5 +- .../LibvirtOvsFetchInterfaceCommandWrapper.java | 2 +- .../kvm/storage/LinstorStorageAdaptor.java | 77 +++++++++++++++++----- .../storage/datastore/util/LinstorUtil.java | 24 +++++++ systemvm/debian/opt/cloud/bin/cs/CsFile.py | 2 +- ui/src/config/section/compute.js | 2 +- ui/src/views/compute/KubernetesServiceTab.vue | 2 +- utils/src/main/java/com/cloud/utils/HttpUtils.java | 4 +- .../test/java/com/cloud/utils/HttpUtilsTest.java | 6 +- 9 files changed, 98 insertions(+), 26 deletions(-) diff --cc plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java index 923c44f4828,d2823334a8c..9ecdfddc2ad --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java @@@ -89,9 -92,9 +89,9 @@@ public final class LibvirtOvsFetchInter @Override public Answer execute(final OvsFetchInterfaceCommand command, final LibvirtComputingResource libvirtComputingResource) { - final String label = "'" + command.getLabel() + "'"; + final String label = command.getLabel(); - s_logger.debug("Will look for network with name-label:" + label); + logger.debug("Will look for network with name-label:" + label); try { Ternary<String, String, String> interfaceDetails = getInterfaceDetails(label); return new OvsFetchInterfaceAnswer(command, true, "Interface " + label diff --cc plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java index fabe2ab3536,fb00875bb3d..aca1037d2be --- 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 @@@ -235,6 -233,34 +237,34 @@@ public class LinstorStorageAdaptor impl } } + private void setAllowTwoPrimariesOnRD(DevelopersApi api, String rscName) throws ApiException { + ResourceDefinitionModify rdm = new ResourceDefinitionModify(); + Properties props = new Properties(); + props.put("DrbdOptions/Net/allow-two-primaries", "yes"); + props.put("DrbdOptions/Net/protocol", "C"); + rdm.setOverrideProps(props); + ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm); + if (answers.hasError()) { - s_logger.error(String.format("Unable to set protocol C and 'allow-two-primaries' on %s", rscName)); ++ logger.error(String.format("Unable to set protocol C and 'allow-two-primaries' on %s", rscName)); + // do not fail here as adding allow-two-primaries property is only a problem while live migrating + } + } + + private void setAllowTwoPrimariesOnRc(DevelopersApi api, String rscName, String inUseNode) throws ApiException { + ResourceConnectionModify rcm = new ResourceConnectionModify(); + Properties props = new Properties(); + props.put("DrbdOptions/Net/allow-two-primaries", "yes"); + props.put("DrbdOptions/Net/protocol", "C"); + rcm.setOverrideProps(props); + ApiCallRcList answers = api.resourceConnectionModify(rscName, inUseNode, localNodeName, rcm); + if (answers.hasError()) { - 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 + } + } + /** * Checks if the given resource is in use by drbd on any host and * if so set the drbd option allow-two-primaries @@@ -294,11 -317,22 +321,22 @@@ return true; } - private void removeTwoPrimariesRcProps(DevelopersApi api, String inUseNode, String rscName) throws ApiException { + private void removeTwoPrimariesRDProps(DevelopersApi api, String rscName, List<String> deleteProps) + throws ApiException { + ResourceDefinitionModify rdm = new ResourceDefinitionModify(); + rdm.deleteProps(deleteProps); + ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm); + if (answers.hasError()) { - s_logger.error( ++ logger.error( + String.format("Failed to remove 'protocol' and 'allow-two-primaries' on %s: %s", + rscName, LinstorUtil.getBestErrorMessage(answers))); + // do not fail here as removing allow-two-primaries property isn't fatal + } + } + + private void removeTwoPrimariesRcProps(DevelopersApi api, String rscName, String inUseNode, List<String> deleteProps) + 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()) { @@@ -343,10 -387,10 +390,10 @@@ try { String inUseNode = LinstorUtil.isResourceInUse(api, rsc.getName()); if (inUseNode != null && !inUseNode.equalsIgnoreCase(localNodeName)) { - removeTwoPrimariesRcProps(api, inUseNode, rsc.getName()); + removeTwoPrimariesProps(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 } diff --cc utils/src/main/java/com/cloud/utils/HttpUtils.java index 299f21633ab,2b2450dd31b..1cbc4c79c17 --- a/utils/src/main/java/com/cloud/utils/HttpUtils.java +++ b/utils/src/main/java/com/cloud/utils/HttpUtils.java @@@ -117,9 -116,9 +117,9 @@@ public class HttpUtils return false; } final String jsessionidFromCookie = HttpUtils.findCookie(cookies, "JSESSIONID"); - if (jsessionidFromCookie == null - || !(jsessionidFromCookie.startsWith(session.getId() + '.'))) { + if (jsessionidFromCookie != null + && !(jsessionidFromCookie.equals(session.getId()) || jsessionidFromCookie.startsWith(session.getId() + '.'))) { - s_logger.error("JSESSIONID from cookie is invalid."); + LOGGER.error("JSESSIONID from cookie is invalid."); return false; } final String sessionKey = (String) session.getAttribute(sessionKeyString);