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

Add Fixed-Rate Polling Specifier To ReportCollector #1492

Merged
merged 2 commits into from
Dec 12, 2024
Merged
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
9 changes: 9 additions & 0 deletions ipa-core/src/bin/report_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
/// Number of records to aggregate
#[clap(long, short = 'n')]
count: u32,

// If set, use the specified fixed polling interval when running a query.
// Otherwise, use exponential backoff.
#[arg(long, default_value_t = 0)]
set_fixed_polling_ms: u64,

Check warning on line 158 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L158

Added line #L158 was not covered by tests
Copy link
Collaborator

@akoshelev akoshelev Dec 12, 2024

Choose a reason for hiding this comment

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

is Option<u64> better to represent this value being not set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, yeah, probably

},
}

Expand Down Expand Up @@ -264,13 +269,15 @@
ref encrypted_inputs,
hybrid_query_config,
count,
set_fixed_polling_ms,

Check warning on line 272 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L272

Added line #L272 was not covered by tests
} => {
hybrid(
&args,
hybrid_query_config,
clients,
encrypted_inputs,
count.try_into().expect("u32 should fit into usize"),
set_fixed_polling_ms,

Check warning on line 280 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L280

Added line #L280 was not covered by tests
)
.await?
}
Expand Down Expand Up @@ -421,6 +428,7 @@
helper_clients: Vec<[IpaHttpClient<Helper>; 3]>,
encrypted_inputs: &EncryptedInputs,
count: usize,
set_fixed_polling_ms: u64,

Check warning on line 431 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L431

Added line #L431 was not covered by tests
) -> Result<(), Box<dyn Error>> {
let query_type = QueryType::MaliciousHybrid(hybrid_query_config);

Expand Down Expand Up @@ -471,6 +479,7 @@
helper_clients,
query_id,
hybrid_query_config,
set_fixed_polling_ms,

Check warning on line 482 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L482

Added line #L482 was not covered by tests
)
.await;

Expand Down
12 changes: 10 additions & 2 deletions ipa-core/src/cli/playbook/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
clients: Vec<[IpaHttpClient<Helper>; 3]>,
query_id: QueryId,
query_config: HybridQueryParams,
set_fixed_polling_ms: u64,

Check warning on line 34 in ipa-core/src/cli/playbook/hybrid.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/cli/playbook/hybrid.rs#L34

Added line #L34 was not covered by tests
) -> HybridQueryResult
where
HV: SharedValue + U128Conversions,
Expand All @@ -55,8 +56,13 @@
.unwrap();

let leader_clients = &clients[0];
let exponential_backoff = set_fixed_polling_ms == 0;
let mut delay = if exponential_backoff {
Duration::from_millis(125)

Check warning on line 61 in ipa-core/src/cli/playbook/hybrid.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/cli/playbook/hybrid.rs#L59-L61

Added lines #L59 - L61 were not covered by tests
} else {
Duration::from_millis(set_fixed_polling_ms)

Check warning on line 63 in ipa-core/src/cli/playbook/hybrid.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/cli/playbook/hybrid.rs#L63

Added line #L63 was not covered by tests
};

let mut delay = Duration::from_millis(125);
loop {
if try_join_all(
leader_clients
Expand All @@ -72,7 +78,9 @@
}

sleep(delay).await;
delay = min(Duration::from_secs(5), delay * 2);
if exponential_backoff {
delay = min(Duration::from_secs(5), delay * 2);
}

Check warning on line 83 in ipa-core/src/cli/playbook/hybrid.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/cli/playbook/hybrid.rs#L81-L83

Added lines #L81 - L83 were not covered by tests
// TODO: Add a timeout of some sort. Possibly, add some sort of progress indicator to
// the status API so we can check whether the query is making progress.
}
Expand Down
Loading