Skip to content

Commit

Permalink
Add support for Fusion ARM64 client [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Dec 6, 2022
1 parent c619eb8 commit d073c53
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
12 changes: 10 additions & 2 deletions plugins/nf-wave/src/main/io/seqera/wave/plugin/WaveClient.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,18 @@ class WaveClient {
return new Gson().fromJson(json, type)
}

protected URL defaultFusionUrl() {
final isArm = config.containerPlatform()?.tokenize('/')?.contains('arm64')
return isArm
? new URL(FusionConfig.DEFAULT_FUSION_ARM64_URL)
: new URL(FusionConfig.DEFAULT_FUSION_AMD64_URL)
}

ContainerConfig resolveContainerConfig() {
final urls = new ArrayList<URL>(config.containerConfigUrl())
if( fusion.enabled() && fusion.containerConfigUrl() ) {
urls.add( fusion.containerConfigUrl() )
if( fusion.enabled() ) {
final fusionUrl = fusion.containerConfigUrl() ?: defaultFusionUrl()
urls.add(fusionUrl)
}
if( !urls )
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import groovy.transform.CompileStatic
@CompileStatic
class FusionConfig {

final static public String DEFAULT_FUSION_URL = 'https://fusionfs.seqera.io/releases/v0.5.json'
final static public String DEFAULT_FUSION_AMD64_URL = 'https://fusionfs.seqera.io/releases/v0.6.0-amd64.json'
final static public String DEFAULT_FUSION_ARM64_URL = 'https://fusionfs.seqera.io/releases/v0.6.0-arm64.json'

final private enabled
final private String containerConfigUrl
Expand All @@ -40,7 +41,7 @@ class FusionConfig {

FusionConfig(Map opts, Map<String,String> env=System.getenv()) {
this.enabled = opts.enabled
this.containerConfigUrl = opts.containerConfigUrl?.toString() ?: env.get('FUSION_CONTAINER_CONFIG_URL') ?: DEFAULT_FUSION_URL
this.containerConfigUrl = opts.containerConfigUrl?.toString() ?: env.get('FUSION_CONTAINER_CONFIG_URL')
if( containerConfigUrl && (!containerConfigUrl.startsWith('http://') && !containerConfigUrl.startsWith('https://')))
throw new IllegalArgumentException("Fusion container config URL should start with 'http:' or 'https:' protocol prefix - offending value: $containerConfigUrl")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class FusionConfigTest extends Specification {
when:
def opts = new FusionConfig(OPTS, ENV)
then:
opts.containerConfigUrl() == new URL(EXPECTED)
opts.containerConfigUrl() == (EXPECTED ? new URL(EXPECTED) : null)

where:
OPTS | ENV | EXPECTED
[:] | [:] | FusionConfig.DEFAULT_FUSION_URL
[:] | [:] | null
[containerConfigUrl:'http://foo.com'] | [:] | 'http://foo.com'
[:] | [FUSION_CONTAINER_CONFIG_URL:'http://bar.com'] | 'http://bar.com'
[containerConfigUrl:'http://foo.com'] | [FUSION_CONTAINER_CONFIG_URL:'http://bar.com'] | 'http://foo.com'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll

/**
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Expand Down Expand Up @@ -715,4 +717,22 @@ class WaveClientTest extends Specification {
| CONFIG_RESP.get('combined')
}

@Unroll
def 'should get fusion default url' () {
given:
def config = CONFIG
def sess = Mock(Session) {getConfig() >> config }
and:
def wave = Spy(new WaveClient(sess))

expect:
wave.defaultFusionUrl().toURI().toString() == EXPECTED

where:
CONFIG | EXPECTED
[:] | 'https://fusionfs.seqera.io/releases/v0.6.0-amd64.json'
[wave:[containerPlatform: 'arm64']] | 'https://fusionfs.seqera.io/releases/v0.6.0-arm64.json'
[wave:[containerPlatform: 'linux/arm64']] | 'https://fusionfs.seqera.io/releases/v0.6.0-arm64.json'
[wave:[containerPlatform: 'linux/arm64/v8']] | 'https://fusionfs.seqera.io/releases/v0.6.0-arm64.json'
}
}

0 comments on commit d073c53

Please sign in to comment.