From 4a645186b58be684759a7d8612279b469442ad58 Mon Sep 17 00:00:00 2001 From: Nick Mosher Date: Fri, 6 Aug 2021 20:03:50 +0000 Subject: [PATCH] Add compatibility notice for mismatched cluster versions (#1394) Closes #1393 --- src/client/src/error.rs | 13 ++++++++++++- src/client/src/fluvio.rs | 9 +++++++++ src/client/src/lib.rs | 3 +++ src/cluster/src/cli/error.rs | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/client/src/error.rs b/src/client/src/error.rs index 5bb5255108..02b5cf5bb8 100644 --- a/src/client/src/error.rs +++ b/src/client/src/error.rs @@ -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")] diff --git a/src/client/src/fluvio.rs b/src/client/src/fluvio.rs index c899c16277..fdd0e06057 100644 --- a/src/client/src/fluvio.rs +++ b/src/client/src/fluvio.rs @@ -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 { @@ -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(()) } diff --git a/src/client/src/lib.rs b/src/client/src/lib.rs index a1288ae307..c7753d6611 100644 --- a/src/client/src/lib.rs +++ b/src/client/src/lib.rs @@ -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 diff --git a/src/cluster/src/cli/error.rs b/src/cluster/src/cli/error.rs index 57c4001fe3..6785ea7f4e 100644 --- a/src/cluster/src/cli/error.rs +++ b/src/cluster/src/cli/error.rs @@ -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")]