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

Better offline support in AWS implementation #44

Merged
merged 3 commits into from
Feb 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class S3BuildCacheService(
}

override fun store(key: BuildCacheKey, writer: BuildCacheEntryWriter) {
if (writer.size == 0L) return // do not store empty entries into the cache
liutikas marked this conversation as resolved.
Show resolved Hide resolved
logger.info("Storing ${key.blobKey()}")
val cacheKey = key.blobKey()
val output = ByteArrayOutputStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ class S3StorageService(
}

override fun validateConfiguration() {
val buckets = client.listBuckets().buckets()
if (buckets.none { bucket -> bucket.name() == bucketName }) {
throw Exception("Bucket $bucketName under project $region cannot be found or it is not accessible using the provided credentials")
try {
val buckets = client.listBuckets().buckets()
if (buckets.none { bucket -> bucket.name() == bucketName }) {
throw Exception("Bucket $bucketName under project $region cannot be found or is not accessible using the provided credentials")
}
} catch (e: Exception) {
logger.warn("Couldn't validate S3 client config: ${e.message}")
}
}

Expand All @@ -127,6 +131,7 @@ class S3StorageService(
return try {
val inputStream = client.getObject(request)
val blob = inputStream.response() ?: return null
if (blob.contentLength() == 0L) return null // return empty entries as a cache miss
liutikas marked this conversation as resolved.
Show resolved Hide resolved
if (blob.contentLength() > sizeThreshold) {
val path = FileHandleInputStream.create()
val outputStream = path.outputStream()
Expand Down Expand Up @@ -162,7 +167,12 @@ class S3StorageService(
}

private fun delete(client: S3Client, request: DeleteObjectRequest): Boolean {
return client.deleteObject(request).deleteMarker()
return try {
client.deleteObject(request).deleteMarker()
} catch (e: Exception) {
logger.debug("Unable to delete $request", e)
false
}
}
}
}
Loading