agent: some better logging

renovate/rouge-4.x
Jef Roosens 2022-12-14 16:33:50 +01:00
parent d7a04c6ebf
commit 51df1874f5
Signed by untrusted user: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 9 additions and 6 deletions

View File

@ -146,7 +146,7 @@ fn (mut d AgentDaemon) start_build(config BuildConfig) bool {
// run_build actually starts the build process for a given target. // run_build actually starts the build process for a given target.
fn (mut d AgentDaemon) run_build(build_index int, config BuildConfig) { fn (mut d AgentDaemon) run_build(build_index int, config BuildConfig) {
d.linfo('started build: $config.url -> $config.repo') d.linfo('started build: $config')
// 0 means success, 1 means failure // 0 means success, 1 means failure
mut status := 0 mut status := 0
@ -164,16 +164,14 @@ fn (mut d AgentDaemon) run_build(build_index int, config BuildConfig) {
} }
if status == 0 { if status == 0 {
d.linfo('finished build: $config.url -> $config.repo; uploading logs...') d.linfo('Uploading build logs for $config')
// TODO use the arch value here // TODO use the arch value here
build_arch := os.uname().machine build_arch := os.uname().machine
d.client.add_build_log(config.target_id, res.start_time, res.end_time, build_arch, d.client.add_build_log(config.target_id, res.start_time, res.end_time, build_arch,
res.exit_code, res.logs) or { res.exit_code, res.logs) or { d.lerror('Failed to upload logs for $config') }
d.lerror('Failed to upload logs for build: $config.url -> $config.repo')
}
} else { } else {
d.linfo('an error occured during build: $config.url -> $config.repo') d.lwarn('an error occurred during build: $config')
} }
stdatomic.store_u64(&d.atomics[build_index], agent.build_done) stdatomic.store_u64(&d.atomics[build_index], agent.build_done)

View File

@ -27,6 +27,11 @@ pub:
force bool force bool
} }
// str return a single-line string representation of a build log
pub fn (c BuildConfig) str() string {
return '{ target: $c.target_id, kind: $c.kind, url: $c.url, branch: $c.branch, repo: $c.repo, base_image: $c.base_image, force: $c.force }'
}
// create_build_image creates a builder image given some base image which can // create_build_image creates a builder image given some base image which can
// then be used to build & package Arch images. It mostly just updates the // then be used to build & package Arch images. It mostly just updates the
// system, install some necessary packages & creates a non-root user to run // system, install some necessary packages & creates a non-root user to run