Skip to content

Commit

Permalink
VBV-2216 - [new xenon] It is not possible to provision a template when
Browse files Browse the repository at this point in the history
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 <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Lazarin Lazarov <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
PG-Verified: jenkins <[email protected]>
  • Loading branch information
gmuleshkov committed Sep 10, 2018
1 parent 6821081 commit 76e65fd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -240,6 +240,7 @@ public void handleUpdateComponents(RequestStatus state, RequestStatus body) {

for (Map<String, Integer> progress : state.requestProgressByComponent.values()) {
progress.remove(DEFAULT_COMPONENT_NAME);
progress.remove(UriUtilsExtended.getValueEncoded(DEFAULT_COMPONENT_NAME));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,7 +148,6 @@ public void testNetworkProvisioningTask() throws Throwable {
}

// VBV-685
@Ignore
@Test
public void testNetworkWithSpecialNameProvisioningTask() throws Throwable {
String networkName = "special chars network";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 76e65fd

Please sign in to comment.