Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace EFS with S3 #577

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
eb3f302
Initial commit
munishchouhan Jul 24, 2024
276e882
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Jul 24, 2024
a426aa0
corrected tarutils
munishchouhan Jul 24, 2024
d9e027b
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Jul 29, 2024
01d2562
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Jul 30, 2024
3105c9d
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 7, 2024
1edf22f
Changed singularity docker build
munishchouhan Aug 7, 2024
ebcc16a
working singularity build
munishchouhan Aug 8, 2024
9f2e217
working singularity build and push
munishchouhan Aug 13, 2024
1ba1a56
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 13, 2024
88d06c0
refactored
munishchouhan Aug 14, 2024
fabe615
updated scan process
munishchouhan Aug 16, 2024
738334e
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 20, 2024
fe2b2f4
working scan process
munishchouhan Aug 22, 2024
ae16c5e
fixed compile error
munishchouhan Aug 22, 2024
9025729
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 22, 2024
c3f5a9f
update k8s services
munishchouhan Aug 22, 2024
fb60a0d
update trivy image
munishchouhan Aug 22, 2024
d18b668
removed workdir
munishchouhan Aug 22, 2024
7751c86
minor change [ci skip]
munishchouhan Aug 22, 2024
447afac
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 23, 2024
88738ee
added nextflow-io/k8s-fuse-plugin
munishchouhan Aug 23, 2024
f2ca939
minor change [ci skip]
munishchouhan Aug 27, 2024
269deec
Merge branch 'master' into 569-allow-the-use-of-s3-bucket-to-host-con…
munishchouhan Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/groovy/io/seqera/wave/configuration/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ class BuildConfig {
@Value('${wave.build.public-repo}')
String defaultPublicRepository

/**
* File system path there the dockerfile is save
*/
@Value('${wave.build.workspace}')
String buildWorkspace
@Nullable
@Value('${wave.build.logs.bucket}')
String storageBucket

@Value('${wave.build.workspace-bucket}')
String workspaceBucket

@Value('${wave.build.status.delay}')
Duration statusDelay
Expand Down Expand Up @@ -119,7 +120,6 @@ class BuildConfig {
"default-build-repository=${defaultBuildRepository}; " +
"default-cache-repository=${defaultCacheRepository}; " +
"default-public-repository=${defaultPublicRepository}; " +
"build-workspace=${buildWorkspace}; " +
"build-timeout=${defaultTimeout}; " +
"build-trusted-timeout=${trustedTimeout}; " +
"status-delay=${statusDelay}; " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ class ContainerController {
containerFile,
condaContent,
spackContent,
Path.of(buildConfig.buildWorkspace),
targetImage,
identity,
platform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import io.micronaut.context.annotation.Factory
import io.micronaut.context.annotation.Requires
import io.micronaut.context.annotation.Value
import io.micronaut.objectstorage.InputStreamMapper
import io.micronaut.objectstorage.ObjectStorageOperations
import io.micronaut.objectstorage.aws.AwsS3Configuration
import io.micronaut.objectstorage.aws.AwsS3Operations
import io.seqera.wave.configuration.BuildConfig
import jakarta.inject.Inject
import jakarta.inject.Named
import jakarta.inject.Singleton
import software.amazon.awssdk.services.s3.S3Client
Expand All @@ -38,17 +39,26 @@ import software.amazon.awssdk.services.s3.S3Client
@Factory
@CompileStatic
@Slf4j
@Requires(property = 'wave.build.logs.bucket')
class ObjectStorageOperationsFactory {

@Value('${wave.build.logs.bucket}')
String storageBucket
@Inject
private BuildConfig buildConfig

@Singleton
@Named("build-logs")
ObjectStorageOperations<?, ?, ?> awsStorageOperations(@Named("DefaultS3Client") S3Client s3Client, InputStreamMapper inputStreamMapper) {
@Requires(property = 'wave.build.logs.bucket')
ObjectStorageOperations<?, ?, ?> awsStorageOperationsBuildLogs(@Named("DefaultS3Client") S3Client s3Client, InputStreamMapper inputStreamMapper) {
AwsS3Configuration configuration = new AwsS3Configuration('build-logs')
configuration.setBucket(storageBucket)
configuration.setBucket(buildConfig.storageBucket)
return new AwsS3Operations(configuration, s3Client, inputStreamMapper)
}

@Singleton
@Named("build-workspace")
@Requires(property = 'wave.build.workspace-bucket')
ObjectStorageOperations<?, ?, ?> awsStorageOperationsBuildWorkspace(@Named("DefaultS3Client") S3Client s3Client, InputStreamMapper inputStreamMapper) {
AwsS3Configuration configuration = new AwsS3Configuration('build-workspace')
configuration.setBucket(buildConfig.workspaceBucket)
return new AwsS3Operations(configuration, s3Client, inputStreamMapper)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Wave, containers provisioning service
* Copyright (c) 2023-2024, Seqera Labs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package io.seqera.wave.service.builder

/**
* Constants for the build service
*
* @author Munish Chouhan <[email protected]>
*/
class BuildConstants {

public static final String FUSION_PREFIX = "/fusion/s3"

static final public String BUILDKIT_ENTRYPOINT = 'buildctl-daemonless.sh'
}
19 changes: 3 additions & 16 deletions src/main/groovy/io/seqera/wave/service/builder/BuildRequest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.seqera.wave.service.builder

import java.nio.file.Path
import java.time.Duration
import java.time.Instant
import java.time.OffsetDateTime
Expand Down Expand Up @@ -65,11 +64,6 @@ class BuildRequest {
*/
final String spackFile

/**
* The build context work directory
*/
final Path workspace

/**
* The target fully qualified image of the built container. It includes the target registry name
*/
Expand Down Expand Up @@ -142,13 +136,13 @@ class BuildRequest {

volatile String buildId

volatile Path workDir

String s3Key

BuildRequest(String containerId,
String containerFile,
String condaFile,
String spackFile,
Path workspace,
String targetImage,
PlatformId identity,
ContainerPlatform platform,
Expand All @@ -167,7 +161,6 @@ class BuildRequest {
this.containerFile = containerFile
this.condaFile = condaFile
this.spackFile = spackFile
this.workspace = workspace
this.targetImage = targetImage
this.identity = identity
this.platform = platform
Expand All @@ -189,7 +182,6 @@ class BuildRequest {
this.containerFile = opts.containerFile
this.condaFile = opts.condaFile
this.spackFile = opts.spackFile
this.workspace = opts.workspace as Path
this.targetImage = opts.targetImage
this.identity = opts.identity as PlatformId
this.platform = opts.platform as ContainerPlatform
Expand All @@ -203,7 +195,6 @@ class BuildRequest {
this.scanId = opts.scanId
this.buildContext = opts.buildContext as BuildContext
this.format = opts.format as BuildFormat
this.workDir = opts.workDir as Path
this.buildId = opts.buildId
this.maxDuration = opts.maxDuration as Duration
}
Expand Down Expand Up @@ -234,10 +225,6 @@ class BuildRequest {
return spackFile
}

Path getWorkDir() {
return workDir
}

String getTargetImage() {
return targetImage
}
Expand Down Expand Up @@ -284,7 +271,7 @@ class BuildRequest {

BuildRequest withBuildId(String id) {
this.buildId = containerId + SEP + id
this.workDir = workspace.resolve(buildId).toAbsolutePath()
this.s3Key = "workspace/$buildId"
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
package io.seqera.wave.service.builder

import groovy.transform.CompileStatic
import io.micronaut.objectstorage.ObjectStorageOperations
import io.seqera.wave.configuration.BuildConfig
import jakarta.inject.Inject
import jakarta.inject.Named
import static io.seqera.wave.service.builder.BuildConstants.FUSION_PREFIX
import static io.seqera.wave.service.builder.BuildConstants.BUILDKIT_ENTRYPOINT
/**
* Defines an abstract container build strategy.
*
Expand All @@ -35,12 +39,14 @@ abstract class BuildStrategy {
@Inject
private BuildConfig buildConfig

abstract BuildResult build(BuildRequest req)
@Inject
@Named('build-workspace')
private ObjectStorageOperations<?, ?, ?> objectStorageOperations

static final public String BUILDKIT_ENTRYPOINT = 'buildctl-daemonless.sh'
abstract BuildResult build(BuildRequest req)

void cleanup(BuildRequest req) {
req.workDir?.deleteDir()
objectStorageOperations.delete(req.s3Key)
}

List<String> launchCmd(BuildRequest req) {
Expand All @@ -57,15 +63,16 @@ abstract class BuildStrategy {
protected List<String> dockerLaunchCmd(BuildRequest req) {
final result = new ArrayList(10)
result
<< BUILDKIT_ENTRYPOINT
<< "build"
<< "--frontend"
<< "dockerfile.v0"
<< "--local"
<< "dockerfile=$req.workDir".toString()
<< "dockerfile=$FUSION_PREFIX/$buildConfig.workspaceBucket/$req.s3Key".toString()
<< "--opt"
<< "filename=Containerfile"
<< "--local"
<< "context=$req.workDir/context".toString()
<< "context=$FUSION_PREFIX/$buildConfig.workspaceBucket/$req.s3Key/context".toString()
<< "--output"
<< "type=image,name=$req.targetImage,push=true,oci-mediatypes=${buildConfig.ociMediatypes}".toString()
<< "--opt"
Expand Down Expand Up @@ -105,11 +112,15 @@ abstract class BuildStrategy {
}

protected List<String> singularityLaunchCmd(BuildRequest req) {
def symlinkSingularity = ""
if( req.configJson ){
symlinkSingularity = "ln -s $FUSION_PREFIX/$buildConfig.workspaceBucket/$req.s3Key/.singularity /root/.singularity &&"
}
final result = new ArrayList(10)
result
<< 'sh'
<< '-c'
<< "singularity build image.sif ${req.workDir}/Containerfile && singularity push image.sif ${req.targetImage}".toString()
<< "$symlinkSingularity singularity build image.sif $FUSION_PREFIX/$buildConfig.workspaceBucket/$req.s3Key/Containerfile && singularity push image.sif ${req.targetImage}".toString()
return result
}

Expand Down
Loading
Loading