fix metadata overwrite logic
This commit is contained in:
parent
c87888beb5
commit
14cf69331d
3 changed files with 23 additions and 32 deletions
|
|
@ -46,21 +46,21 @@ steps:
|
||||||
backend_options:
|
backend_options:
|
||||||
kubernetes:
|
kubernetes:
|
||||||
### PROD
|
### PROD
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
memory: 25Gi
|
|
||||||
cpu: 12000m
|
|
||||||
limits:
|
|
||||||
memory: 28Gi
|
|
||||||
cpu: 16000m
|
|
||||||
## DEBUG
|
|
||||||
# resources:
|
# resources:
|
||||||
# requests:
|
# requests:
|
||||||
# memory: 4Gi
|
# memory: 25Gi
|
||||||
# cpu: 2000m
|
# cpu: 12000m
|
||||||
# limits:
|
# limits:
|
||||||
# memory: 4Gi
|
# memory: 28Gi
|
||||||
# cpu: 2000m
|
# cpu: 16000m
|
||||||
|
# DEBUG
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 4Gi
|
||||||
|
cpu: 2000m
|
||||||
|
limits:
|
||||||
|
memory: 4Gi
|
||||||
|
cpu: 2000m
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/arch: 'arm64'
|
kubernetes.io/arch: 'arm64'
|
||||||
# - name: Upload PACKAGES files
|
# - name: Upload PACKAGES files
|
||||||
|
|
|
||||||
|
|
@ -93,12 +93,11 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
||||||
tryCatch(
|
tryCatch(
|
||||||
{
|
{
|
||||||
p()
|
p()
|
||||||
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir, platform = platform, debug = debug)
|
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir, platform = platform, debug = debug, force = force)
|
||||||
|
|
||||||
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
|
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
|
||||||
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
|
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
|
||||||
if (fs::file_exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
|
if (fs::file_exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
|
||||||
store_build_metadata(x, y, platform, error_occurred = FALSE, force = force)
|
|
||||||
cli::cli_alert_success("Successfully built package {.pkg {x}} with tag {.field {y}}.")
|
cli::cli_alert_success("Successfully built package {.pkg {x}} with tag {.field {y}}.")
|
||||||
} else {
|
} else {
|
||||||
cli::cli_alert_warning("Error in building package {.pkg {x}} with tag {.field {y}}: Uncommon/unspecific error during build.")
|
cli::cli_alert_warning("Error in building package {.pkg {x}} with tag {.field {y}}: Uncommon/unspecific error during build.")
|
||||||
|
|
@ -147,7 +146,8 @@ build_single_tag <- function(
|
||||||
platform,
|
platform,
|
||||||
dir_out_bin,
|
dir_out_bin,
|
||||||
local_clone_dir,
|
local_clone_dir,
|
||||||
debug = FALSE) {
|
debug = FALSE,
|
||||||
|
force = FALSE) {
|
||||||
cli::cli_alert("{.fun build_single_tag}: (1/3) Cloning package {.pkg {package_name}} with tag {.field {tag}}.")
|
cli::cli_alert("{.fun build_single_tag}: (1/3) Cloning package {.pkg {package_name}} with tag {.field {tag}}.")
|
||||||
|
|
||||||
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name, tag)
|
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name, tag)
|
||||||
|
|
@ -213,19 +213,9 @@ build_single_tag <- function(
|
||||||
cli::cli_alert_warning("DEBUG: file_size: {file_size}")
|
cli::cli_alert_warning("DEBUG: file_size: {file_size}")
|
||||||
}
|
}
|
||||||
|
|
||||||
# skip DB connection if package already exists
|
tarball_name <- sprintf("%s_%s.tar.gz", package_name, tag)
|
||||||
if (file.exists(sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag))) {
|
if (fs::file_exists(sprintf("%s/%s", dir_out_bin, tarball_name))) {
|
||||||
con <- DBI::dbConnect(RPostgres::Postgres(),
|
store_build_metadata(package_name, tag, platform, error_occurred = FALSE, force = force, build_duration = total_build_time, size = file_size)
|
||||||
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
|
|
||||||
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
|
|
||||||
)
|
|
||||||
dbExecute(con,
|
|
||||||
"UPDATE single_builds SET build_duration = $1, size = $2 WHERE package_name = $3 and platform = $4 and tag = $5",
|
|
||||||
params = list(
|
|
||||||
total_build_time, file_size, package_name, platform, tag
|
|
||||||
)
|
|
||||||
)
|
|
||||||
dbDisconnect(con)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#' @importFrom DBI dbConnect dbDisconnect dbWriteTable dbGetQuery dbExecute
|
#' @importFrom DBI dbConnect dbDisconnect dbWriteTable dbGetQuery dbExecute
|
||||||
store_build_metadata <- function(
|
store_build_metadata <- function(
|
||||||
package_name, tag, platform, error_occurred,
|
package_name, tag, platform, error_occurred,
|
||||||
force = FALSE, error = NA) {
|
force = FALSE, error = NA, build_duration = NA, size = NA) {
|
||||||
con <- DBI::dbConnect(RPostgres::Postgres(),
|
con <- DBI::dbConnect(RPostgres::Postgres(),
|
||||||
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
|
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
|
||||||
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
|
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
|
||||||
|
|
@ -19,8 +19,8 @@ store_build_metadata <- function(
|
||||||
} else if (nrow(existing_entries) >= 1 && force) {
|
} else if (nrow(existing_entries) >= 1 && force) {
|
||||||
cli::cli_alert_info("{.fun store_build_metadata}: Force overwriting build metadata for {.pkg {package_name}} {.field {tag}} because {.code force = TRUE} was set.")
|
cli::cli_alert_info("{.fun store_build_metadata}: Force overwriting build metadata for {.pkg {package_name}} {.field {tag}} because {.code force = TRUE} was set.")
|
||||||
|
|
||||||
DBI::dbExecute(con, "UPDATE single_builds SET build_timestamp = $1, error_occurred = $2, error = $3, WHERE package_name = $5 and tag = $6 and platform = $7",
|
DBI::dbExecute(con, "UPDATE single_builds SET build_timestamp = $1, error_occurred = $2, error = $3, build_duration = $4, size = $5 WHERE package_name = $6 and tag = $7 and platform = $8",
|
||||||
params = list(format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, error, package_name, tag, platform)
|
params = list(format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, error, build_duration, size, package_name, tag, platform)
|
||||||
)
|
)
|
||||||
} else if (nrow(existing_entries) == 0) {
|
} else if (nrow(existing_entries) == 0) {
|
||||||
cli::cli_alert("{.fun store_build_metadata}: Storing build metadata for {.pkg {package_name}} {.field {tag}}.")
|
cli::cli_alert("{.fun store_build_metadata}: Storing build metadata for {.pkg {package_name}} {.field {tag}}.")
|
||||||
|
|
@ -32,7 +32,8 @@ store_build_metadata <- function(
|
||||||
error_occurred = error_occurred,
|
error_occurred = error_occurred,
|
||||||
error = error,
|
error = error,
|
||||||
build_timestamp = format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
|
build_timestamp = format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
|
||||||
build_duration = NA
|
build_duration = build_duration,
|
||||||
|
size = size
|
||||||
)
|
)
|
||||||
# Write the data frame to the SQLite database
|
# Write the data frame to the SQLite database
|
||||||
dbWriteTable(con, "single_builds", metadata, append = TRUE)
|
dbWriteTable(con, "single_builds", metadata, append = TRUE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue