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

Various improvements around logging & JSON #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl ObsJobHandler {
outputln!("Build was superceded by a newer revision.");
}
PackageCompletion::Disabled => {
outputln!("Package is disabled for this architecture.");
outputln!("Build is disabled for this architecture.");
}
PackageCompletion::Failed(reason) => {
log_file
Expand Down Expand Up @@ -1509,7 +1509,7 @@ mod tests {
// so don't check for an old build status.
let build_actually_occurred = dput_test != DputTest::ReusePreviousBuild;
assert_eq!(
job_log.contains("Waiting for build status"),
job_log.contains("waiting for updates"),
build_actually_occurred
);

Expand Down
26 changes: 18 additions & 8 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,22 @@ impl ObsMonitor {
match state {
PackageBuildState::Building(code) => {
if previous_code != Some(code) {
if previous_code.is_some() {
outputln!("Build status is now '{}'...", code);
} else {
outputln!("Monitoring build, current status is '{}'...", code);
if previous_code.is_none() {
outputln!("Monitoring build...");
}

outputln!("Build status is '{}'.", code);
previous_code = Some(code);
}

tokio::time::sleep(options.sleep_on_building).await;
}
PackageBuildState::Dirty => {
if !was_dirty {
outputln!("Package is dirty, trying again later...");
outputln!(
"Package build is dirty / being re-scheduled, \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Package build status is being re-calculated"?

waiting for updates..."
);
}

was_dirty = true;
Expand All @@ -235,11 +238,14 @@ impl ObsMonitor {
PackageBuildState::PendingStatusPosted => {
ensure!(
old_status_retries < options.max_old_status_retries,
"Old build status has been posted for too long."
"Outdated package build status has been posted for too long."
);

if old_status_retries == 0 {
outputln!("Waiting for build status to be available...");
outputln!(
"Package has the build status of a previous build, \
waiting for updates..."
);
}
old_status_retries += 1;

Expand Down Expand Up @@ -870,6 +876,10 @@ mod tests {
tokio::time::timeout(Duration::from_secs(5), monitor.monitor_package(options)).await
);
let err = assert_err!(result);
assert!(err.to_string().contains("Old build status"), "{:?}", err);
assert!(
err.to_string().contains("Outdated package build status"),
"{:?}",
err
);
}
}