Skip to content

Commit

Permalink
chore(upgrade): modify check for rebuilding
Browse files Browse the repository at this point in the history
Signed-off-by: sinhaashish <[email protected]>
  • Loading branch information
sinhaashish committed Jul 20, 2023
1 parent c03a706 commit 4a99b97
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use kube::{api::ObjectList, ResourceExt};
use semver::{Version, VersionReq};
use snafu::ResultExt;
use tracing::{info, warn};
use upgrade::common::utils::is_child_degraded_or_faulted;

/// Function to check for any volume rebuild in progress across the cluster
pub(crate) async fn is_rebuilding(rest_client: &RestClientSet) -> Result<bool> {
Expand All @@ -32,7 +33,7 @@ pub(crate) async fn is_rebuilding(rest_client: &RestClientSet) -> Result<bool> {
if target
.children
.iter()
.any(|child| child.rebuild_progress.is_some())
.any(|child| is_child_degraded_or_faulted(child))
{
return Ok(true);
}
Expand Down
1 change: 1 addition & 0 deletions k8s/upgrade/src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod utils;
10 changes: 10 additions & 0 deletions k8s/upgrade/src/common/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use openapi::models::{Child, ChildState};

/// Returns true if child is faulted or degrade.
pub fn is_child_degraded_or_faulted(child: &Child) -> bool {
match child.state {
ChildState::Degraded => true,
ChildState::Faulted => true,
_ => false,
}
}
2 changes: 2 additions & 0 deletions k8s/upgrade/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub use plugin::constants;

/// Module for upgrade client errors.
pub use plugin::error;

pub mod common;
15 changes: 9 additions & 6 deletions k8s/upgrade/src/plugin/preflight_validations.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use crate::plugin::{
constants::{get_image_version_tag, SINGLE_REPLICA_VOLUME, UPGRADE_TO_DEVELOP_BRANCH},
error,
upgrade::{get_pvc_from_uuid, get_source_version},
user_prompt,
use crate::{
common::utils::is_child_degraded_or_faulted,
plugin::{
constants::{get_image_version_tag, SINGLE_REPLICA_VOLUME, UPGRADE_TO_DEVELOP_BRANCH},
error,
upgrade::{get_pvc_from_uuid, get_source_version},
user_prompt,
},
};
use openapi::{
clients::tower::{self, Configuration},
Expand Down Expand Up @@ -154,7 +157,7 @@ pub(crate) async fn is_rebuild_in_progress(client: &RestClient) -> error::Result
if target
.children
.iter()
.any(|child| child.rebuild_progress.is_some())
.any(|child| is_child_degraded_or_faulted(child))
{
return Ok(true);
}
Expand Down

0 comments on commit 4a99b97

Please sign in to comment.