Skip to content

Commit

Permalink
process-excuses: add some flags to schedule binNMUs even if packages …
Browse files Browse the repository at this point in the history
…are not fully ready
  • Loading branch information
sebastinas committed Mar 24, 2024
1 parent 5d1acb0 commit 91f3ec1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 17 deletions.
2 changes: 2 additions & 0 deletions assorted-debian-utils/src/excuses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ pub struct PolicyInfo {
pub age: Option<AgeInfo>,
/// The buildt-on-buildd policy
pub builtonbuildd: Option<BuiltOnBuildd>,
/// The autopkgtest porlicy
pub autopkgtest: Option<UnspecfiedPolicyInfo>,
/// All remaining policies
#[serde(flatten)]
pub extras: HashMap<String, UnspecfiedPolicyInfo>,
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use grep_excuses::{GrepExcuses, GrepExcusesOptions};
use nmu_eso::{NMUOutdatedBuiltUsing, NMUOutdatedBuiltUsingOptions};
use nmu_transition::{NMUTransition, NMUTransitionOptions};
use nmu_versionskew::{NMUVersionSkew, NMUVersionSkewOptions};
use process_excuses::ProcessExcuses;
use process_excuses::{ProcessExcuses, ProcessExcusesOptions};
use process_unblocks::ProcessUnblocks;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -82,7 +82,7 @@ struct DrtToolsOptions {
#[derive(Debug, Subcommand)]
enum DrtToolsCommands {
/// Process current excuses.yaml and prepare a list of binNMUs required for testing migration.
ProcessExcuses,
ProcessExcuses(ProcessExcusesOptions),
/// Prepare and schedule binNMUs for a transition.
///
/// This command expects a list of packages with their respective versions
Expand Down Expand Up @@ -190,8 +190,8 @@ async fn main() -> Result<()> {
config::Cache::new(opts.base_options.force_download, &opts.base_options.mirror).await?;
let command: Box<dyn AsyncCommand> =
match opts.command {
DrtToolsCommands::ProcessExcuses => {
Box::new(ProcessExcuses::new(&cache, &opts.base_options))
DrtToolsCommands::ProcessExcuses(pe_opts) => {
Box::new(ProcessExcuses::new(&cache, &opts.base_options, pe_opts))
}
DrtToolsCommands::NMUTransition(pbm_opts) => {
Box::new(NMUTransition::new(&cache, &opts.base_options, pbm_opts))
Expand Down
55 changes: 42 additions & 13 deletions src/process_excuses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use assorted_debian_utils::{
wb::{BinNMU, SourceSpecifier, WBArchitecture, WBCommand, WBCommandBuilder},
};
use async_trait::async_trait;
use clap::Parser;
use indicatif::{ProgressBar, ProgressIterator};
use log::{debug, error, info, trace, warn};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -39,20 +40,36 @@ impl ScheduledBinNMUs {
}
}

#[derive(Debug, Parser)]
pub(crate) struct ProcessExcusesOptions {
/// Ignore age to identify packages to rebuild.
#[clap(long)]
ignore_age: bool,
/// Ignore results from autopkgtests.
#[clap(long)]
ignore_autopkgtests: bool,
}

pub(crate) struct ProcessExcuses<'a> {
cache: &'a config::Cache,
base_options: &'a BaseOptions,
options: ProcessExcusesOptions,
}

impl<'a> ProcessExcuses<'a> {
pub(crate) fn new(cache: &'a config::Cache, base_options: &'a BaseOptions) -> Self {
pub(crate) fn new(
cache: &'a config::Cache,
base_options: &'a BaseOptions,
options: ProcessExcusesOptions,
) -> Self {
Self {
cache,
base_options,
options,
}
}

fn is_binnmu_required(policy_info: &PolicyInfo) -> bool {
fn is_binnmu_required(&self, policy_info: &PolicyInfo) -> bool {
if let Some(b) = &policy_info.builtonbuildd {
if b.verdict == Verdict::Pass {
// nothing to do
Expand All @@ -66,7 +83,9 @@ impl<'a> ProcessExcuses<'a> {
}
}
if let Some(a) = &policy_info.age {
if a.current_age < min(a.age_requirement / 2, a.age_requirement - 1) {
if !self.options.ignore_age
&& a.current_age < min(a.age_requirement / 2, a.age_requirement - 1)
{
// too young
trace!(
"no binnmu possible: too young: {} days (required: {} days)",
Expand All @@ -76,6 +95,12 @@ impl<'a> ProcessExcuses<'a> {
return false;
}
}
if let Some(autopkgtests) = &policy_info.autopkgtest {
if !self.options.ignore_autopkgtests && autopkgtests.verdict != Verdict::Pass {
trace!("no binnmu possible: autopkgtests are not passing/are pending");
return false;
}
}

// if the others do not pass, would not migrate even if binNMUed
policy_info.extras.values().all(|info| {
Expand All @@ -88,14 +113,18 @@ impl<'a> ProcessExcuses<'a> {
})
}

fn build_binnmu(item: &ExcusesItem, source_packages: &SourcePackages) -> Option<WBCommand> {
fn build_binnmu(
&self,
item: &ExcusesItem,
source_packages: &SourcePackages,
) -> Option<WBCommand> {
if !Self::is_actionable(item) {
debug!("{}: not actionable", item.source);
return None;
}

let policy_info = item.policy_info.as_ref()?;
if !Self::is_binnmu_required(policy_info) {
if !self.is_binnmu_required(policy_info) {
debug!("{}: binNMU not required", item.source);
return None;
}
Expand Down Expand Up @@ -142,35 +171,35 @@ impl<'a> ProcessExcuses<'a> {
fn is_actionable(item: &ExcusesItem) -> bool {
if item.is_removal() {
// skip removals
trace!("{} not actionable: removal", item.source);
info!("{} not actionable: removal", item.source);
return false;
}
if item.is_from_pu() {
// skip PU requests
trace!("{} not actionable: pu request", item.source);
info!("{} not actionable: pu request", item.source);
return false;
}
if item.is_from_tpu() {
// skip TPU requests
trace!("{} not actionable: tpu request", item.source);
info!("{} not actionable: tpu request", item.source);
return false;
}
match item.component {
Some(Component::Main) | None => {}
_ => {
Some(component) => {
// skip non-free and contrib
trace!("{} not actionable: in {:?}", item.source, item.component);
info!("{} not actionable: in {}", item.source, component);
return false;
}
}
if let Some(true) = item.invalidated_by_other_package {
// skip otherwise blocked packages
trace!("{} not actionable: invalided by other package", item.source);
info!("{} not actionable: invalided by other package", item.source);
return false;
}
if item.missing_builds.is_some() {
// skip packages with missing builds
trace!("{} not actionable: missing builds", item.source);
info!("{} not actionable: missing builds", item.source);
return false;
}

Expand Down Expand Up @@ -213,7 +242,7 @@ impl AsyncCommand for ProcessExcuses<'_> {
.sources
.iter()
.progress_with(pb)
.filter_map(|item| Self::build_binnmu(item, &source_packages))
.filter_map(|item| self.build_binnmu(item, &source_packages))
.filter(|command| {
if scheduled_binnmus.contains(command) {
info!("{}: skipping, already scheduled", command);
Expand Down

0 comments on commit 91f3ec1

Please sign in to comment.