Skip to content

Commit

Permalink
Merge branch 'master' into refactor-mirror-config
Browse files Browse the repository at this point in the history
  • Loading branch information
munishchouhan authored Oct 8, 2024
2 parents 993ec0c + c6d2438 commit fb5a9a7
Show file tree
Hide file tree
Showing 151 changed files with 5,502 additions and 1,359 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ dependencies {
compileOnly("io.micronaut:micronaut-http-validation")
implementation("jakarta.persistence:jakarta.persistence-api:3.0.0")
api 'io.seqera:lib-mail:1.0.0'
api 'io.seqera:wave-api:0.12.0'
api 'io.seqera:wave-utils:0.13.1'

api 'io.seqera:wave-api:0.13.1'
api 'io.seqera:wave-utils:0.14.1'
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-jackson-databind")
implementation("io.micronaut.groovy:micronaut-runtime-groovy")
Expand Down Expand Up @@ -72,6 +71,7 @@ dependencies {
implementation 'software.amazon.awssdk:ses'
implementation 'org.yaml:snakeyaml:2.0'
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
implementation 'org.luaj:luaj-jse:3.0.1'
//object storage dependency
implementation("io.micronaut.objectstorage:micronaut-object-storage-aws")
// include sts to allow the use of service account role - https://stackoverflow.com/a/73306570
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RegistryAuthStore extends AbstractStateStore<RegistryAuth> {

@Override
protected String getPrefix() {
return 'registry-auth/v1:'
return 'registry-auth/v1'
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RegistryTokenStore extends AbstractStateStore<String> {

@Override
protected String getPrefix() {
return 'registry-token/v1:'
return 'registry-token/v1'
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class ScanConfig {
@Value('${wave.scan.status.duration:1h}')
Duration statusDuration

@Value('${wave.scan.id.duration:7d}')
Duration scanIdDuration

String getScanImage() {
return scanImage
}
Expand All @@ -86,6 +89,11 @@ class ScanConfig {
return result
}

@Memoized
Path getWorkspace() {
Path.of(buildDirectory).toAbsolutePath()
}

String getRequestsCpu() {
return requestsCpu
}
Expand Down
40 changes: 16 additions & 24 deletions src/main/groovy/io/seqera/wave/controller/BuildController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package io.seqera.wave.controller
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import io.micronaut.core.annotation.Nullable
import io.micronaut.http.HttpHeaders
import io.micronaut.http.HttpResponse
import io.micronaut.http.MediaType
import io.micronaut.http.annotation.Controller
Expand All @@ -30,11 +31,8 @@ import io.micronaut.http.server.types.files.StreamedFile
import io.micronaut.scheduling.TaskExecutors
import io.micronaut.scheduling.annotation.ExecuteOn
import io.seqera.wave.api.BuildStatusResponse
import io.seqera.wave.exception.BadRequestException
import io.seqera.wave.service.builder.ContainerBuildService
import io.seqera.wave.service.logs.BuildLogService
import io.seqera.wave.service.mirror.ContainerMirrorService
import io.seqera.wave.service.mirror.MirrorRequest
import io.seqera.wave.service.persistence.WaveBuildRecord
import jakarta.inject.Inject
/**
Expand All @@ -51,12 +49,9 @@ class BuildController {
@Inject
private ContainerBuildService buildService

@Inject
private ContainerMirrorService mirrorService

@Inject
@Nullable
BuildLogService logService
private BuildLogService logService

@Get("/v1alpha1/builds/{buildId}")
HttpResponse<WaveBuildRecord> getBuildRecord(String buildId) {
Expand All @@ -79,25 +74,22 @@ class BuildController {

@Get("/v1alpha1/builds/{buildId}/status")
HttpResponse<BuildStatusResponse> getBuildStatus(String buildId) {
final resp = buildResponse0(buildId)
resp != null
? HttpResponse.ok(resp)
final build = buildService.getBuildRecord(buildId)
build != null
? HttpResponse.ok(build.toStatusResponse())
: HttpResponse.<BuildStatusResponse>notFound()
}

protected BuildStatusResponse buildResponse0(String buildId) {
if( !buildId )
throw new BadRequestException("Missing 'buildId' parameter")
// build IDs starting with the `mr-` prefix are interpreted as mirror requests
if( buildId.startsWith(MirrorRequest.ID_PREFIX) ) {
return mirrorService
.getMirrorEntry(buildId)
?.toStatusResponse()
}
else {
return buildService
.getBuildRecord(buildId)
?.toStatusResponse()
}
@Produces(MediaType.TEXT_PLAIN)
@Get(value="/v1alpha1/builds/{buildId}/condalock")
HttpResponse<StreamedFile> getCondaLock(String buildId){
if( logService==null )
throw new IllegalStateException("Build Logs service not configured")
final condaLock = logService.fetchCondaLockStream(buildId)
return condaLock
? HttpResponse.ok(condaLock)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"conda-env-${buildId}.lock\"")
: HttpResponse.<StreamedFile>notFound()
}

}
Loading

0 comments on commit fb5a9a7

Please sign in to comment.