Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jgainerdewar committed Feb 11, 2025
1 parent c03f985 commit 57ed4b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cromwell.backend.standard.callcaching

import java.util.concurrent.TimeoutException
import akka.actor.{Actor, ActorLogging, ActorRef, Timers}
import akka.event.LoggingAdapter
import com.typesafe.config.Config
Expand All @@ -16,6 +15,7 @@ import cromwell.core.path.Path
import net.ceedubs.ficus.Ficus._
import wom.values.WomFile

import java.util.concurrent.TimeoutException
import scala.jdk.CollectionConverters._
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -99,11 +99,11 @@ abstract class StandardFileHashingActor(standardParams: StandardFileHashingActor
fsConfigs <- configurationDescriptor.backendConfig.as[Option[Config]]("filesystems").toList
fsKey <- fsConfigs.root.keySet().asScala
configKey = s"${fsKey}.caching.hashing-strategy"
// TODO this allows users to override with an empty list to prevent caching, is that desirable or a footgun?
fileHashStrategyFromList = Try(fsConfigs.as[List[String]](configKey)).toOption
fileHashStrategyFromString = Try(fsConfigs.as[String](configKey)).toOption.map(List(_))
fileHashStrategy <- fileHashStrategyFromList.orElse(fileHashStrategyFromString)
} yield (fsKey, FileHashStrategy.of(fileHashStrategy))
nonEmptyFileHashStrategy <- if (fileHashStrategy.nonEmpty) Option(fileHashStrategy) else None
} yield (fsKey, FileHashStrategy.of(nonEmptyFileHashStrategy))

defaultHashingStrategies ++ configuredHashingStrategies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class StandardFileHashingActorSpec
"""filesystems.gcs.caching.hashing-strategy = ["md5", "identity"]
|filesystems.s3.caching.hashing-strategy = "etag"
|filesystems.http.some-other-config = "foobar"
|filesystems.ftp.caching.hashing-strategy = []""".stripMargin
|filesystems.ftp.caching.hashing-strategy = []
|filesystems.nfs.caching.hashing-strategy = "bogohash"""".stripMargin
)
val config = BackendConfigurationDescriptor(backendConfig, ConfigFactory.empty)

Expand Down Expand Up @@ -185,12 +186,26 @@ class StandardFileHashingActorSpec
}
}

// Test an actor-defined default overriden by config
checkHashStrategy("gcs", FileHashStrategy(List(HashType.Md5, HashType.Identity)))

// Test a strategy only defined in config
checkHashStrategy("s3", FileHashStrategy.ETag)
checkHashStrategy("ftp", FileHashStrategy(List()))

// Test a strategy defined as an empty list in config, should use fallback
checkHashStrategy("ftp", FileHashStrategy(List(HashType.Sha256)))

// Test a strategy with a default defined in the actor
checkHashStrategy("drs", FileHashStrategy.Drs)

// Test a filesystem that has config, but not this config
checkHashStrategy("http", FileHashStrategy(List(HashType.Sha256)))

// Test a strategy not defined in config or actor defaults
checkHashStrategy("blob", FileHashStrategy(List(HashType.Sha256)))

// Test a strategy with an invalid value in config
checkHashStrategy("nfs", FileHashStrategy(List(HashType.Sha256)))
}

}
Expand Down

0 comments on commit 57ed4b4

Please sign in to comment.