pub async fn start_update_check(&mut self, options: CheckOptions) {
        let apps = self.app_set.to_vec().await;
        let result = self.perform_update_check(options, self.context.clone(), apps).await;
        match &result {
            Ok(result) => {
                info!("Update check result: {:?}", result);
                // Update check succeeded, update |last_update_time|.
                self.context.schedule.last_update_time = clock::now();

                // Update the service dictated poll interval (which is an Option<>, so doesn't
                // need to be tested for existence here).
                self.context.state.server_dictated_poll_interval =
                    result.server_dictated_poll_interval;

                // Increment |consecutive_failed_update_attempts| if any app failed to install,
                // otherwise reset it to 0.
                if result
                    .app_responses
                    .iter()
                    .any(|app| app.result == update_check::Action::InstallPlanExecutionError)
                {
                    self.context.state.consecutive_failed_update_attempts += 1;
                } else {
                    self.context.state.consecutive_failed_update_attempts = 0;
                }

                // Update check succeeded, reset |consecutive_failed_update_checks| to 0.
                self.context.state.consecutive_failed_update_checks = 0;

                self.app_set.update_from_omaha(&result.app_responses).await;

                self.report_attempts_to_succeed(true).await;

                // TODO: update consecutive_proxied_requests
            }
            Err(error) => {
                error!("Update check failed: {:?}", error);
                // Update check failed, increment |consecutive_failed_update_checks|.
                self.context.state.consecutive_failed_update_checks += 1;

                let failure_reason = match error {
                    UpdateCheckError::ResponseParser(_) | UpdateCheckError::InstallPlan(_) => {
                        // We talked to Omaha, update |last_update_time|.
                        self.context.schedule.last_update_time = clock::now();

                        UpdateCheckFailureReason::Omaha
                    }
                    UpdateCheckError::Policy(_) => UpdateCheckFailureReason::Internal,
                    UpdateCheckError::OmahaRequest(request_error) => match request_error {
                        OmahaRequestError::Json(_) | OmahaRequestError::HttpBuilder(_) => {
                            UpdateCheckFailureReason::Internal
                        }
                        OmahaRequestError::Hyper(_) | OmahaRequestError::HttpStatus(_) => {
                            UpdateCheckFailureReason::Network
                        }
                    },
                };
                self.report_metrics(Metrics::UpdateCheckFailureReason(failure_reason));

                self.report_attempts_to_succeed(false).await;
            }
        }

        if let Some(observer) = &mut self.observer {
            observer.on_schedule_change(&self.context.schedule).await;
            observer.on_protocol_state_change(&self.context.state).await;
            observer.on_update_check_result(&result).await;
        }

        self.persist_data().await;

        if self.state == State::WaitingForReboot {
            info!("Rebooting the system at the end of a successful update");
            if let Err(e) = self.installer.perform_reboot().await {
                error!("Unable to reboot the system: {}", e);
            }
        } else {
            self.set_state(State::Idle).await;
        }
    }
/// Perform update check and handle the result, including updating the update check context
/// and cohort.
Perform update check and handle the result, including updating the update check context
and cohort.
Perform update check and handle the result including updating the update check context and cohort .
pub async fn start_update_check(&mut self, options: CheckOptions) {
        let apps = self.app_set.to_vec().await;
        let result = self.perform_update_check(options, self.context.clone(), apps).await;
        match &result {
            Ok(result) => {
                info!("Update check result: {:?}", result);
                // Update check succeeded, update |last_update_time|.
                self.context.schedule.last_update_time = clock::now();
                // Update the service dictated poll interval (which is an Option<>, so doesn't
                // need to be tested for existence here).
                self.context.state.server_dictated_poll_interval =
                    result.server_dictated_poll_interval;
                // Increment |consecutive_failed_update_attempts| if any app failed to install,
                // otherwise reset it to 0.
                if result
                    .app_responses
                    .iter()
                    .any(|app| app.result == update_check::Action::InstallPlanExecutionError)
                {
                    self.context.state.consecutive_failed_update_attempts += 1;
                } else {
                    self.context.state.consecutive_failed_update_attempts = 0;
                }
                // Update check succeeded, reset |consecutive_failed_update_checks| to 0.
                self.context.state.consecutive_failed_update_checks = 0;
                self.app_set.update_from_omaha(&result.app_responses).await;
                self.report_attempts_to_succeed(true).await;
                // TODO: update consecutive_proxied_requests
            }
            Err(error) => {
                error!("Update check failed: {:?}", error);
                // Update check failed, increment |consecutive_failed_update_checks|.
                self.context.state.consecutive_failed_update_checks += 1;
                let failure_reason = match error {
                    UpdateCheckError::ResponseParser(_) | UpdateCheckError::InstallPlan(_) => {
                        // We talked to Omaha, update |last_update_time|.
                        self.context.schedule.last_update_time = clock::now();
                        UpdateCheckFailureReason::Omaha
                    }
                    UpdateCheckError::Policy(_) => UpdateCheckFailureReason::Internal,
                    UpdateCheckError::OmahaRequest(request_error) => match request_error {
                        OmahaRequestError::Json(_) | OmahaRequestError::HttpBuilder(_) => {
                            UpdateCheckFailureReason::Internal
                        }
                        OmahaRequestError::Hyper(_) | OmahaRequestError::HttpStatus(_) => {
                            UpdateCheckFailureReason::Network
                        }
                    },
                };
                self.report_metrics(Metrics::UpdateCheckFailureReason(failure_reason));
                self.report_attempts_to_succeed(false).await;
            }
        }
        if let Some(observer) = &mut self.observer {
            observer.on_schedule_change(&self.context.schedule).await;
            observer.on_protocol_state_change(&self.context.state).await;
            observer.on_update_check_result(&result).await;
        }
        self.persist_data().await;
        if self.state == State::WaitingForReboot {
            info!("Rebooting the system at the end of a successful update");
            if let Err(e) = self.installer.perform_reboot().await {
                error!("Unable to reboot the system: {}", e);
            }
        } else {
            self.set_state(State::Idle).await;
        }
    }
