Skip to content

Commit

Permalink
Fix: Option to set maximum expiry date for task completion upload tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
zerweck committed Aug 6, 2019
1 parent 9e9b494 commit aa10f12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions R/batch-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BatchUtilities <- R6::R6Class(
cloudCombine <- args$cloudCombine
userOutputFiles <- args$outputFiles
containerImage <- args$containerImage
maxDate <- args$maxDate

accountName <- storageClient$authentication$name

Expand Down Expand Up @@ -76,7 +77,7 @@ BatchUtilities <- R6::R6Class(
rAzureBatch::createBlobUrl(
storageAccount = storageClient$authentication$name,
containerName = jobId,
sasToken = storageClient$generateSasToken("w", "c", jobId),
sasToken = storageClient$generateSasToken("w", "c", jobId, end = maxDate),
storageEndpointSuffix = config$endpointSuffix
)

Expand Down Expand Up @@ -109,13 +110,14 @@ BatchUtilities <- R6::R6Class(

outputFiles <- append(outputFiles, userOutputFiles)


commands <-
c(commands,
rCommand)

commands <- linuxWrapCommands(commands)

sasToken <- storageClient$generateSasToken("rwcl", "c", jobId)
sasToken <- storageClient$generateSasToken("rwcl", "c", jobId, end = maxDate)
queryParameterUrl <- "?"

for (query in names(sasToken)) {
Expand Down
14 changes: 11 additions & 3 deletions R/doAzureParallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,17 @@ setHttpTraffic <- function(value = FALSE) {

job <- batchClient$jobOperations$getJob(id)

if(!is.null(obj$options$azure$maxDate)) {
maxDate <- obj$options$azure$maxDate
} else {
maxDate <- Sys.time() + 60 * 60 * 24 * 2 # same as default value for rAzureBatch::StorageServiceClient$public_methods$generateSasToken
}

outputContainerUrl <-
rAzureBatch::createBlobUrl(
storageAccount = storageClient$authentication$name,
containerName = id,
sasToken = storageClient$generateSasToken("w", "c", id),
sasToken = storageClient$generateSasToken("w", "c", id, end = maxDate),
storageEndpointSuffix = config$endpointSuffix
)

Expand Down Expand Up @@ -641,7 +647,8 @@ setHttpTraffic <- function(value = FALSE) {
outputFiles = mergeOutput,
containerImage = data$containerImage,
args = args,
maxRetryCount = maxTaskRetryCount
maxRetryCount = maxTaskRetryCount,
maxDate = maxDate
)

cat("\r", sprintf("Submitting tasks (%s/%s)", i, length(endIndices)), sep = "")
Expand Down Expand Up @@ -700,7 +707,8 @@ setHttpTraffic <- function(value = FALSE) {
cloudCombine = cloudCombine,
outputFiles = append(obj$options$azure$outputFiles, mergeOutput),
containerImage = data$containerImage,
resourceFiles = mergeResources
resourceFiles = mergeResources,
maxDate = maxDate
)

cat(". . .")
Expand Down

0 comments on commit aa10f12

Please sign in to comment.