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

Bump the SBT version from 1.4.1 to 1.9.8 #1114

Merged
merged 4 commits into from
Feb 7, 2024
Merged
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
166 changes: 88 additions & 78 deletions bags_api/src/main/scala/weco/storage_service/bags_api/BagsApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,45 @@ trait BagsApi

protected val s3PresignedUrls: S3PresignedUrls

private val routes: Route = pathPrefix("bags") {
concat(
// We look for /versions at the end of the path: this means we should
// return a list of versions, not the complete manifest.
//
// The trailing slash is significant: it causes Akka to consume "/versions",
// rather than "versions". If you omit it, the externalIdentifier gets a
// slash appended!
//
pathSuffix("versions" /) {
private val routes: Route = concat(
pathPrefix("bags") {
concat(
// We look for /versions at the end of the path: this means we should
// return a list of versions, not the complete manifest.
//
// The trailing slash is significant: it causes Akka to consume "/versions",
// rather than "versions". If you omit it, the externalIdentifier gets a
// slash appended!
//
pathSuffix("versions" /) {
path(Segment / Remaining) {
(space, remaining) =>
get {
Try { decodeExternalIdentifier(remaining) } match {
case Success(externalIdentifier) =>
val bagId = BagId(
space = StorageSpace(space),
externalIdentifier = externalIdentifier
)

parameter('before.as[String] ?) { maybeBefore =>
withFuture {
lookupVersions(
bagId = bagId,
maybeBeforeString = maybeBefore
)
}
}

case Failure(_) =>
notFound(
s"No storage manifest versions found for $space/$remaining"
)
}
}
}
},
// Look up a single manifest.
path(Segment / Remaining) {
(space, remaining) =>
get {
Expand All @@ -42,84 +71,65 @@ trait BagsApi
externalIdentifier = externalIdentifier
)

parameter('before.as[String] ?) { maybeBefore =>
withFuture {
lookupVersions(
bagId = bagId,
maybeBeforeString = maybeBefore
val chemistAndDruggist = BagId(
space = StorageSpace("digitised"),
externalIdentifier = ExternalIdentifier("b19974760")
)

// This is some special casing to handle Chemist & Druggist, which
// is enormous. If somebody tries to retrieve it, direct them straight
// to the cached response.
//
// We should fix the bags API so retrieving this API doesn't cause the
// app to run out of heap space/memory.
//
// See https://github.com/wellcomecollection/platform/issues/4549
bagId match {
case id if id == chemistAndDruggist =>
val url = s3PresignedUrls
.getPresignedGetURL(
location = S3ObjectLocation(
bucket =
"wellcomecollection-storage-prod-large-response-cache",
key = "responses/digitised/b19974760/v1"
),
expiryLength = 1 days
)
.right
.get

complete(
HttpResponse(
status = StatusCodes.TemporaryRedirect,
headers = Location(url.toExternalForm) :: Nil
)
)
}
case _ =>
parameter('version.as[String] ?) { maybeVersionString =>
withFuture {
lookupBag(
bagId = bagId,
maybeVersionString = maybeVersionString
)
}
}
}

case Failure(_) =>
notFound(
s"No storage manifest versions found for $space/$remaining"
)
notFound(s"Storage manifest $space/$remaining not found")
}
}
}
},
// Look up a single manifest.
path(Segment / Remaining) { (space, remaining) =>
)
},
pathPrefix("management") {
path("healthcheck") {
get {
Try { decodeExternalIdentifier(remaining) } match {
case Success(externalIdentifier) =>
val bagId = BagId(
space = StorageSpace(space),
externalIdentifier = externalIdentifier
)

val chemistAndDruggist = BagId(
space = StorageSpace("digitised"),
externalIdentifier = ExternalIdentifier("b19974760")
)

// This is some special casing to handle Chemist & Druggist, which
// is enormous. If somebody tries to retrieve it, direct them straight
// to the cached response.
//
// We should fix the bags API so retrieving this API doesn't cause the
// app to run out of heap space/memory.
//
// See https://github.com/wellcomecollection/platform/issues/4549
bagId match {
case id if id == chemistAndDruggist =>
val url = s3PresignedUrls
.getPresignedGetURL(
location = S3ObjectLocation(
bucket =
"wellcomecollection-storage-prod-large-response-cache",
key = "responses/digitised/b19974760/v1"
),
expiryLength = 1 days
)
.right
.get

complete(
HttpResponse(
status = StatusCodes.TemporaryRedirect,
headers = Location(url.toExternalForm) :: Nil
)
)
case _ =>
parameter('version.as[String] ?) { maybeVersionString =>
withFuture {
lookupBag(
bagId = bagId,
maybeVersionString = maybeVersionString
)
}
}
}

case Failure(_) =>
notFound(s"Storage manifest $space/$remaining not found")
}
complete("ok")
}
}
)
}
}
)

val bags: Route = wrapLargeResponses(routes)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@ trait IngestsApi[UnpackerDestination]
extends CreateIngest[UnpackerDestination]
with LookupIngest {

val ingests: Route = pathPrefix("ingests") {
post {
entity(as[RequestDisplayIngest]) { ingest =>
withFuture { createIngest(ingest) }
val ingests: Route = concat(
pathPrefix("ingests") {
post {
entity(as[RequestDisplayIngest]) { ingest =>
withFuture { createIngest(ingest) }
}
} ~ path(JavaUUID) { id: UUID =>
get {
withFuture { lookupIngest(id) }
}
}
} ~ path(JavaUUID) { id: UUID =>
get {
withFuture { lookupIngest(id) }
},
pathPrefix("management") {
path("healthcheck") {
get {
complete("ok")
}
}
}
}
)
}
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object ExternalDependencies {

// This should match the version of circe used in scala-json; see
// https://github.com/wellcomecollection/scala-json/blob/master/project/Dependencies.scala
val circeOptics = "0.13.0"
val circeOptics = "0.14.1"

// This should match the version of aws used in scala-libs; see
// https://github.com/wellcomecollection/scala-libs/blob/main/project/Dependencies.scala
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.1
sbt.version=1.9.8
2 changes: 1 addition & 1 deletion project/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalaVersion := "2.12.7"
scalaVersion := "2.12.15"
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.34")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.5")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")
addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.19.0")
addDependencyTreePlugin
6 changes: 3 additions & 3 deletions terraform/modules/service/bags/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module "base" {
}

module "nginx_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/nginx/apigw?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/nginx/apigw?ref=v4.0.0"

forward_port = var.container_port
log_configuration = module.base.log_configuration
Expand All @@ -51,7 +51,7 @@ module "nginx_container" {
}

module "app_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v4.0.0"
name = "app"

image = var.api_container_image
Expand All @@ -62,7 +62,7 @@ module "app_container" {
}

module "tracker_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v4.0.0"
name = "tracker"

image = var.tracker_container_image
Expand Down
4 changes: 3 additions & 1 deletion terraform/modules/service/bags/target_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ resource "aws_lb_target_group" "tcp" {
deregistration_delay = 90

health_check {
protocol = "TCP"
protocol = "HTTP"
path = var.healthcheck_path
matcher = "200"
}
}

Expand Down
5 changes: 5 additions & 0 deletions terraform/modules/service/bags/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ variable "nginx_container" {
container_tag = string
})
}

variable "healthcheck_path" {
type = string
default = "/management/healthcheck"
}
8 changes: 4 additions & 4 deletions terraform/modules/service/base/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "log_router_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/firelens?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/firelens?ref=v4.0.0"
namespace = var.service_name

container_registry = var.logging_container["container_registry"]
Expand All @@ -8,13 +8,13 @@ module "log_router_container" {
}

module "log_router_container_secrets_permissions" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v4.0.0"
secrets = module.log_router_container.shared_secrets_logging
role_name = module.task_definition.task_execution_role_name
}

module "task_definition" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/task_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/task_definition?ref=v4.0.0"

cpu = var.cpu
memory = var.memory
Expand All @@ -27,7 +27,7 @@ module "task_definition" {
}

module "service" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/service?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/service?ref=v4.0.0"

cluster_arn = var.cluster_arn
service_name = var.service_name
Expand Down
14 changes: 7 additions & 7 deletions terraform/modules/service/ingest/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module "base" {
}

module "nginx_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/nginx/apigw?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/nginx/apigw?ref=v4.0.0"

forward_port = var.external_api_container_port
log_configuration = module.base.log_configuration
Expand All @@ -56,7 +56,7 @@ module "nginx_container" {
}

module "external_api_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v4.0.0"
name = "api"

image = var.external_api_container_image
Expand All @@ -68,13 +68,13 @@ module "external_api_container" {
}

module "external_api_container_secrets_permissions" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v4.0.0"
secrets = var.external_api_secrets
role_name = module.base.task_execution_role_name
}

module "worker_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v4.0.0"
name = "worker"

image = var.worker_container_image
Expand All @@ -86,13 +86,13 @@ module "worker_container" {
}

module "worker_container_secrets_permissions" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v4.0.0"
secrets = var.worker_secrets
role_name = module.base.task_execution_role_name
}

module "internal_api_container" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/container_definition?ref=v4.0.0"
name = "tracker"

image = var.internal_api_container_image
Expand All @@ -104,7 +104,7 @@ module "internal_api_container" {
}

module "internal_api_container_secrets_permissions" {
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v3.13.1"
source = "git::github.com/wellcomecollection/terraform-aws-ecs-service.git//modules/secrets?ref=v4.0.0"
secrets = var.internal_api_secrets
role_name = module.base.task_execution_role_name
}
4 changes: 3 additions & 1 deletion terraform/modules/service/ingest/target_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ resource "aws_lb_target_group" "tcp" {
deregistration_delay = 90

health_check {
protocol = "TCP"
protocol = "HTTP"
path = var.healthcheck_path
matcher = "200"
}
}

Expand Down
Loading