From c82d9ea24243f15fdb765bb4be403a5e37a6a436 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 22 May 2023 09:25:46 +0000 Subject: [PATCH 1/4] fix(upgrade-job): use thin provisioning helm flags with 2.0.x instead of 2.1.x releases Signed-off-by: Niladri Halder --- k8s/upgrade-job/src/common/constants.rs | 4 ++-- k8s/upgrade-job/src/helm/values.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/k8s/upgrade-job/src/common/constants.rs b/k8s/upgrade-job/src/common/constants.rs index ee7489862..e48a9b56e 100644 --- a/k8s/upgrade-job/src/common/constants.rs +++ b/k8s/upgrade-job/src/common/constants.rs @@ -27,5 +27,5 @@ pub(crate) const TO_UMBRELLA_SEMVER: &str = "3.7.0"; pub(crate) const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str = "https://openebs.io/docs/user-guides/upgrade#mayastor-upgrade"; -/// This defines the range of helm chart versions for the 2.1 release of the Core helm chart. -pub(crate) const TWO_DOT_ONE: &str = ">=2.1.0-rc.0, <=2.1.0"; +/// This defines the range of helm chart versions for the 2.0 release of the Core helm chart. +pub(crate) const TWO_DOT_O: &str = ">=2.0.0-rc.0, <=2.0.1"; diff --git a/k8s/upgrade-job/src/helm/values.rs b/k8s/upgrade-job/src/helm/values.rs index 8f98ca534..ddfd21c8b 100644 --- a/k8s/upgrade-job/src/helm/values.rs +++ b/k8s/upgrade-job/src/helm/values.rs @@ -1,6 +1,6 @@ use crate::{ common::{ - constants::TWO_DOT_ONE, + constants::TWO_DOT_O, error::{ OpeningFile, Result, SemverParse, U8VectorToString, YamlParseFromFile, YamlParseFromSlice, @@ -41,10 +41,10 @@ pub(crate) fn generate_values_args( // use from installed-release's values, if present, else use defaults from to-chart. let mut upgrade_args: Vec = Vec::with_capacity(18); - let version_two_dot_one = VersionReq::parse(TWO_DOT_ONE).context(SemverParse { - version_string: TWO_DOT_ONE.to_string(), + let version_two_dot_o = VersionReq::parse(TWO_DOT_O).context(SemverParse { + version_string: TWO_DOT_O.to_string(), })?; - if version_two_dot_one.matches(from_version) { + if version_two_dot_o.matches(from_version) { let io_engine_key = "io_engine"; let log_level_key = "logLevel"; let log_level_to_replace = "info,io_engine=info"; From 85b3a72b70b633f627bb5698ca39fcb8045fa777 Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 22 May 2023 09:27:09 +0000 Subject: [PATCH 2/4] fix(upgrade-job): allow 'no-rollback' check to be overridden Signed-off-by: Niladri Halder --- k8s/upgrade-job/src/helm/upgrade.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/k8s/upgrade-job/src/helm/upgrade.rs b/k8s/upgrade-job/src/helm/upgrade.rs index a6bbfa160..25b137872 100644 --- a/k8s/upgrade-job/src/helm/upgrade.rs +++ b/k8s/upgrade-job/src/helm/upgrade.rs @@ -105,15 +105,6 @@ impl HelmUpgradeBuilder { let chart_yaml_path = chart_dir.join("Chart.yaml"); let to_version: Version = upgrade::path::version_from_chart_yaml_file(chart_yaml_path)?; - // Basic validation. - // Rollbacks not supported. - ensure!( - to_version.ge(&from_version), - RollbackForbidden { - from_version: from_version.to_string(), - to_version: to_version.to_string() - } - ); // Check if already upgraded. let already_upgraded = to_version.eq(&from_version); @@ -148,6 +139,15 @@ impl HelmUpgradeBuilder { // Skip upgrade-path validation and allow all upgrades for the Core helm chart, if the // flag is set. if !self.skip_upgrade_path_validation { + // Rollbacks not supported. + ensure!( + to_version.ge(&from_version), + RollbackForbidden { + from_version: from_version.to_string(), + to_version: to_version.to_string() + } + ); + let upgrade_path_is_valid = upgrade::path::is_valid_for_core_chart(&from_version)?; ensure!(upgrade_path_is_valid, InvalidUpgradePath); } From dac8d5d1acf12d8e82f6a23d77b064b80aa6a05d Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 22 May 2023 09:30:55 +0000 Subject: [PATCH 3/4] feat(upgrade-job): allow for upgrade support for future 2.0.x releases Signed-off-by: Niladri Halder --- k8s/upgrade-job/src/common/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/upgrade-job/src/common/constants.rs b/k8s/upgrade-job/src/common/constants.rs index e48a9b56e..588b90eaf 100644 --- a/k8s/upgrade-job/src/common/constants.rs +++ b/k8s/upgrade-job/src/common/constants.rs @@ -28,4 +28,4 @@ pub(crate) const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str = "https://openebs.io/docs/user-guides/upgrade#mayastor-upgrade"; /// This defines the range of helm chart versions for the 2.0 release of the Core helm chart. -pub(crate) const TWO_DOT_O: &str = ">=2.0.0-rc.0, <=2.0.1"; +pub(crate) const TWO_DOT_O: &str = ">=2.0.0-rc.0, <2.1.0"; From b438842814b9978b41600262dee4fe98f824cf0d Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Mon, 22 May 2023 13:50:40 +0000 Subject: [PATCH 4/4] feat(upgrade-job): add comments to the crate::helm::values modules Signed-off-by: Niladri Halder --- k8s/upgrade-job/src/helm/values.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/k8s/upgrade-job/src/helm/values.rs b/k8s/upgrade-job/src/helm/values.rs index ddfd21c8b..b9f6eedba 100644 --- a/k8s/upgrade-job/src/helm/values.rs +++ b/k8s/upgrade-job/src/helm/values.rs @@ -41,6 +41,20 @@ pub(crate) fn generate_values_args( // use from installed-release's values, if present, else use defaults from to-chart. let mut upgrade_args: Vec = Vec::with_capacity(18); + // For the rest of the this function's body, the flags which must be included to achieve + // a successful helm upgrade will be added to the 'upgrade_args' vector. + // There are two types of flags -- 1. Default flags, 2. Version-specific flags. + // Default flags set helm values options which must be included with all of the upgrade + // source versions. + // The version-specific flags set options which are required only in case the version of + // the source helm chart matches some ranges, e.g. the 2.0.x helm charts, including the + // pre-release versions. + + // Version-specific set flags for 2.0.x source helm versions. + // For instance, These did not have the thin-provisioning options when they + // were released, and require explicit helm `--set` flags (when using the + // `--reuse-values`) to successfully generate the helm templates (the + // 'default' template function cannot work with a nil value). let version_two_dot_o = VersionReq::parse(TWO_DOT_O).context(SemverParse { version_string: TWO_DOT_O.to_string(), })?;