async fn tick_finalize_update(&self, state: &mut UpdateAgentMachineState, release: Release) {
        trace!("trying to finalize an update");
        FINALIZATION_ATTEMPTS.inc();

        let strategy_can_finalize = self.strategy.can_finalize().await;
        if !strategy_can_finalize {
            utils::update_unit_status(&format!(
                "update staged: {}; reboot pending due to update strategy",
                &release.version
            ));
            // Reset number of postponements to `MAX_FINALIZE_POSTPONEMENTS`
            // if strategy does not allow finalization.
            state.update_staged(release);
            return;
        }

        let usersessions_can_finalize = state.usersessions_can_finalize();
        if !usersessions_can_finalize {
            FINALIZATION_BLOCKED
                .with_label_values(&[ACTIVE_USERSESSIONS_LABEL])
                .inc();
            utils::update_unit_status(&format!(
                "update staged: {}; reboot delayed due to active user sessions",
                release.version
            ));
            // Record postponement and postpone finalization.
            state.record_postponement();
            return;
        }

        match self.finalize_deployment(release).await {
            Ok(release) => {
                FINALIZATION_SUCCESS.inc();
                let status_msg = format!("update finalized: {}", release.version);
                log::info!("{}", &status_msg);
                state.update_finalized(release);
                utils::update_unit_status(&status_msg);
            }
            Err(e) => log::error!("failed to finalize deployment: {}", e),
        }
    }
/// Try to finalize an update.
Try to finalize an update.
Try to finalize an update .
async fn tick_finalize_update(&self, state: &mut UpdateAgentMachineState, release: Release) {
        trace!("trying to finalize an update");
        FINALIZATION_ATTEMPTS.inc();
        let strategy_can_finalize = self.strategy.can_finalize().await;
        if !strategy_can_finalize {
            utils::update_unit_status(&format!(
                "update staged: {}; reboot pending due to update strategy",
                &release.version
            ));
            // Reset number of postponements to `MAX_FINALIZE_POSTPONEMENTS`
            // if strategy does not allow finalization.
            state.update_staged(release);
            return;
        }
        let usersessions_can_finalize = state.usersessions_can_finalize();
        if !usersessions_can_finalize {
            FINALIZATION_BLOCKED
                .with_label_values(&[ACTIVE_USERSESSIONS_LABEL])
                .inc();
            utils::update_unit_status(&format!(
                "update staged: {}; reboot delayed due to active user sessions",
                release.version
            ));
            // Record postponement and postpone finalization.
            state.record_postponement();
            return;
        }
        match self.finalize_deployment(release).await {
            Ok(release) => {
                FINALIZATION_SUCCESS.inc();
                let status_msg = format!("update finalized: {}", release.version);
                log::info!("{}", &status_msg);
                state.update_finalized(release);
                utils::update_unit_status(&status_msg);
            }
            Err(e) => log::error!("failed to finalize deployment: {}", e),
        }
    }
async fn tick_finalize_update ( & self , state : & mut UpdateAgentMachineState , release : Release ) { trace ! ( " " ) ; FINALIZATION_ATTEMPTS . inc ( ) ; let strategy_can_finalize = self . strategy . can_finalize ( ) . await ; if ! strategy_can_finalize { utils :: update_unit_status ( & format ! ( " " release version ) ) ; // Reset number of postponements to `MAX_FINALIZE_POSTPONEMENTS` // if strategy does not allow finalization. state . update_staged ( release ) ; return ; } let usersessions_can_finalize = state . usersessions_can_finalize ( ) ; if ! usersessions_can_finalize { FINALIZATION_BLOCKED . with_label_values ( & [ ACTIVE_USERSESSIONS_LABEL ] ) . inc ( ) ; utils :: update_unit_status ( & format ! ( " " release version ) ) ; // Record postponement and postpone finalization. state . record_postponement ( ) ; return ; } match self . finalize_deployment ( release ) . await { Ok ( release ) => { FINALIZATION_SUCCESS . inc ( ) ; let status_msg = format ! ( " " release version ) ; log :: info ! ( " " status_msg ) ; state . update_finalized ( release ) ; utils :: update_unit_status ( & status_msg ) ; } Err ( e ) => log :: error ! ( " " e ) , } }
Try to finalize an update.
Try to finalize an update .
&self
state
&mut UpdateAgentMachineState
release
Release