From 76e65fddadc44b2d04b74bb38cd3419efce764a8 Mon Sep 17 00:00:00 2001 From: Georgi Muleshkov Date: Tue, 4 Sep 2018 17:53:18 +0300 Subject: [PATCH] VBV-2216 - [new xenon] It is not possible to provision a template when there is a network with a space in the name The problem was because of the new limitations in xenon for the self links of the documents. - Changed the generation of the self link to use Base64 encoding Change-Id: I024cb9d6501d8adcb86022a67ead377b11d72efa Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/43518 Closures-Verified: jenkins Upgrade-Verified: jenkins CS-Verified: jenkins Reviewed-by: Lazarin Lazarov Bellevue-Verified: jenkins PG-Verified: jenkins --- .../com/vmware/admiral/common/util/UriUtilsExtended.java | 6 +++--- .../vmware/admiral/common/util/UriUtilsExtendedTest.java | 4 ++-- .../com/vmware/admiral/request/RequestStatusService.java | 7 ++++--- .../request/composition/CompositionTaskService.java | 6 +++--- .../request/ContainerNetworkProvisionTaskServiceTest.java | 2 -- .../vmware/admiral/request/RequestBrokerServiceTest.java | 4 +++- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/com/vmware/admiral/common/util/UriUtilsExtended.java b/common/src/main/java/com/vmware/admiral/common/util/UriUtilsExtended.java index f5f838103..9afb7e955 100644 --- a/common/src/main/java/com/vmware/admiral/common/util/UriUtilsExtended.java +++ b/common/src/main/java/com/vmware/admiral/common/util/UriUtilsExtended.java @@ -232,7 +232,7 @@ public static URI getReverseProxyUri(URI in) { if (in == null) { return null; } - String encodedUri = getReverseProxyEncoded(in.toString()); + String encodedUri = getValueEncoded(in.toString()); return UriUtils.buildUri(UriUtils.buildUriPath(ReverseProxyService.SELF_LINK, encodedUri)); } @@ -267,7 +267,7 @@ public static String getReverseProxyLocation(String location, URI currentUri, UR + (location.endsWith(UriUtils.URI_PATH_CHAR) ? UriUtils.URI_PATH_CHAR : ""); } String newLocation = UriUtils.buildUriPath(ReverseProxyService.SELF_LINK, - getReverseProxyEncoded(location)); + getValueEncoded(location)); if (originalUri == null) { return newLocation; } @@ -368,7 +368,7 @@ public static URI getReverseProxyTargetUri(URI opUri) { * Value to be encoded * @return Encoded value */ - public static String getReverseProxyEncoded(String input) { + public static String getValueEncoded(String input) { return Base64.getUrlEncoder().encodeToString(input.getBytes(UTF_8)); } diff --git a/common/src/test/java/com/vmware/admiral/common/util/UriUtilsExtendedTest.java b/common/src/test/java/com/vmware/admiral/common/util/UriUtilsExtendedTest.java index e5977bcec..fda1b39a4 100644 --- a/common/src/test/java/com/vmware/admiral/common/util/UriUtilsExtendedTest.java +++ b/common/src/test/java/com/vmware/admiral/common/util/UriUtilsExtendedTest.java @@ -36,7 +36,7 @@ public class UriUtilsExtendedTest { @Test public void testReverseProxyEncoding() { - String encoded = UriUtilsExtended.getReverseProxyEncoded(SAMPLE_URL); + String encoded = UriUtilsExtended.getValueEncoded(SAMPLE_URL); assertNotEquals(SAMPLE_URL, encoded); String decoded = UriUtilsExtended.getReverseProxyDecoded(encoded); @@ -296,7 +296,7 @@ public void testReverseProxyInvalidTransformations() { assertNull(uri); opUri = UriUtils.buildUri("http://localhost/rp/" - + UriUtilsExtended.getReverseProxyEncoded("%0")); + + UriUtilsExtended.getValueEncoded("%0")); try { uri = UriUtilsExtended.getReverseProxyTargetUri(opUri); fail("URI should be invalid!"); diff --git a/request/src/main/java/com/vmware/admiral/request/RequestStatusService.java b/request/src/main/java/com/vmware/admiral/request/RequestStatusService.java index a8a94753b..cff1b5303 100644 --- a/request/src/main/java/com/vmware/admiral/request/RequestStatusService.java +++ b/request/src/main/java/com/vmware/admiral/request/RequestStatusService.java @@ -21,9 +21,8 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.yaml.snakeyaml.util.UriEncoder; - import com.vmware.admiral.common.ManagementUriParts; +import com.vmware.admiral.common.util.UriUtilsExtended; import com.vmware.admiral.compute.ResourceType; import com.vmware.admiral.request.composition.CompositionGraph.ResourceNode; import com.vmware.admiral.request.composition.CompositionSubTaskService; @@ -214,7 +213,8 @@ public void handleUpdateComponents(RequestStatus state, RequestStatus body) { if (trackedAllocationTasks == null) { trackedAllocationTasks = new ArrayList<>(); } - String name = UriEncoder.encode(rn.name); + + String name = UriUtilsExtended.getValueEncoded(rn.name); String allocName = name + CompositionSubTaskService.ALLOC_SUFFIX; for (String k : state.requestProgressByComponent.keySet()) { @@ -240,6 +240,7 @@ public void handleUpdateComponents(RequestStatus state, RequestStatus body) { for (Map progress : state.requestProgressByComponent.values()) { progress.remove(DEFAULT_COMPONENT_NAME); + progress.remove(UriUtilsExtended.getValueEncoded(DEFAULT_COMPONENT_NAME)); } } diff --git a/request/src/main/java/com/vmware/admiral/request/composition/CompositionTaskService.java b/request/src/main/java/com/vmware/admiral/request/composition/CompositionTaskService.java index b106a9a0b..b89ae733c 100644 --- a/request/src/main/java/com/vmware/admiral/request/composition/CompositionTaskService.java +++ b/request/src/main/java/com/vmware/admiral/request/composition/CompositionTaskService.java @@ -36,10 +36,9 @@ import com.esotericsoftware.kryo.serializers.VersionFieldSerializer.Since; -import org.yaml.snakeyaml.util.UriEncoder; - import com.vmware.admiral.common.serialization.ReleaseConstants; import com.vmware.admiral.common.util.AssertUtil; +import com.vmware.admiral.common.util.UriUtilsExtended; import com.vmware.admiral.compute.BindingEvaluator; import com.vmware.admiral.compute.ResourceType; import com.vmware.admiral.compute.container.CompositeComponentFactoryService; @@ -567,7 +566,8 @@ private void patchCompositionSubTaskToExecute( } private String buildCompositionSubTaskLink(String name) { - final String compositionSubTaskId = getSelfId() + "-" + UriEncoder.encode(name); + final String compositionSubTaskId = getSelfId() + "-" + + UriUtilsExtended.getValueEncoded(name); return UriUtils.buildUriPath(CompositionSubTaskFactoryService.SELF_LINK, compositionSubTaskId); } diff --git a/request/src/test/java/com/vmware/admiral/request/ContainerNetworkProvisionTaskServiceTest.java b/request/src/test/java/com/vmware/admiral/request/ContainerNetworkProvisionTaskServiceTest.java index 40154fd80..88dde33e9 100644 --- a/request/src/test/java/com/vmware/admiral/request/ContainerNetworkProvisionTaskServiceTest.java +++ b/request/src/test/java/com/vmware/admiral/request/ContainerNetworkProvisionTaskServiceTest.java @@ -25,7 +25,6 @@ import java.util.Set; import java.util.UUID; -import org.junit.Ignore; import org.junit.Test; import com.vmware.admiral.compute.ContainerHostService; @@ -149,7 +148,6 @@ public void testNetworkProvisioningTask() throws Throwable { } // VBV-685 - @Ignore @Test public void testNetworkWithSpecialNameProvisioningTask() throws Throwable { String networkName = "special chars network"; diff --git a/request/src/test/java/com/vmware/admiral/request/RequestBrokerServiceTest.java b/request/src/test/java/com/vmware/admiral/request/RequestBrokerServiceTest.java index 275ebe01d..020517441 100644 --- a/request/src/test/java/com/vmware/admiral/request/RequestBrokerServiceTest.java +++ b/request/src/test/java/com/vmware/admiral/request/RequestBrokerServiceTest.java @@ -46,6 +46,7 @@ import com.vmware.admiral.common.test.CommonTestStateFactory; import com.vmware.admiral.common.util.QueryUtil; import com.vmware.admiral.common.util.ServiceDocumentQuery; +import com.vmware.admiral.common.util.UriUtilsExtended; import com.vmware.admiral.compute.ComputeConstants; import com.vmware.admiral.compute.ContainerHostService; import com.vmware.admiral.compute.ResourceType; @@ -514,7 +515,8 @@ public void testCompositeComponentRequestLifeCycle() throws Throwable { request = waitForRequestToComplete(request); // 2. Reservation stage: - String allocationTaskId = requestId + "-" + containerDesc.name + String allocationTaskId = requestId + "-" + + UriUtilsExtended.getValueEncoded(containerDesc.name) + CompositionSubTaskService.ALLOC_SUFFIX; String rsrvSelfLink = UriUtils.buildUriPath(ReservationTaskFactoryService.SELF_LINK, allocationTaskId);