Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Platform Version 0.9.25 - UNRELEASED
* Set timestamp in Records while producing. ([#2288](https://github.com/infinyon/fluvio/issues/2288))
* Support `ReadCommitted` isolation in SPU for Produce requests [#2336](https://github.com/infinyon/fluvio/pull/2336)
* Improve error messages and add `--fix` option to `fluvio cluster check` to autofix recoverable errors ([#2308](https://github.com/infinyon/fluvio/issues/2308))

## Platform Version 0.9.24 - 2022-04-21
* CLI: Migrate all fluvio crates to `comfy-table` from `prettytable-rs` ([#2285](https://github.com/infinyon/fluvio/issues/2263))
Expand Down
24 changes: 22 additions & 2 deletions crates/fluvio-cluster/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ pub enum UnrecoverableCheckStatus {
#[error("Local Fluvio component still exists")]
ExistingLocalCluster,

#[error("Helm client error")]
HelmClientError,

/// Other misc
#[error("Other failure: {0}")]
Other(String),
Expand Down Expand Up @@ -476,9 +479,18 @@ impl ClusterCheck for SysChartCheck {

let helm = HelmClient::new()?;
// check installed system chart version
let sys_charts = helm
let sys_charts = match helm
.get_installed_chart_by_name(SYS_CHART_NAME, None)
.map_err(ClusterCheckError::HelmError)?;
.map_err(ClusterCheckError::HelmError)
{
Ok(charts) => charts,
Err(helm_error) => {
debug!(?helm_error, "helm client error");
return Ok(CheckStatus::Unrecoverable(
UnrecoverableCheckStatus::HelmClientError,
));
}
};
debug!(charts = sys_charts.len(), "sys charts count");
if sys_charts.is_empty() {
Ok(CheckStatus::AutoFixableError {
Expand Down Expand Up @@ -862,6 +874,12 @@ impl ClusterChecker {
}
}
} else {
pb.println(pad_format!(format!(
"{} {} check failed and is auto-fixable but fixer is disabled. Use `--fix` to enable it.",
"❌".bold(),
check.label().italic(),
)));

failed = true;
}
}
Expand All @@ -871,12 +889,14 @@ impl ClusterChecker {
}
CheckStatus::Unrecoverable(err) => {
debug!("failed: {}", err);

pb.println(pad_format!(format!(
"{} Check {} failed {}",
"❌",
check.label().italic(),
err.to_string().red()
)));

failed = true;
}
}
Expand Down
17 changes: 13 additions & 4 deletions crates/fluvio-cluster/src/cli/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@ use semver::Version;
use clap::Parser;

use crate::progress::ProgressBarFactory;
use crate::{ClusterChecker};
use crate::ClusterChecker;
use crate::check::{SysChartCheck, ClusterCheckError};
use crate::charts::ChartConfig;

#[derive(Debug, Parser)]
pub struct CheckOpt {}
pub struct CheckOpt {
/// Attempt to fix recoverable errors
#[clap(long)]
fix: bool,
}

impl CheckOpt {
pub async fn process(self, platform_version: Version) -> Result<(), ClusterCheckError> {
use colored::*;
println!("{}", "Running pre-startup checks...".bold());
println!(
"{}",
"Note: This may require admin access to current Kubernetes context"
.bold()
.yellow()
);
let sys_config: ChartConfig = ChartConfig::sys_builder()
.build()
.map_err(|err| ClusterCheckError::Other(format!("chart config error: {:#?}", err)))?;

let pb = ProgressBarFactory::new(false);
ClusterChecker::empty()
.with_preflight_checks()
.with_check(SysChartCheck::new(sys_config, platform_version))
.run(&pb, false)
.run(&pb, self.fix)
.await?;

Ok(())
Expand Down
7 changes: 6 additions & 1 deletion crates/fluvio-cluster/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ pub enum ClusterCmd {
#[clap(name = "delete")]
Delete(DeleteOpt),

/// Check that all requirements for cluster startup are met
/// Check that all requirements for cluster startup are met.
///
/// This command is useful to check if user has all the required dependencies and permissions to run
/// fluvio on the current Kubernetes context.
///
/// It is not intended to be used in scenarios where user does not have access to Kubernetes resources (eg. Cloud)
#[clap(name = "check")]
Check(CheckOpt),

Expand Down

0 comments on commit eb36962

Please sign in to comment.