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

fix: prevent processor from attempting to run an empty select_all #211

Merged
merged 5 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions agents/processor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Unreleased

- bug: add check for empty intersection of specified and subsidized
- refactor: processor now uses global AWS client when proof pushing is enabled
- prevent processor from retrying messages it has previously attempted to
process
Expand Down
16 changes: 13 additions & 3 deletions agents/processor/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,21 @@ impl NomadAgent for Processor {
where
Self: Sized,
{
// we filter this so that the agent doesn't think it should subsidize
// remotes it is unaware of
let subsidized_remotes = settings
.agent
.subsidized_remotes
.iter()
.filter(|r| settings.base.replicas.contains_key(*r))
.cloned()
.collect();
Ok(Self::new(
settings.agent.interval,
settings.as_ref().try_into_core(AGENT_NAME).await?,
settings.agent.allowed,
settings.agent.denied,
settings.agent.subsidized_remotes,
subsidized_remotes,
settings.agent.s3,
))
}
Expand Down Expand Up @@ -416,8 +425,9 @@ impl NomadAgent for Processor {
.iter()
.map(|x| x.as_str())
.collect();

tasks.push(self.run_many(&specified_subsidized));
if !specified_subsidized.is_empty() {
tasks.push(self.run_many(&specified_subsidized));
}
prestwich marked this conversation as resolved.
Show resolved Hide resolved
}

// if we have a bucket, add a task to push to it
Expand Down
2 changes: 2 additions & 0 deletions nomad-base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Unreleased

- bug: add checks for empty replica name arrays in `NomadAgent::run_many` and
`NomadAgent::run_all`
- add `previously_attempted` to the DB schema
- remove `enabled` flag from agents project-wide
- adds a changelog
11 changes: 11 additions & 0 deletions nomad-base/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ pub trait NomadAgent: Send + Sync + Sized + std::fmt::Debug + AsRef<AgentCore> {
#[allow(clippy::unit_arg)]
fn run_many(&self, replicas: &[&str]) -> Instrumented<JoinHandle<Result<()>>> {
let span = info_span!("run_many");

// easy check that the slice is non-empty
replicas
.first()
.expect("Attempted to run without any replicas");

let handles: Vec<_> = replicas
.iter()
.map(|replica| self.run_report_error(replica.to_string()))
Expand Down Expand Up @@ -196,6 +202,11 @@ pub trait NomadAgent: Send + Sync + Sized + std::fmt::Debug + AsRef<AgentCore> {
// this is the unused must use
let names: Vec<&str> = self.replicas().keys().map(|k| k.as_str()).collect();

// quick check that at least 1 replica is configured
names
.first()
.expect("Attempted to run without any replicas");

let run_task = self.run_many(&names);
let mut tasks = vec![run_task];

Expand Down