Skip to content

Commit

Permalink
Add compatibility notice for mismatched cluster versions (#1394)
Browse files Browse the repository at this point in the history
Closes #1393
  • Loading branch information
nicholastmosher committed Aug 6, 2021
1 parent cf90cc9 commit 4a64518
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ pub enum FluvioError {
ClientConfig(#[from] ConfigError),
#[error("Attempted to create negative offset: {0}")]
NegativeOffset(i64),
#[error("Cluster (with platform version {cluster_version}) is older than the minimum required version {client_minimum_version}")]
#[error("Cluster (with platform version {cluster_version}) is older than the minimum required version {client_minimum_version}
To interact with this cluster, please install the matching CLI version using the following command:
curl -fsS https://packages.fluvio.io/v1/install.sh | VERSION={cluster_version} bash
")]
MinimumPlatformVersion {
cluster_version: Version,
client_minimum_version: Version,
},
#[error("Cluster (with platform version {cluster_version}) is newer than this CLI major version {client_maximum_version}
To interact with this cluster, please install the matching CLI version using the following command:
curl -fsS https://packages.fluvio.io/v1/install.sh | VERSION={cluster_version} bash
")]
MaximumPlatformVersion {
cluster_version: Version,
client_maximum_version: Version,
},
#[error("Consumer config error: {0}")]
ConsumerConfig(String),
#[error("Encountered a runtime error in the user's SmartStream")]
Expand Down
9 changes: 9 additions & 0 deletions src/client/src/fluvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ impl Fluvio {
fn check_platform_compatible(cluster_version: &Version) -> Result<(), FluvioError> {
let client_minimum_version = Version::parse(crate::MINIMUM_PLATFORM_VERSION)
.expect("MINIMUM_PLATFORM_VERSION must be semver");
let client_maximum_version = Version::parse(crate::MAXIMUM_PLATFORM_VERSION)
.expect("MAXIMUM_PLATFORM_VERSION must be semver");

if *cluster_version < client_minimum_version {
return Err(FluvioError::MinimumPlatformVersion {
Expand All @@ -220,6 +222,13 @@ fn check_platform_compatible(cluster_version: &Version) -> Result<(), FluvioErro
});
}

if *cluster_version >= client_maximum_version {
return Err(FluvioError::MaximumPlatformVersion {
cluster_version: cluster_version.clone(),
client_maximum_version,
});
}

Ok(())
}

Expand Down
3 changes: 3 additions & 0 deletions src/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub use crate::fluvio::Fluvio;
/// The minimum VERSION of the Fluvio Platform that this client is compatible with.
const MINIMUM_PLATFORM_VERSION: &str = "0.9.0";

/// The maximum VERSION of the Fluvio Platform that this client is compatible with.
const MAXIMUM_PLATFORM_VERSION: &str = "0.10.0";

/// Creates a producer that sends records to the named topic
///
/// This is a shortcut function that uses the current profile
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum ClusterCliError {
#[error("Target Error")]
TargetError(#[from] TargetError),
/// An error occurred with a cluster operation
#[error("Fluvio cluster error")]
#[error(transparent)]
ClusterError(#[from] ClusterError),
/// An error occurred while communicating with Fluvio
#[error("Fluvio client error")]
Expand Down

0 comments on commit 4a64518

Please sign in to comment.