pub async fn start(args: OrchestratorArgs) -> Result<Self, ()> {
        args.create_dirs();
        let metrics_addr = args.get_metrics_addr();
        let config = args.get_ic_config();
        let (_node_pks, node_id) = get_node_keys_or_generate_if_missing(&config.crypto.crypto_root);

        let (logger, _async_log_guard) = Self::get_logger(&config);
        let slog_logger = logger.inner_logger.root.clone();
        let metrics_registry = MetricsRegistry::global();
        let current_orchestrator_hash = utils::get_orchestrator_binary_hash()
            .expect("Failed to determine sha256 of orchestrator binary");

        info!(
            logger,
            "Running orchestrator ({:?} sha256 hash: {:?}) with upgrade support, config is: {:?}",
            env::current_exe(),
            current_orchestrator_hash,
            config
        );

        let registry = Arc::new(RegistryHelper::new_with(
            &metrics_registry,
            &config,
            node_id,
            logger.clone(),
        ));

        let crypto = Arc::new(setup_crypto(
            &config.crypto,
            registry.get_registry_client(),
            logger.clone(),
        ));

        let cup_provider = Arc::new(CatchUpPackageProvider::new(
            Arc::clone(&registry),
            args.cup_dir.clone(),
            crypto.clone(),
            logger.clone(),
        ));

        let replica_version = load_version_from_file(&logger, &args.version_file)?;

        // we only support the local store data provider
        let local_store_path = if let DataProviderConfig::LocalStore(path) = config
            .registry_client
            .data_provider
            .clone()
            .expect("registry data provider is not configured")
        {
            path
        } else {
            panic!("Only LocalStore is supported in the orchestrator.");
        };

        let (metrics, _metrics_runtime) = Self::get_metrics(
            metrics_addr,
            &slog_logger,
            &metrics_registry,
            registry.get_registry_client(),
            crypto.clone(),
        );
        let metrics = Arc::new(metrics);

        let registry_local_store = Arc::new(LocalStoreImpl::new(local_store_path));
        let mut registration = NodeRegistration::new(
            logger.clone(),
            config.clone(),
            Arc::clone(&registry.registry_client),
            Arc::clone(&crypto) as Arc<dyn KeyManager>,
            registry_local_store.clone(),
        );
        // initialize the registry local store. Will not return if the nns is not
        // reachable.
        registration.initialize_local_store().await;

        let nns_registry_replicator = Arc::new(NnsRegistryReplicator::new(
            logger.clone(),
            node_id,
            registry.get_registry_client(),
            registry_local_store as Arc<dyn LocalStore>,
            std::time::Duration::from_millis(config.nns_registry_replicator.poll_delay_duration_ms),
        ));

        if let Err(err) = nns_registry_replicator.fetch_and_start_polling() {
            warn!(logger, "{}", err);
        }

        if args.enable_provisional_registration {
            // will not return until the node is registered
            registration.register_node().await;
        }

        let release_package_provider = Arc::new(ReleasePackageProvider::new(
            Arc::clone(&registry),
            args.replica_binary_dir.clone(),
            args.force_replica_binary.clone(),
            logger.clone(),
        ));

        let slog_logger = logger.inner_logger.root.clone();
        let replica_process = Arc::new(Mutex::new(ReplicaProcess::new(slog_logger.clone())));
        let ic_binary_directory = args
            .ic_binary_directory
            .as_ref()
            .unwrap_or(&PathBuf::from("/tmp"))
            .clone();

        let release_package = ReleasePackage::start(
            Arc::clone(&registry),
            replica_process.clone(),
            release_package_provider,
            cup_provider,
            replica_version,
            args.replica_config_file.clone(),
            node_id,
            ic_binary_directory.clone(),
            nns_registry_replicator,
            logger.clone(),
        )
        .await;
        let firewall = Firewall::new(
            Arc::clone(&registry),
            Arc::clone(&metrics),
            config.firewall.clone(),
            logger.clone(),
        )
        .start();
        let ssh_access_manager =
            SshAccessManager::new(Arc::clone(&registry), Arc::clone(&metrics), logger.clone())
                .start();
        Ok(Self {
            logger,
            _async_log_guard,
            _metrics_runtime,
            _crypto: crypto,
            release_package,
            replica_process,
            firewall,
            ssh_access_manager,
        })
    }
/// Start the Orchestrator
///
/// This starts 2 tasks for upgrades: one which runs and monitors
/// a Replica process, and another that constantly monitors for a
/// new release package that this node should upgrade to and
/// executes the upgrade to this new release.
///
/// It spawns a third task that monitors the registry for new
/// data centers. If a new data center is added, orchestrator will
/// generate a new firewall configuration allowing access from the
/// IP range specified in the DC record.
Start the Orchestrator
This starts 2 tasks for upgrades: one which runs and monitors
a Replica process, and another that constantly monitors for a
new release package that this node should upgrade to and
executes the upgrade to this new release.

It spawns a third task that monitors the registry for new
data centers. If a new data center is added, orchestrator will
generate a new firewall configuration allowing access from the
IP range specified in the DC record.
Start the Orchestrator This starts 2 tasks for upgrades : one which runs and monitors a Replica process and another that constantly monitors for a new release package that this node should upgrade to and executes the upgrade to this new release . It spawns a third task that monitors the registry for new data centers . If a new data center is added orchestrator will generate a new firewall configuration allowing access from the IP range specified in the DC record .
pub async fn start(args: OrchestratorArgs) -> Result<Self, ()> {
        args.create_dirs();
        let metrics_addr = args.get_metrics_addr();
        let config = args.get_ic_config();
        let (_node_pks, node_id) = get_node_keys_or_generate_if_missing(&config.crypto.crypto_root);
        let (logger, _async_log_guard) = Self::get_logger(&config);
        let slog_logger = logger.inner_logger.root.clone();
        let metrics_registry = MetricsRegistry::global();
        let current_orchestrator_hash = utils::get_orchestrator_binary_hash()
            .expect("Failed to determine sha256 of orchestrator binary");
        info!(
            logger,
            "Running orchestrator ({:?} sha256 hash: {:?}) with upgrade support, config is: {:?}",
            env::current_exe(),
            current_orchestrator_hash,
            config
        );
        let registry = Arc::new(RegistryHelper::new_with(
            &metrics_registry,
            &config,
            node_id,
            logger.clone(),
        ));
        let crypto = Arc::new(setup_crypto(
            &config.crypto,
            registry.get_registry_client(),
            logger.clone(),
        ));
        let cup_provider = Arc::new(CatchUpPackageProvider::new(
            Arc::clone(&registry),
            args.cup_dir.clone(),
            crypto.clone(),
            logger.clone(),
        ));
        let replica_version = load_version_from_file(&logger, &args.version_file)?;
        // we only support the local store data provider
        let local_store_path = if let DataProviderConfig::LocalStore(path) = config
            .registry_client
            .data_provider
            .clone()
            .expect("registry data provider is not configured")
        {
            path
        } else {
            panic!("Only LocalStore is supported in the orchestrator.");
        };
        let (metrics, _metrics_runtime) = Self::get_metrics(
            metrics_addr,
            &slog_logger,
            &metrics_registry,
            registry.get_registry_client(),
            crypto.clone(),
        );
        let metrics = Arc::new(metrics);
        let registry_local_store = Arc::new(LocalStoreImpl::new(local_store_path));
        let mut registration = NodeRegistration::new(
            logger.clone(),
            config.clone(),
            Arc::clone(&registry.registry_client),
            Arc::clone(&crypto) as Arc<dyn KeyManager>,
            registry_local_store.clone(),
        );
        // initialize the registry local store. Will not return if the nns is not
        // reachable.
        registration.initialize_local_store().await;
        let nns_registry_replicator = Arc::new(NnsRegistryReplicator::new(
            logger.clone(),
            node_id,
            registry.get_registry_client(),
            registry_local_store as Arc<dyn LocalStore>,
            std::time::Duration::from_millis(config.nns_registry_replicator.poll_delay_duration_ms),
        ));
        if let Err(err) = nns_registry_replicator.fetch_and_start_polling() {
            warn!(logger, "{}", err);
        }
        if args.enable_provisional_registration {
            // will not return until the node is registered
            registration.register_node().await;
        }
        let release_package_provider = Arc::new(ReleasePackageProvider::new(
            Arc::clone(&registry),
            args.replica_binary_dir.clone(),
            args.force_replica_binary.clone(),
            logger.clone(),
        ));
        let slog_logger = logger.inner_logger.root.clone();
        let replica_process = Arc::new(Mutex::new(ReplicaProcess::new(slog_logger.clone())));
        let ic_binary_directory = args
            .ic_binary_directory
            .as_ref()
            .unwrap_or(&PathBuf::from("/tmp"))
            .clone();
        let release_package = ReleasePackage::start(
            Arc::clone(&registry),
            replica_process.clone(),
            release_package_provider,
            cup_provider,
            replica_version,
            args.replica_config_file.clone(),
            node_id,
            ic_binary_directory.clone(),
            nns_registry_replicator,
            logger.clone(),
        )
        .await;
        let firewall = Firewall::new(
            Arc::clone(&registry),
            Arc::clone(&metrics),
            config.firewall.clone(),
            logger.clone(),
        )
        .start();
        let ssh_access_manager =
            SshAccessManager::new(Arc::clone(&registry), Arc::clone(&metrics), logger.clone())
                .start();
        Ok(Self {
            logger,
            _async_log_guard,
            _metrics_runtime,
            _crypto: crypto,
            release_package,
            replica_process,
            firewall,
            ssh_access_manager,
        })
    }
pub async fn start ( args : OrchestratorArgs ) -> Result < Self , ( ) > { args . create_dirs ( ) ; let metrics_addr = args . get_metrics_addr ( ) ; let config = args . get_ic_config ( ) ; let ( _node_pks , node_id ) = get_node_keys_or_generate_if_missing ( & config . crypto . crypto_root ) ; let ( logger , _async_log_guard ) = Self :: get_logger ( & config ) ; let slog_logger = logger . inner_logger . root . clone ( ) ; let metrics_registry = MetricsRegistry :: global ( ) ; let current_orchestrator_hash = utils :: get_orchestrator_binary_hash ( ) . expect ( " " ) ; info ! ( logger " " env current_exe ( ) current_orchestrator_hash config ) ; let registry = Arc :: new ( RegistryHelper :: new_with ( & metrics_registry , & config , node_id , logger . clone ( ) , ) ) ; let crypto = Arc :: new ( setup_crypto ( & config . crypto , registry . get_registry_client ( ) , logger . clone ( ) , ) ) ; let cup_provider = Arc :: new ( CatchUpPackageProvider :: new ( Arc :: clone ( & registry ) , args . cup_dir . clone ( ) , crypto . clone ( ) , logger . clone ( ) , ) ) ; let replica_version = load_version_from_file ( & logger , & args . version_file ) ? ; // we only support the local store data provider let local_store_path = if let DataProviderConfig :: LocalStore ( path ) = config . registry_client . data_provider . clone ( ) . expect ( " " ) { path } else { panic ! ( " " ) ; } ; let ( metrics , _metrics_runtime ) = Self :: get_metrics ( metrics_addr , & slog_logger , & metrics_registry , registry . get_registry_client ( ) , crypto . clone ( ) , ) ; let metrics = Arc :: new ( metrics ) ; let registry_local_store = Arc :: new ( LocalStoreImpl :: new ( local_store_path ) ) ; let mut registration = NodeRegistration :: new ( logger . clone ( ) , config . clone ( ) , Arc :: clone ( & registry . registry_client ) , Arc :: clone ( & crypto ) as Arc < dyn KeyManager > , registry_local_store . clone ( ) , ) ; // initialize the registry local store. Will not return if the nns is not // reachable. registration . initialize_local_store ( ) . await ; let nns_registry_replicator = Arc :: new ( NnsRegistryReplicator :: new ( logger . clone ( ) , node_id , registry . get_registry_client ( ) , registry_local_store as Arc < dyn LocalStore > , std :: time :: Duration :: from_millis ( config . nns_registry_replicator . poll_delay_duration_ms ) , ) ) ; if let Err ( err ) = nns_registry_replicator . fetch_and_start_polling ( ) { warn ! ( logger " " err ) ; } if args . enable_provisional_registration { // will not return until the node is registered registration . register_node ( ) . await ; } let release_package_provider = Arc :: new ( ReleasePackageProvider :: new ( Arc :: clone ( & registry ) , args . replica_binary_dir . clone ( ) , args . force_replica_binary . clone ( ) , logger . clone ( ) , ) ) ; let slog_logger = logger . inner_logger . root . clone ( ) ; let replica_process = Arc :: new ( Mutex :: new ( ReplicaProcess :: new ( slog_logger . clone ( ) ) ) ) ; let ic_binary_directory = args . ic_binary_directory . as_ref ( ) . unwrap_or ( & PathBuf :: from ( " " ) ) . clone ( ) ; let release_package = ReleasePackage :: start ( Arc :: clone ( & registry ) , replica_process . clone ( ) , release_package_provider , cup_provider , replica_version , args . replica_config_file . clone ( ) , node_id , ic_binary_directory . clone ( ) , nns_registry_replicator , logger . clone ( ) , ) . await ; let firewall = Firewall :: new ( Arc :: clone ( & registry ) , Arc :: clone ( & metrics ) , config . firewall . clone ( ) , logger . clone ( ) , ) . start ( ) ; let ssh_access_manager = SshAccessManager :: new ( Arc :: clone ( & registry ) , Arc :: clone ( & metrics ) , logger . clone ( ) ) . start ( ) ; Ok ( Self { logger , _async_log_guard , _metrics_runtime , _crypto : crypto , release_package , replica_process , firewall , ssh_access_manager , } ) }
Start the Orchestrator
This starts 2 tasks for upgrades: one which runs and monitors
a Replica process, and another that constantly monitors for a
new release package that this node should upgrade to and
executes the upgrade to this new release.
Start the Orchestrator This starts 2 tasks for upgrades : one which runs and monitors a Replica process and another that constantly monitors for a new release package that this node should upgrade to and executes the upgrade to this new release .
args
OrchestratorArgs
args
OrchestratorArgs