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

fix: Azure Fusion env misses credentials when no key or SAS provided #5287

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class AzFusionEnv implements FusionEnv {
// the account name is always required
result.AZURE_STORAGE_ACCOUNT = cfg.storage().accountName

// If a Managed Identity or Service Principal is configured, Fusion only needs to know the account name
if (cfg.managedIdentity().isConfigured() || cfg.activeDirectory().isConfigured()) {
// If a Managed Identity is configured, Fusion only needs to know the account name
if (cfg.managedIdentity().isConfigured()) {
return result
}

// If a SAS token is configured, instead, Fusion also requires the token value
if (cfg.storage().sasToken) {
// If Fusion does not use a managed identity, get or create a SAS token for Fusion to use
adamrtalbot marked this conversation as resolved.
Show resolved Hide resolved
if (cfg.storage().sasToken || cfg.storage().accountKey || cfg.activeDirectory().isConfigured()) {
result.AZURE_STORAGE_SAS_TOKEN = cfg.storage().getOrCreateSasToken()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import nextflow.Global
import nextflow.Session
import nextflow.SysEnv
import nextflow.fusion.FusionConfig
import nextflow.cloud.azure.config.AzStorageOpts

import spock.lang.Specification

/**
Expand Down Expand Up @@ -61,6 +63,27 @@ class AzFusionEnvTest extends Specification {

}

def 'should return env environment with SAS token config when accountKey is provided'() {
given:
Global.session = Mock(Session) {
getConfig() >> [azure: [storage: [accountName: 'myaccount', accountKey: 'myaccountkey']]]
}
def mockStorageObject = Mock(AzStorageOpts) {
getOrCreateSasToken() >> 'generatedSasToken'
}
def config = Mock(FusionConfig) {
storage() >> mockStorageObject
}

when:
def env = new AzFusionEnv().getEnvironment('az', config)

then:
env.AZURE_STORAGE_ACCOUNT == 'myaccount'
env.AZURE_STORAGE_SAS_TOKEN
env.size() == 2
}

def 'should return env environment with SAS token config'() {
given:
Global.session = Mock(Session) {
Expand Down Expand Up @@ -99,4 +122,5 @@ class AzFusionEnvTest extends Specification {
then:
thrown(IllegalArgumentException)
}

}