Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Fix: Option to set maximum expiry date for task completion upload tokens #364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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