Skip to content

Commit

Permalink
Merge branch 'master' into 475-use-k8s-job-instead-of-pod-for-blob-ca…
Browse files Browse the repository at this point in the history
…che-transfer
  • Loading branch information
munishchouhan committed Jul 2, 2024
2 parents 329a2c4 + d987222 commit 17d8f46
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 35 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.2
1.8.3
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Wave changelog
1.8.3 - 29 Jun 2024
- Fix client cache deadlock (#547) [cc6012ff]
- Fix failing test [263b44d3]
- Add cache record-stats (#534) [229926e2]

1.8.2 - 14 Jun 2024
- Fix get image auth digest (#530) [df8ec041]

Expand Down
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
8 changes: 4 additions & 4 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 Expand Up @@ -66,7 +66,7 @@ wave:
server:
url: "${WAVE_SERVER_URL:`http://localhost:9090`}"
build:
buildkit-image: "moby/buildkit:v0.14.0-rootless"
buildkit-image: "moby/buildkit:v0.14.1-rootless"
singularity-image: "quay.io/singularity/singularity:v3.11.4-slim"
singularity-image-arm64: "quay.io/singularity/singularity:v3.11.4-slim-arm64"
repo: "195996028523.dkr.ecr.eu-west-1.amazonaws.com/wave/build/dev"
Expand Down
59 changes: 43 additions & 16 deletions src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package io.seqera.wave.core
import spock.lang.Shared
import spock.lang.Specification

import java.net.http.HttpHeaders
import java.net.http.HttpResponse
import java.nio.file.Files

import groovy.json.JsonSlurper
Expand Down Expand Up @@ -817,32 +819,57 @@ class ContainerAugmenterTest extends Specification {

def 'should fetch container manifest for legacy image' () {
given:
def REGISTRY = 'quay.io'
def IMAGE = 'biocontainers/fastqc'
def TAG = '0.11.9--0'
def registry = lookupService.lookup(REGISTRY)
def creds = credentialsProvider.getDefaultCredentials(REGISTRY)
def httpClient = HttpClientFactory.neverRedirectsHttpClient()
def REGISTRY = 'mockreg.io'
def IMAGE = 'repo/image'
def TAG = '1.0.0'
and:

def client = new ProxyClient(httpClient, httpConfig)
.withRoute(Mock(RoutePath))
.withImage(IMAGE)
.withRegistry(registry)
.withCredentials(creds)
.withLoginService(loginService)
def client = Mock(ProxyClient)

and:
def headers = ['content-type': List.of('application/vnd.docker.distribution.manifest.v1+prettyjws'),
'docker-content-digest': List.of('sha256:samplesha')]
def response1 = Mock(HttpResponse)
response1.headers() >> HttpHeaders.of(headers, (a, b)->true)
and:
String manifest = """
{
"schemaVersion": 1,
"name": "mockImage",
"tag": "latest",
"architecture": "amd64",
"fsLayers": [
{"blobSum": "sha256:mockBlobSum1"},
{"blobSum": "sha256:mockBlobSum2"}
],
"history": [
{
"v1Compatibility": "{\\"id\\":\\"mockId1\\",\\"architecture\\": \\"amd64\\",\\"config\\": {\\"Cmd\\": [\\"/bin/sh\\"],\\"Env\\": [\\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\\"],\\"Entrypoint\\": null,\\"WorkingDir\\": \\"\\"},\\"created\\": \\"2021-09-23T23:47:57.442225064Z\\",\\"docker_version\\": \\"20.10.7\\",\\"os\\": \\"linux\\",\\"parent\\": \\"mockParent1\\"}"
}
]
}
"""
def response2 = Mock(HttpResponse)
response2.headers() >> HttpHeaders.of(Map.of('content-type', List.of('application/vnd.docker.distribution.manifest.v1+prettyjws')), (a, b)->true)
response2.body() >> manifest
and:
def scanner = new ContainerAugmenter()
.withClient(client)
.withPlatform('amd64')

when:
def spec = scanner.getContainerSpec(IMAGE, TAG, WaveDefault.ACCEPT_HEADERS)

then:
client.head("/v2/$IMAGE/manifests/$TAG", _) >> response1
client.getString(_, _ ) >> response2
client.route >> new RoutePath('docker', REGISTRY, IMAGE)
client.getRegistry() >> new RegistryInfo(REGISTRY, new URI(REGISTRY), Mock(RegistryAuth))
then:
spec.registry == 'quay.io'
spec.imageName == 'biocontainers/fastqc'
spec.reference == '0.11.9--0'
spec.digest == 'sha256:319b8d4eca0fc0367d192941f221f7fcd29a6b96996c63cbf8931dbb66e53348'
spec.registry == 'mockreg.io'
spec.imageName == 'repo/image'
spec.reference == '1.0.0'
spec.digest == 'sha256:samplesha'
and:
spec.isV1()
!spec.isV2()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DockerBuildStrategyTest extends Specification {
'-v', '/work/foo:/work/foo',
'--entrypoint',
'buildctl-daemonless.sh',
'moby/buildkit:v0.14.0-rootless']
'moby/buildkit:v0.14.1-rootless']

when:
cmd = service.cmdForBuildkit(work, Path.of('/foo/creds.json'), null, ContainerPlatform.of('arm64'))
Expand All @@ -68,7 +68,7 @@ class DockerBuildStrategyTest extends Specification {
'buildctl-daemonless.sh',
'-v', '/foo/creds.json:/home/user/.docker/config.json:ro',
'--platform', 'linux/arm64',
'moby/buildkit:v0.14.0-rootless']
'moby/buildkit:v0.14.1-rootless']

when:
cmd = service.cmdForBuildkit(work, Path.of('/foo/creds.json'), spackConfig, null)
Expand All @@ -82,7 +82,7 @@ class DockerBuildStrategyTest extends Specification {
'buildctl-daemonless.sh',
'-v', '/foo/creds.json:/home/user/.docker/config.json:ro',
'-v', '/host/spack/key:/opt/spack/key:ro',
'moby/buildkit:v0.14.0-rootless']
'moby/buildkit:v0.14.1-rootless']

cleanup:
ctx.close()
Expand Down Expand Up @@ -113,7 +113,7 @@ class DockerBuildStrategyTest extends Specification {
'buildctl-daemonless.sh',
'-v', '/work/creds.json:/home/user/.docker/config.json:ro',
'--platform', 'linux/amd64',
'moby/buildkit:v0.14.0-rootless',
'moby/buildkit:v0.14.1-rootless',
'build',
'--frontend',
'dockerfile.v0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class KubeBuildStrategyTest extends Specification {
def req = new BuildRequest(containerId, dockerfile, null, null, PATH, targetImage, USER, ContainerPlatform.of('amd64'), cache, "10.20.30.40", '{"config":"json"}', null,null , null, null, BuildFormat.DOCKER).withBuildId('1')

then: 'should return buildkit image'
strategy.getBuildImage(req) == 'moby/buildkit:v0.14.0-rootless'
strategy.getBuildImage(req) == 'moby/buildkit:v0.14.1-rootless'

when:'getting singularity with amd64 arch in build request'
req = new BuildRequest(containerId, dockerfile, null, null, PATH, targetImage, USER, ContainerPlatform.of('amd64'), cache, "10.20.30.40", '{}', null,null , null, null, BuildFormat.SINGULARITY).withBuildId('1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ class ContainerInspectServiceImplTest extends Specification {

and:
ContainerInspectServiceImpl.findRepositories('''
FROM moby/buildkit:v0.14.0-rootless AS bkt
FROM moby/buildkit:v0.14.1-rootless AS bkt
RUN this and that
FROM amazoncorretto:17.0.4
COPY --from=bkt /usr/bin/buildctl /usr/bin/buildctl
''') == ['moby/buildkit:v0.14.0-rootless', 'amazoncorretto:17.0.4']
''') == ['moby/buildkit:v0.14.1-rootless', 'amazoncorretto:17.0.4']

}

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 17d8f46

Please sign in to comment.