pub async fn update_child_labels(
        &mut self,
    ) -> Result<NexusLabel, LabelError> {
        // Get a list of all children and their labels
        let list = self.get_child_labels().await;

        // Search for first "valid" label
        if let Some(target) = NexusChildLabel::find_target_label(&list) {
            // Check that all "valid" labels are equal
            if NexusChildLabel::compare_labels(&target, &list) {
                let (_valid, invalid): (
                    Vec<NexusChildLabel>,
                    Vec<NexusChildLabel>,
                ) = list.into_iter().partition(|label| {
                    label.get_label_status() == NexusLabelStatus::Both
                });

                if invalid.is_empty() {
                    info!(
                        "{}: All child disk labels are valid and consistent",
                        self.name
                    );
                } else {
                    // Write out (only) those labels that require updating
                    info!(
                        "{}: Replacing missing/invalid child disk labels",
                        self.name
                    );
                    self.write_labels(&target, &invalid).await?
                }

                // TODO: When the GUID does not match the given UUID.
                // it means that the PVC has been recreated.
                // We should consider also updating the labels in such a case.

                info!("{}: existing label: {}", self.name, target.primary.guid);
                trace!("{}: existing label:\n {}", self.name, target);

                return Ok(target);
            }

            info!("{}: Child disk labels do not match, writing new label to all children", self.name);
        } else {
            info!("{}: Child disk labels invalid or absent, writing new label to all children", self.name);
        }

        // Either there are no valid labels or there
        // are some valid labels that do not agree.
        // Generate a new label ...
        let label = self.generate_label();

        // ... and write it out to ALL children.
        let label = match self.write_all_labels(&label).await {
            Ok(_) => Ok(label),
            Err(LabelError::ReReadError {
                ..
            }) => {
                if env::var("NEXUS_LABEL_IGNORE_ERRORS").is_ok() {
                    warn!("ignoring label error on request");
                    Ok(label)
                } else {
                    Err(LabelError::ProbeError {})
                }
            }
            Err(e) => Err(e),
        }?;

        info!("{}: new label: {}", self.name, label.primary.guid);
        trace!("{}: new label:\n{}", self.name, label);
        Ok(label)
    }
/// Update labels of child devices as required:
/// (1) Update any child that does not have valid label.
/// (2) Upate all children with a new label if existing (valid) labels
///     are not all identical.
///
/// Return the resulting label.
Update labels of child devices as required:
(1) Update any child that does not have valid label.
(2) Upate all children with a new label if existing (valid) labels
are not all identical.

Return the resulting label.
Update labels of child devices as required : ( 1 ) Update any child that does not have valid label . ( 2 ) Upate all children with a new label if existing ( valid ) labels are not all identical . Return the resulting label .
pub async fn update_child_labels(
        &mut self,
    ) -> Result<NexusLabel, LabelError> {
        // Get a list of all children and their labels
        let list = self.get_child_labels().await;
        // Search for first "valid" label
        if let Some(target) = NexusChildLabel::find_target_label(&list) {
            // Check that all "valid" labels are equal
            if NexusChildLabel::compare_labels(&target, &list) {
                let (_valid, invalid): (
                    Vec<NexusChildLabel>,
                    Vec<NexusChildLabel>,
                ) = list.into_iter().partition(|label| {
                    label.get_label_status() == NexusLabelStatus::Both
                });
                if invalid.is_empty() {
                    info!(
                        "{}: All child disk labels are valid and consistent",
                        self.name
                    );
                } else {
                    // Write out (only) those labels that require updating
                    info!(
                        "{}: Replacing missing/invalid child disk labels",
                        self.name
                    );
                    self.write_labels(&target, &invalid).await?
                }
                // TODO: When the GUID does not match the given UUID.
                // it means that the PVC has been recreated.
                // We should consider also updating the labels in such a case.
                info!("{}: existing label: {}", self.name, target.primary.guid);
                trace!("{}: existing label:\n {}", self.name, target);
                return Ok(target);
            }
            info!("{}: Child disk labels do not match, writing new label to all children", self.name);
        } else {
            info!("{}: Child disk labels invalid or absent, writing new label to all children", self.name);
        }
        // Either there are no valid labels or there
        // are some valid labels that do not agree.
        // Generate a new label ...
        let label = self.generate_label();
        // ... and write it out to ALL children.
        let label = match self.write_all_labels(&label).await {
            Ok(_) => Ok(label),
            Err(LabelError::ReReadError {
                ..
            }) => {
                if env::var("NEXUS_LABEL_IGNORE_ERRORS").is_ok() {
                    warn!("ignoring label error on request");
                    Ok(label)
                } else {
                    Err(LabelError::ProbeError {})
                }
            }
            Err(e) => Err(e),
        }?;
        info!("{}: new label: {}", self.name, label.primary.guid);
        trace!("{}: new label:\n{}", self.name, label);
        Ok(label)
    }
pub async fn update_child_labels ( & mut self , ) -> Result < NexusLabel , LabelError > { // Get a list of all children and their labels let list = self . get_child_labels ( ) . await ; // Search for first "valid" label if let Some ( target ) = NexusChildLabel :: find_target_label ( & list ) { // Check that all "valid" labels are equal if NexusChildLabel :: compare_labels ( & target , & list ) { let ( _valid , invalid ) : ( Vec < NexusChildLabel > , Vec < NexusChildLabel > , ) = list . into_iter ( ) . partition ( | label | { label . get_label_status ( ) == NexusLabelStatus :: Both } ) ; if invalid . is_empty ( ) { info ! ( " " self name ) ; } else { // Write out (only) those labels that require updating info ! ( " " self name ) ; self . write_labels ( & target , & invalid ) . await ? } // TODO: When the GUID does not match the given UUID. // it means that the PVC has been recreated. // We should consider also updating the labels in such a case. info ! ( " " self name target primary guid ) ; trace ! ( " \n " self name target ) ; return Ok ( target ) ; } info ! ( " " self name ) ; } else { info ! ( " " self name ) ; } // Either there are no valid labels or there // are some valid labels that do not agree. // Generate a new label ... let label = self . generate_label ( ) ; // ... and write it out to ALL children. let label = match self . write_all_labels ( & label ) . await { Ok ( _ ) => Ok ( label ) , Err ( LabelError :: ReReadError { .. } ) => { if env :: var ( " " ) . is_ok ( ) { warn ! ( " " ) ; Ok ( label ) } else { Err ( LabelError :: ProbeError { } ) } } Err ( e ) => Err ( e ) , } ? ; info ! ( " " self name label primary guid ) ; trace ! ( " \n " self name label ) ; Ok ( label ) }
Update labels of child devices as required:
(1) Update any child that does not have valid label.
Update labels of child devices as required : ( 1 ) Update any child that does not have valid label .
&mut self