Skip to content

Commit bf0999d

Browse files
mayastor-borssinhaashish
andcommitted
chore(bors): merge pull request #248
248: Cherry pick PR #245 and #247 to release/2.2 branch r=sinhaashish a=sinhaashish This PR cherry-picks the following commit(s) to release/2.2: - [beb02c9](beb02c9) - [8df03fc](8df03fc) Co-authored-by: sinhaashish <[email protected]>
2 parents f459637 + 2e90f52 commit bf0999d

File tree

7 files changed

+111
-76
lines changed

7 files changed

+111
-76
lines changed

k8s/plugin/README.md

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ Commands:
2828
scale 'Scale' resources
2929
cordon 'Cordon' resources
3030
uncordon 'Uncordon' resources
31-
dump `Dump` resources
32-
install `Install` resources
33-
uninstall `Uninstall` resources
34-
upgrade `Upgrade` resources
35-
help Print this message or the help of the given subcommand(s)
31+
dump 'Dump' resources
32+
upgrade 'Upgrade' the deployment
33+
delete 'Delete' the upgrade resources
34+
help Print this message or the help of the given subcommand(s)
3635
3736
Options:
3837
-r, --rest <REST>
@@ -46,7 +45,7 @@ Options:
4645
-t, --timeout <TIMEOUT>
4746
Timeout for the REST operations [default: 10s]
4847
-n, --namespace <NAMESPACE>
49-
Kubernetes namespace of mayastor service, defaults to mayastor [default: mayastor]
48+
Kubernetes namespace of mayastor service
5049
-h, --help
5150
Print help
5251
-V, --version
@@ -278,7 +277,7 @@ Options:
278277
-d, --output-directory-path <OUTPUT_DIRECTORY_PATH>
279278
Output directory path to store archive file [default: ./]
280279
-n, --namespace <NAMESPACE>
281-
Kubernetes namespace of mayastor service, defaults to mayastor [default: mayastor]
280+
Kubernetes namespace of mayastor service[default: mayastor]
282281
-o, --output <OUTPUT>
283282
The Output, viz yaml, json [default: none]
284283
-j, --jaeger <JAEGER>
@@ -347,57 +346,91 @@ Supportability - collects state & log information of services and dumps it to a
347346
kubectl mayastor dump volume volume-1 -d /mayastor-dump -r http://127.0.0.1:30011 -l http://127.0.0.1:3100 -e http://127.0.0.1:2379 -n mayastor
348347
```
349348
349+
</details>
350350
<details>
351351
<summary> Upgrade operations </summary>
352352
353353
**Examples**:
354354
355-
1. To install upgrade resources need for executing upgrade operation
356-
```sh
357-
## Command
358-
kubectl mayastor install upgrade-operator -n <mayastor_namespace>
359-
```
360-
361-
2. To uninstall upgrade resources need for executing upgrade operation
362-
```sh
363-
## Command
364-
kubectl mayastor uninstall upgrade-operator -n <mayastor_namespace>
365-
```
366-
367-
1. To upgrade the installation
368-
```sh
355+
1. Upgrade deployment
356+
```
369357
## Command
370358
kubectl mayastor upgrade
371359
`Upgrade` the deployment
372360
373361
Usage: kubectl-mayastor upgrade [OPTIONS]
374362
375363
Options:
376-
-d, --dry-run
364+
-d, --dry-run
377365
Display all the validations output but will not execute upgrade
378-
-r, --rest <REST>
366+
-r, --rest <REST>
379367
The rest endpoint to connect to
380-
-k, --kube-config-path <KUBE_CONFIG_PATH>
381-
Path to kubeconfig file
382-
-s, --skip-data-plane-restart
368+
-D, --skip-data-plane-restart
383369
If set then upgrade will skip the io-engine pods restart
384-
--skip-single-replica-volume-validation
370+
-k, --kube-config-path <KUBE_CONFIG_PATH>
371+
Path to kubeconfig file
372+
-S, --skip-single-replica-volume-validation
385373
If set then it will continue with upgrade without validating singla replica volume
386-
--skip-replica-rebuild
374+
-R, --skip-replica-rebuild
387375
If set then upgrade will skip the repilca rebuild in progress validation
388-
-o, --output <OUTPUT>
376+
-C, --skip-cordoned-node-validation
377+
If set then upgrade will skip the cordoned node validation
378+
-o, --output <OUTPUT>
389379
The Output, viz yaml, json [default: none]
390-
-j, --jaeger <JAEGER>
380+
-j, --jaeger <JAEGER>
391381
Trace rest requests to the Jaeger endpoint agent
392-
-n, --namespace <NAMESPACE>
393-
Kubernetes namespace of mayastor service, defaults to mayastor [default: mayastor]
394-
-h, --help
382+
-n, --namespace <NAMESPACE>
383+
Kubernetes namespace of mayastor service [default: mayastor]
384+
-h, --help
395385
Print help
396386
```
397387
398-
4. To get the upgrade status
399-
```sh
388+
2. Get the upgrade status
389+
```
400390
## Command
401391
kubectl mayastor get upgrade-status
392+
`Get` the upgrade status
393+
394+
Usage: kubectl-mayastor get upgrade-status [OPTIONS]
395+
396+
Options:
397+
-r, --rest <REST>
398+
The rest endpoint to connect to
399+
-k, --kube-config-path <KUBE_CONFIG_PATH>
400+
Path to kubeconfig file
401+
-o, --output <OUTPUT>
402+
The Output, viz yaml, json [default: none]
403+
-j, --jaeger <JAEGER>
404+
Trace rest requests to the Jaeger endpoint agent
405+
-n, --namespace <NAMESPACE>
406+
Kubernetes namespace of mayastor service [default: mayastor]
407+
-h, --help
408+
Print help
402409
```
410+
411+
3. Delete upgrade resources
412+
```
413+
## Command
414+
kubectl mayastor delete upgrade
415+
`Delete` the upgrade resources
416+
417+
Usage: kubectl-mayastor delete upgrade [OPTIONS]
418+
419+
Options:
420+
-f, --force
421+
If true, immediately remove upgrade resources bypass graceful deletion
422+
-r, --rest <REST>
423+
The rest endpoint to connect to
424+
-k, --kube-config-path <KUBE_CONFIG_PATH>
425+
Path to kubeconfig file
426+
-o, --output <OUTPUT>
427+
The Output, viz yaml, json [default: none]
428+
-j, --jaeger <JAEGER>
429+
Trace rest requests to the Jaeger endpoint agent
430+
-n, --namespace <NAMESPACE>
431+
Kubernetes namespace of mayastor service [default: mayastor]
432+
-h, --help
433+
Print help
434+
435+
```
403436
</details>

k8s/plugin/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct CliArgs {
4343
#[clap(long, short, default_value = "10s")]
4444
timeout: humantime::Duration,
4545

46-
/// Kubernetes namespace of mayastor service, defaults to mayastor
46+
/// Kubernetes namespace of mayastor service
4747
#[clap(global = true, long, short = 'n', default_value = "mayastor")]
4848
namespace: String,
4949
}

k8s/plugin/src/resources/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum Operations {
3434
Dump(DumpArgs),
3535
/// `Upgrade` the deployment.
3636
Upgrade(UpgradeArgs),
37-
/// `Delete` the resources.
37+
/// `Delete` the upgrade resources.
3838
#[clap(subcommand)]
3939
Delete(DeleteResources),
4040
}

k8s/supportability/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct SupportArgs {
4444
#[clap(global = true, long, short = 'd', default_value = "./")]
4545
output_directory_path: String,
4646

47-
/// Kubernetes namespace of mayastor service, defaults to mayastor
47+
/// Kubernetes namespace of mayastor service
4848
#[clap(global = true, long, short = 'n', default_value = "mayastor")]
4949
namespace: String,
5050
}

k8s/upgrade/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ pub enum Error {
107107
#[snafu(display("Upgrade Job: {} status not present.", name))]
108108
UpgradeJobStatusNotPresent { name: String },
109109

110-
/// Error for when the job.status is a None.
111-
#[snafu(display("Upgrade Job: {} not completed.", name))]
112-
UpgradeJobNotCompleted { name: String },
110+
/// Error for when the upgrade job is not present.
111+
#[snafu(display("Upgrade Job: {} in namespace {} does not exist.", name, namespace))]
112+
UpgradeJobNotPresent { name: String, namespace: String },
113113

114114
/// Error for when a Kubernetes API request for GET-ing a list of Pods filtered by label(s)
115115
/// fails.
@@ -260,7 +260,7 @@ impl From<Error> for i32 {
260260
Error::NodeSpecNotPresent { .. } => 423,
261261
Error::PodNameNotPresent { .. } => 424,
262262
Error::UpgradeJobStatusNotPresent { .. } => 425,
263-
Error::UpgradeJobNotCompleted { .. } => 426,
263+
Error::UpgradeJobNotPresent { .. } => 426,
264264
Error::ListPodsWithLabel { .. } => 427,
265265
Error::ListDeploymantsWithLabel { .. } => 428,
266266
Error::ListEventsWithFieldSelector { .. } => 429,

k8s/upgrade/src/upgrade_resources/upgrade.rs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use crate::{
1111
upgrade_resources::objects,
1212
user_prompt::{
1313
upgrade_dry_run_summary, CONTROL_PLANE_PODS_LIST, DATA_PLANE_PODS_LIST,
14-
DATA_PLANE_PODS_LIST_SKIP_RESTART, UPGRADE_DRY_RUN_SUMMARY, UPGRADE_JOB_STARTED,
14+
DATA_PLANE_PODS_LIST_SKIP_RESTART, DELETE_INCOMPLETE_JOB, UPGRADE_DRY_RUN_SUMMARY,
15+
UPGRADE_JOB_STARTED,
1516
},
1617
};
1718
use k8s_openapi::api::{
@@ -38,16 +39,21 @@ pub enum DeleteResources {
3839

3940
/// Delete Upgrade resource.
4041
#[derive(clap::Args, Debug)]
41-
pub struct DeleteUpgradeArgs {}
42+
pub struct DeleteUpgradeArgs {
43+
/// If true, immediately remove upgrade resources bypass graceful deletion.
44+
#[clap(global = false, long, short, default_value_t = false)]
45+
pub force: bool,
46+
}
4247

4348
impl DeleteUpgradeArgs {
4449
/// Delete the upgrade resources
4550
pub async fn delete(&self, ns: &str) {
46-
// Delete upgrade resources once job completes
47-
4851
match is_upgrade_job_completed(ns).await {
4952
Ok(job_completed) => {
50-
if job_completed {
53+
if !job_completed && !self.force {
54+
console_logger::error("", DELETE_INCOMPLETE_JOB);
55+
}
56+
if job_completed || self.force {
5157
_ = UpgradeResources::delete_upgrade_resources(ns)
5258
.await
5359
.map_err(|error| {
@@ -56,9 +62,8 @@ impl DeleteUpgradeArgs {
5662
}
5763
}
5864
Err(error) => {
59-
eprintln!(
60-
"error occured while fetching the completion status of upgrade job {error}"
61-
);
65+
eprintln!("error : {error}");
66+
std::process::exit(error.into());
6267
}
6368
}
6469
}
@@ -663,33 +668,26 @@ pub async fn is_upgrade_job_completed(ns: &str) -> error::Result<bool> {
663668
})?;
664669
match option_job {
665670
Some(job) => {
666-
if matches!(
667-
job.status
668-
.as_ref()
669-
.ok_or(
670-
error::UpgradeJobStatusNotPresent {
671-
name: job_name.clone()
672-
}
673-
.build()
674-
)?
675-
.succeeded
676-
.as_ref()
677-
.ok_or(
678-
error::UpgradeJobNotCompleted {
679-
name: job_name.clone()
680-
}
681-
.build()
682-
)?,
683-
1
684-
) {
685-
return Ok(true);
686-
}
671+
let status = job.status.as_ref().ok_or(
672+
error::UpgradeJobStatusNotPresent {
673+
name: job_name.clone(),
674+
}
675+
.build(),
676+
)?;
677+
678+
let is_job_completed = match status.succeeded {
679+
None => false,
680+
Some(count) => count == 1,
681+
};
682+
Ok(is_job_completed)
687683
}
688-
None => {
689-
eprintln!("Upgrade job {job_name} in namespace {ns} does not exist");
684+
685+
None => error::UpgradeJobNotPresent {
686+
name: job_name,
687+
namespace: ns,
690688
}
689+
.fail(),
691690
}
692-
Ok(false)
693691
}
694692

695693
struct ImageProperties {

k8s/upgrade/src/user_prompt.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ pub const UPGRADE_JOB_STARTED: &str =
4343
pub const UPGRADE_PATH_NOT_VALID: &str =
4444
"\nThe upgrade path is not valid. The source version is in the list of unsupported versions:";
4545

46-
/// Upgrade to unsuppoted version not valid.
46+
/// Upgrade to unsupported version not valid.
4747
pub const UPGRADE_TO_UNSUPPORTED_VERSION: &str =
48-
"\nUpgrade failed as destination version is unsupported. Please try with `--skip-upgrade-path-validation-for-unsupported-version`";
48+
"\nUpgrade failed as destination version is unsupported. Please try with `--skip-upgrade-path-validation-for-unsupported-version.`";
49+
50+
/// Delete an incomplete job.
51+
pub const DELETE_INCOMPLETE_JOB: &str =
52+
"\n Cant delete an incomplete upgrade job. Please try with `--force` flag to forcefully remove upgrade resources and bypass graceful deletion.";

0 commit comments

Comments
 (0)