Skip to content

Commit

Permalink
fix(elasticsearch): URL encode the ID (#4419)
Browse files Browse the repository at this point in the history
In cases where the tag ID has illegal url character we need to encode.
Not sure why it worked in Jest2 and not in Jest6 - will figure this out separately.
  • Loading branch information
marchello2000 committed Mar 13, 2020
1 parent b34ea09 commit 599131e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import io.searchbox.indices.DeleteIndex;
import io.searchbox.params.Parameters;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
import org.apache.lucene.search.join.ScoreMode;
Expand Down Expand Up @@ -189,7 +190,7 @@ public void index(EntityTags entityTags) {
objectMapper.convertValue(prepareForWrite(objectMapper, entityTags), Map.class))
.index(activeElasticSearchIndex)
.type(mappingTypeName)
.id(entityTags.getId())
.id(URLEncoder.encode(entityTags.getId(), "UTF-8"))
.build();

JestResult jestResult = jestClient.execute(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class ElasticSearchEntityTagsProviderSpec extends Specification {
def "should delete all entity tags in namespace"() {
given:
def allEntityTags = [
buildEntityTags("titus:servergroup:clouddriver-main-^1.0.0-v150:myaccount:us-west-1", ["a": "1"], "my_namespace"),
buildEntityTags("aws:servergroup:clouddriver-main-v001:myaccount:us-west-1", ["a": "1"], "my_namespace"),
buildEntityTags("aws:servergroup:clouddriver-main-v002:myaccount:us-west-1", ["b": "2"], "my_namespace"),
buildEntityTags("aws:servergroup:clouddriver-main-v003:myaccount:us-west-1", ["c": "3"]),
Expand Down

0 comments on commit 599131e

Please sign in to comment.