Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(upgrade): add unsupported upgrade version file upgrade #229

Merged
merged 1 commit into from
May 14, 2023

Conversation

sinhaashish
Copy link
Member

@sinhaashish sinhaashish commented May 11, 2023

This PR incorporates the below changes:

  • add a file for unsupported version
  • This file is read by both plugin and upgrade job for upgrade path validation
  • since the to version is already fixed, the from/source version is validated against the unsupported version list.
  • In order to upgrade to develop , use the flag --skip-upgrade-path-validation-for-unsupported-version
  • return the error code mapped to errors.

Test case 1
Install version 2.0.0 and add 2.0.0 in unsupported_versions.yaml as shown below

unsupported_versions:
  - 2.0.0

Upgrade fails stating

ashish@vm:~/code/rust/mayastor-extensions(upgradevalidation-using-file)$ ./target/debug/kubectl-mayastor  upgrade --dry-run

Volumes which make use of a single volume replica instance will be unavailable for some time during upgrade.
It is recommended that you do not create new volumes which make use of only one volume replica.

The upgrade path is not valid. The source version is in the list of unsupported versions:
 2.0.0

Test case 2
Using the skip-upgrade-path-validation-for-unsupported-version so that upgrade against can be tested.

./target/debug/kubectl-mayastor  upgrade --skip-upgrade-path-validation-for-unsupported-version --dry-run

Volumes which make use of a single volume replica instance will be unavailable for some time during upgrade.
It is recommended that you do not create new volumes which make use of only one volume replica.


List of control plane pods which will be restarted during upgrade.
 mayastor-agent-core-56cc7fc757-zzjqv
mayastor-api-rest-6f96bbb988-tf8c2

List of data plane pods which will be restarted during upgrade.
 mayastor-io-engine-crpcx
mayastor-io-engine-k6h4n
mayastor-io-engine-ml5wn

Finally the cluster deployment will be upgraded to version : develop

Test case3
Upgrade to develop
Run /target/debug/kubectl-mayastor upgrade --skip-upgrade-path-validation-for-unsupported-version
Upgrade succeeds

ashish@vm:~/code/rust/mayastor-extensions(upgradevalidation-using-file)$ ./target/debug/kubectl-mayastor get upgrade-status
Upgrade From: 2.0.0
Upgrade To: 0.0.0
Upgrade Status: Successfully upgraded Mayastor

k8s/plugin/src/main.rs Outdated Show resolved Hide resolved
Comment on lines 156 to 164
let mut invalid_upgrade_path: PathBuf;

match self.upgrade_path_dir {
Some(up_path) => invalid_upgrade_path = up_path,
None => {
return FilePathNotPresent.fail();
}
}
invalid_upgrade_path.push("unsupported_versions.yaml");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut invalid_upgrade_path: PathBuf;
match self.upgrade_path_dir {
Some(up_path) => invalid_upgrade_path = up_path,
None => {
return FilePathNotPresent.fail();
}
}
invalid_upgrade_path.push("unsupported_versions.yaml");
let invalid_upgrade_path = match self.upgrade_path_dir {
Some(path) => Ok(path.join("unsupported_versions.yaml")),
None => Err(Error::FilePathNotPresent),
}?;

Also, should "unsupported_versions.yaml" be a const?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing the complete file path now.

@@ -41,10 +41,18 @@ pub(crate) struct CliArgs {
)]
core_chart_dir: Option<PathBuf>,

/// This is the Helm chart directory filepath for the core Helm chart variant.
#[arg(long, env = "UPGRADE_EXCEPTION_PATH", value_name = "DIR PATH")]
upgrade_exception_dir: Option<PathBuf>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not specify the file path, rather than the dir? And have the default value here so it's clear?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing the complete file path now.

k8s/upgrade-job/src/upgrade/path.rs Outdated Show resolved Hide resolved
k8s/upgrade-job/src/upgrade/path.rs Outdated Show resolved Hide resolved
k8s/upgrade/src/constant.rs Outdated Show resolved Hide resolved
nix/pkgs/images/default.nix Outdated Show resolved Hide resolved
@sinhaashish sinhaashish force-pushed the upgradevalidation-using-file branch 4 times, most recently from 5594bdd to 6debe22 Compare May 12, 2023 04:13
k8s/upgrade/src/preflight_validations.rs Outdated Show resolved Hide resolved
@@ -134,18 +153,30 @@ impl HelmUpgradeBuilder {
}

// Validating upgrade path.
let invalid_upgrade_path = match self.upgrade_path_file {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not default it in the cli argument to our file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,3 @@
unsupported_versions:
# add the list of unsupported versions as shown below
- 0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add v1 for completeness?
Do we support "wild cards" here btw?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no wild cards support , the version in chart.yal is 0.0.0 so v1 not added here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth adding that, even as a follow-up PR

@sinhaashish sinhaashish force-pushed the upgradevalidation-using-file branch from 6debe22 to a56391a Compare May 12, 2023 13:37
#[arg(
long,
env = "UPGRADE_EXCEPTION_FILE_PATH",
default_value = "/k8s/upgrade/config/unsupported_versions.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: default_value is left for backwards compatibility. Better to use default_value_t.

This value should be in the constants file... and the constant should be used here.

@sinhaashish
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented May 14, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 21cfb16 into openebs:develop May 14, 2023
bors bot pushed a commit that referenced this pull request May 15, 2023
230: Cherry pick PR #229 to release/2.2 branch r=sinhaashish a=sinhaashish

This PR cherry-picks the following commit(s) to release/2.2:
 - [a56391a](a56391a)

Co-authored-by: sinhaashish <[email protected]>
@sinhaashish sinhaashish deleted the upgradevalidation-using-file branch May 15, 2023 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants