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 CLI arg to skip the update of the local registry #191

Merged
merged 5 commits into from
Feb 18, 2024
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
5 changes: 2 additions & 3 deletions .github/workflows/msd-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ jobs:
run: |
set -exuo pipefail
REGISTRY_DIR_MAIN="$HOME/tmp/main-registry"
REGISTRY_DIR_BRANCH="$HOME/tmp/branch-registry"
TARGETS_DIR_MAIN="$HOME/main-targets"
TARGETS_DIR_BRANCH="$HOME/branch-targets"
mkdir -p "$REGISTRY_DIR_MAIN" \
"$REGISTRY_DIR_BRANCH" \
"$TARGETS_DIR_MAIN" \
"$TARGETS_DIR_BRANCH"
chmod +x multiservice-discovery
Expand All @@ -48,7 +46,8 @@ jobs:
--render-prom-targets-to-stdout > "$TARGETS_DIR_MAIN/targets.json"
# Run multiservice-discovery for branch targets with bazel
bazel run //rs/ic-observability/multiservice-discovery -- \
--targets-dir "$REGISTRY_DIR_BRANCH" \
--targets-dir "$REGISTRY_DIR_MAIN" \
--skip-update-local-registry \
--render-prom-targets-to-stdout > "$TARGETS_DIR_BRANCH/targets.json"
echo "targets_main=$TARGETS_DIR_MAIN" >> $GITHUB_OUTPUT
echo "targets_branch=$TARGETS_DIR_BRANCH" >> $GITHUB_OUTPUT
Expand Down
29 changes: 22 additions & 7 deletions rs/ic-observability/multiservice-discovery/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use service_discovery::IcServiceDiscovery;
use service_discovery::IcServiceDiscoveryError;
use service_discovery::TargetGroup;
use service_discovery::{registry_sync::sync_local_registry, IcServiceDiscoveryImpl};
use slog::error;
use slog::{debug, info, warn, Logger};
use std::collections::BTreeMap;
use std::collections::BTreeSet;
Expand Down Expand Up @@ -143,13 +144,27 @@ impl TestDefinition {
}

/// Syncs the registry update the in-memory cache then stops.
pub async fn sync_and_stop(&self) {
let _ = self.running_def.initial_registry_sync().await;
// if self.initial_registry_sync().await.is_err() {
// FIXME: Error has been logged, but ideally, it should be handled.
// E.g. telemetry should collect this.
// return;
// }
pub async fn sync_and_stop(&self, skip_update_local_registry: bool) {
if let Err(e) = if skip_update_local_registry {
sync_local_registry(
pietrodimarco-dfinity marked this conversation as resolved.
Show resolved Hide resolved
self.running_def.definition.log.clone(),
self.running_def.definition.registry_path.join("targets"),
self.running_def.definition.nns_urls.clone(),
true,
self.running_def.definition.public_key,
&self.running_def.stop_signal,
)
.await
} else {
self.running_def.initial_registry_sync().await
} {
error!(
self.running_def.definition.log,
"Error while running initial sync for definition named '{}': {:?}", self.running_def.definition.name, e
);
return;
};

let _ = self
.running_def
.definition
Expand Down
12 changes: 11 additions & 1 deletion rs/ic-observability/multiservice-discovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
) -> Option<RunningDefinition> {
let def = get_mainnet_definition(cli_args, log.clone());
let mut test_def = TestDefinition::new(def, RunningDefinitionsMetrics::new());
let sync_fut = test_def.sync_and_stop();
let sync_fut = test_def.sync_and_stop(cli_args.skip_update_local_registry);
tokio::select! {
_ = sync_fut => {
info!(log, "Synchronization done");
Expand Down Expand Up @@ -207,6 +207,16 @@ the Prometheus targets of mainnet as a JSON structure on stdout.
)]
render_prom_targets_to_stdout: bool,

#[clap(
long = "skip-update-local-registry",
default_value = "false",
action,
help = r#"
Used for testing: Whether to skip the update of the local mainnet registry.
"#
)]
skip_update_local_registry: bool,

#[clap(
long = "networks-state-file",
default_value = None,
Expand Down
Loading