pub async fn start_update_check ( & mut self , options : CheckOptions ) { let apps = self . app_set . to_vec ( ) . await ; let result = self . perform_update_check ( options , self . context . clone ( ) , apps ) . await ; match & result { Ok ( result ) => { info ! ( " " result ) ; // Update check succeeded, update |last_update_time|. self . context . schedule . last_update_time = clock :: now ( ) ; // Update the service dictated poll interval (which is an Option<>, so doesn't // need to be tested for existence here). self . context . state . server_dictated_poll_interval = result . server_dictated_poll_interval ; // Increment |consecutive_failed_update_attempts| if any app failed to install, // otherwise reset it to 0. if result . app_responses . iter ( ) . any ( | app | app . result == update_check :: Action :: InstallPlanExecutionError ) { self . context . state . consecutive_failed_update_attempts += 1 ; } else { self . context . state . consecutive_failed_update_attempts = 0 ; } // Update check succeeded, reset |consecutive_failed_update_checks| to 0. self . context . state . consecutive_failed_update_checks = 0 ; self . app_set . update_from_omaha ( & result . app_responses ) . await ; self . report_attempts_to_succeed ( true ) . await ; // TODO: update consecutive_proxied_requests } Err ( error ) => { error ! ( " " error ) ; // Update check failed, increment |consecutive_failed_update_checks|. self . context . state . consecutive_failed_update_checks += 1 ; let failure_reason = match error { UpdateCheckError :: ResponseParser ( _ ) | UpdateCheckError :: InstallPlan ( _ ) => { // We talked to Omaha, update |last_update_time|. self . context . schedule . last_update_time = clock :: now ( ) ; UpdateCheckFailureReason :: Omaha } UpdateCheckError :: Policy ( _ ) => UpdateCheckFailureReason :: Internal , UpdateCheckError :: OmahaRequest ( request_error ) => match request_error { OmahaRequestError :: Json ( _ ) | OmahaRequestError :: HttpBuilder ( _ ) => { UpdateCheckFailureReason :: Internal } OmahaRequestError :: Hyper ( _ ) | OmahaRequestError :: HttpStatus ( _ ) => { UpdateCheckFailureReason :: Network } } , } ; self . report_metrics ( Metrics :: UpdateCheckFailureReason ( failure_reason ) ) ; self . report_attempts_to_succeed ( false ) . await ; } } if let Some ( observer ) = & mut self . observer { observer . on_schedule_change ( & self . context . schedule ) . await ; observer . on_protocol_state_change ( & self . context . state ) . await ; observer . on_update_check_result ( & result ) . await ; } self . persist_data ( ) . await ; if self . state == State :: WaitingForReboot { info ! ( " " ) ; if let Err ( e ) = self . installer . perform_reboot ( ) . await { error ! ( " " e ) ; } } else { self . set_state ( State :: Idle ) . await ; } }
Perform update check and handle the result, including updating the update check context
and cohort.
Perform update check and handle the result including updating the update check context and cohort .
&mut self
options
CheckOptions
&mut self
options
CheckOptions