Skip to content

Commit

Permalink
Fix client cache deadlock (#547)
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored Jun 29, 2024
1 parent 263b44d commit cc6012f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class RegistryProxyService {

static private List<Integer> RETRY_ON_NOT_FOUND = HTTP_RETRYABLE_ERRORS + 404

@Cacheable(value = 'cache-20sec', atomic = true)
@Cacheable(value = 'cache-registry-proxy', atomic = true)
protected String getImageDigest0(BuildRequest request, boolean retryOnNotFound) {
final image = request.targetImage
final coords = ContainerCoordinates.parse(image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ class TowerClient {
return connector.sendAsync(endpoint, uri, authorization, type)
}

@Cacheable(value = 'cache-20sec', atomic = true)
@Cacheable(value = 'cache-tower-client', atomic = true)
CompletableFuture<ServiceInfoResponse> serviceInfo(String towerEndpoint) {
final uri = serviceInfoEndpoint(towerEndpoint)
return getAsync(uri, towerEndpoint, null, ServiceInfoResponse)
}

@Cacheable(value = 'cache-20sec', atomic = true)
@Cacheable(value = 'cache-tower-client', atomic = true)
CompletableFuture<UserInfoResponse> userInfo(String towerEndpoint, JwtAuth authorization) {
final uri = userInfoEndpoint(towerEndpoint)
return getAsync(uri, towerEndpoint, authorization, UserInfoResponse)
}

@Cacheable(value = 'cache-20sec', atomic = true)
@Cacheable(value = 'cache-tower-client', atomic = true)
CompletableFuture<ListCredentialsResponse> listCredentials(String towerEndpoint, JwtAuth authorization, Long workspaceId) {
final uri = listCredentialsEndpoint(towerEndpoint, workspaceId)
return getAsync(uri, towerEndpoint, authorization, ListCredentialsResponse)
}

@Cacheable(value = 'cache-20sec', atomic = true)
@Cacheable(value = 'cache-tower-client', atomic = true)
CompletableFuture<GetCredentialsKeysResponse> fetchEncryptedCredentials(String towerEndpoint, JwtAuth authorization, String credentialsId, String pairingId, Long workspaceId) {
final uri = fetchCredentialsEndpoint(towerEndpoint, credentialsId, pairingId, workspaceId)
return getAsync(uri, towerEndpoint, authorization, GetCredentialsKeysResponse)
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ micronaut:
# IMPORTANT: use `expire-after-write` strategy to guarantee cached entries are not retained more than the declared period.
# Using `expire-after-read` can cause an entry to be retained in the cache more than expected if it is hit continuously
# with a frequency shorter than the declared cache period.
cache-20sec:
cache-tower-client:
expire-after-write: 20s
record-stats: true
cache-1min:
expire-after-write: 1m
cache-registry-proxy:
expire-after-write: 20s
record-stats: true
# Discovery client by default uses a cache for results. This is a transitive behaviour
# introduced by prometheus and management dependencies and below line disables as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class TowerClientHttpTest extends Specification{

def setup() {
jwtAuthStore.clear()
cacheManager.getCache("cache-1min").invalidateAll()
cacheManager.getCache("cache-20sec").invalidateAll()
cacheManager.getCache("cache-tower-client").invalidateAll()
cacheManager.getCache("cache-registry-proxy").invalidateAll()
towerConnector.refreshCache0().invalidateAll()
}

Expand Down

0 comments on commit cc6012f

Please sign in to comment.