Skip to content

Commit

Permalink
fix(titus/entitytags): remove schema version from key returned by Tit…
Browse files Browse the repository at this point in the history
…usClusterProvider (#4405)

EntityTag reconciliation process gets all server groups from the provider and matches them against the existing entity tags.
Titus returns keys in the form
```
titus:servergroups:v2:<application>:...
```
while the tags are stored in the form
```
titus:servergroups:<application>:...
```

This change removes the schema key (`v1` or `v2`) from the key IDs that are returned. This API (`getServerGroupIdentifiers`) is only used by the tag reconciler
  • Loading branch information
marchello2000 committed Mar 10, 2020
1 parent 8d84a3a commit 4a685eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,19 @@ class Keys implements KeyParser {
static String getInstanceHealthKey(String id, String healthProvider) {
"${TitusCloudProvider.ID}:${Namespace.HEALTH}:${id}:${healthProvider}"
}

static String removeSchemaVersion(String key) {
def parts = key.split(':')

if ((parts.length < 2) || (parts[0] != TitusCloudProvider.ID)) {
return key
}

if ((parts[2] != CachingSchema.V2.toString()) && (parts[2] != CachingSchema.V1.toString())) {
return key
}

parts[2] = null
return parts.findAll({ it != null }).join(':')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ class TitusClusterProvider implements ClusterProvider<TitusCluster>, ServerGroup
account = Optional.ofNullable(account).orElse("*")
region = Optional.ofNullable(region).orElse("*")

return cacheView.filterIdentifiers(SERVER_GROUPS.ns, Keys.getServerGroupKey("*", "*", account, region))
Collection<String> ids = cacheView.filterIdentifiers(SERVER_GROUPS.ns, Keys.getServerGroupKey("*", "*", account, region))

return ids.collect({ id ->
Keys.removeSchemaVersion(id)
}).toList()
}

@Override
Expand Down

0 comments on commit 4a685eb

Please sign in to comment.