Skip to content

Commit 08fe5bd

Browse files
committed
api adjustment
1 parent 822f466 commit 08fe5bd

File tree

6 files changed

+44
-47
lines changed

6 files changed

+44
-47
lines changed

crates/trident/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ pub enum Commands {
178178

179179
/// Manually rollback to previous state
180180
Rollback {
181-
/// Run a dry-run for rollback, return operation that would be performed
181+
/// Check operation that would be performed
182182
#[arg(long)]
183-
dry_run: bool,
183+
check: bool,
184184

185185
/// Invoke rollback only if next available rollback is runtime rollback
186186
#[arg(long, conflicts_with = "ab")]

crates/trident/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ impl Trident {
737737
pub fn rollback(
738738
&mut self,
739739
datastore: &mut DataStore,
740-
dry_run: bool,
740+
check: bool,
741741
invoke_if_next_is_runtime: bool,
742742
invoke_available_ab: bool,
743743
allowed_operations: Operations,
@@ -757,7 +757,7 @@ impl Trident {
757757
let rollback_result = self.execute_and_record_error(datastore, |datastore| {
758758
manual_rollback::execute_rollback(
759759
datastore,
760-
dry_run,
760+
check,
761761
invoke_if_next_is_runtime,
762762
invoke_available_ab,
763763
&allowed_operations,

crates/trident/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ fn run_trident(
206206
),
207207
Commands::Commit { .. } => trident.commit(&mut datastore),
208208
Commands::Rollback {
209-
dry_run,
209+
check,
210210
runtime,
211211
ab,
212212
ref allowed_operations,
213213
..
214214
} => trident.rollback(
215215
&mut datastore,
216-
dry_run,
216+
check,
217217
runtime,
218218
ab,
219219
cli::to_operations(allowed_operations),

crates/trident/src/manual_rollback/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn get_rollback_info(datastore: &DataStore, kind: GetKind) -> Result<String,
8585
/// Handle manual rollback operations.
8686
pub fn execute_rollback(
8787
datastore: &mut DataStore,
88-
dry_run: bool,
88+
check: bool,
8989
invoke_if_next_is_runtime: bool,
9090
invoke_available_ab: bool,
9191
allowed_operations: &Operations,
@@ -105,13 +105,13 @@ pub fn execute_rollback(
105105
.structured(ServicingError::ManualRollback)
106106
.message("Failed to get available rollbacks")?;
107107

108-
let (rollback_index, dry_run_string) = get_requested_rollback_info(
108+
let (rollback_index, check_string) = get_requested_rollback_info(
109109
&available_rollbacks,
110110
invoke_if_next_is_runtime,
111111
invoke_available_ab,
112112
)?;
113-
if dry_run {
114-
println!("{}", dry_run_string);
113+
if check {
114+
println!("{}", check_string);
115115
return Ok(ExitKind::Done);
116116
}
117117

@@ -1041,31 +1041,31 @@ mod tests {
10411041
}
10421042

10431043
#[test]
1044-
fn test_dry_run() {
1044+
fn test_check() {
10451045
let mut host_status_list = vec![
10461046
inter(None, CI_FINAL, MIN),
10471047
inter(None, CI_FINAL, MIN),
10481048
prov(VOL_A, false, vec![], MIN),
10491049
];
10501050
let context = create_rollback_context_for_testing(&host_status_list);
10511051
// if nothing is requested and there are no rollbacks, none is returned
1052-
let (index, dry_run_string) =
1052+
let (index, check_string) =
10531053
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), false, false)
10541054
.unwrap();
10551055
assert!(index.is_none());
1056-
assert_eq!(dry_run_string, "none");
1056+
assert_eq!(check_string, "none");
10571057
// if both ab and runtime rollback is requested simultaneously, error is returned
1058-
let (index, dry_run_string) =
1058+
let (index, check_string) =
10591059
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), true, false)
10601060
.unwrap();
10611061
assert!(index.is_none());
1062-
assert_eq!(dry_run_string, "none");
1062+
assert_eq!(check_string, "none");
10631063
// if both ab and runtime rollback is requested simultaneously, error is returned
1064-
let (index, dry_run_string) =
1064+
let (index, check_string) =
10651065
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), false, true)
10661066
.unwrap();
10671067
assert!(index.is_none());
1068-
assert_eq!(dry_run_string, "none");
1068+
assert_eq!(check_string, "none");
10691069

10701070
// Add some operations to datastore
10711071
host_status_list.push(inter(VOL_A, AB_STAGE, MIN));
@@ -1075,17 +1075,17 @@ mod tests {
10751075
host_status_list.push(prov(VOL_B, false, vec![5, 2], MIN));
10761076
let context = create_rollback_context_for_testing(&host_status_list);
10771077
// if runtime rollback is requested and it is the next rollback, return the index of the runtime rollback and 'runtime'
1078-
let (index, dry_run_string) =
1078+
let (index, check_string) =
10791079
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), false, false)
10801080
.unwrap();
10811081
assert_eq!(index, Some(0));
1082-
assert_eq!(dry_run_string, "runtime");
1082+
assert_eq!(check_string, "runtime");
10831083
// if ab rollback is requested and it is not the next rollback, return the index of the ab rollback and 'ab'
1084-
let (index, dry_run_string) =
1084+
let (index, check_string) =
10851085
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), false, true)
10861086
.unwrap();
10871087
assert_eq!(index, Some(1));
1088-
assert_eq!(dry_run_string, "ab");
1088+
assert_eq!(check_string, "ab");
10891089
// if both ab and runtime rollback is requested simultaneously, error is returned
10901090
assert!(
10911091
get_requested_rollback_info(&context.get_rollback_chain().unwrap(), true, true)

docs/Reference/Trident-CLI.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ Argument summary:
391391
```
392392
Arguments:
393393
[KIND] What data to retrieve [default: status] [possible values:
394-
configuration, status, last-error]
394+
configuration, status, last-error, rollback-chain,
395+
rollback-target]
395396
396397
Options:
397398
-o, --outfile <OUTFILE>
@@ -413,6 +414,8 @@ Possible values:
413414
- `configuration`
414415
- `status`
415416
- `last-error`
417+
- `rollback-chain`
418+
- `rollback-target`
416419

417420
Default: `status`
418421

@@ -564,20 +567,20 @@ Argument summary:
564567

565568
```
566569
Options:
567-
--runtime
568-
Declare expectation that rollback undoes a runtime update
570+
--check
571+
Check operation that would be performed
569572
-v, --verbosity <VERBOSITY>
570573
Logging verbosity [OFF, ERROR, WARN, INFO, DEBUG, TRACE]
571574
[default: DEBUG]
575+
--runtime
576+
Invoke rollback only if next available rollback is runtime
577+
rollback
572578
--ab
573-
Declare expectation that rollback undoes an A/B update
579+
Invoke available A/B rollback
574580
--allowed-operations [<ALLOWED_OPERATIONS>...]
575581
Comma-separated list of operations that Trident will be
576582
allowed to perform [default: stage,finalize] [possible
577583
values: stage, finalize]
578-
--show <SHOW>
579-
Show available rollback points [possible values: validation,
580-
target, chain]
581584
-s, --status <STATUS>
582585
Path to save the resulting Host Status
583586
-e, --error <ERROR>
@@ -587,9 +590,14 @@ Options:
587590

588591
### Argument Details
589592

593+
#### <span>--check &lt;CHECK&gt;</span>
594+
595+
Check operation that would be performed
596+
597+
590598
#### <span>--runtime &lt;RUNTIME&gt;</span>
591599

592-
Declare expectation that rollback undoes a runtime update
600+
Invoke rollback only if next available rollback is runtime rollback
593601

594602
Conflicts with:
595603

@@ -598,7 +606,7 @@ Conflicts with:
598606

599607
#### <span>--ab &lt;AB&gt;</span>
600608

601-
Declare expectation that rollback undoes an A/B update
609+
Invoke available A/B rollback
602610

603611
Conflicts with:
604612

@@ -617,17 +625,6 @@ Possible values:
617625
Default: `stage,finalize`
618626

619627

620-
#### <span>--show &lt;SHOW&gt;</span>
621-
622-
Show available rollback points
623-
624-
Possible values:
625-
626-
- `validation`: Show the next available rollback type. 'ab' if an A/B update will be rolled back, 'runtime' if a runtime update will be rolled back, or 'none' if no rollback is possible
627-
- `target`: Show the next available rollback Host Configuration
628-
- `chain`: Show the full list of available rollbacks
629-
630-
631628
#### <span>--status &lt;STATUS&gt;</span>
632629

633630
Path to save the resulting Host Status

tools/storm/rollback/tests/rollback.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,24 +491,24 @@ func validateRollbacksAvailable(
491491
}
492492
}
493493

494-
rollbackShowValidationOutput, err := stormssh.SshCommand(vmConfig.VMConfig, vmIP, "sudo trident rollback --dry-run")
494+
rollbackShowValidationOutput, err := stormssh.SshCommand(vmConfig.VMConfig, vmIP, "sudo trident rollback --check")
495495
if err != nil {
496-
return fmt.Errorf("'rollback --dry-run' failed to from VM: %v", err)
496+
return fmt.Errorf("'rollback --check' failed to from VM: %v", err)
497497
}
498-
logrus.Tracef("Reported 'rollback --dry-run':\n%s", rollbackShowValidationOutput)
498+
logrus.Tracef("Reported 'rollback --check':\n%s", rollbackShowValidationOutput)
499499
if expectedAvailableRollbacks > 0 {
500500
if expectedFirstRollbackNeedsReboot {
501501
if strings.TrimSpace(rollbackShowValidationOutput) != "ab" {
502-
return fmt.Errorf("expected 'ab' from 'rollback --dry-run', got: %s", rollbackShowValidationOutput)
502+
return fmt.Errorf("expected 'ab' from 'rollback --check', got: %s", rollbackShowValidationOutput)
503503
}
504504
} else {
505505
if strings.TrimSpace(rollbackShowValidationOutput) != "runtime" {
506-
return fmt.Errorf("expected 'runtime' from 'rollback --dry-run', got: %s", rollbackShowValidationOutput)
506+
return fmt.Errorf("expected 'runtime' from 'rollback --check', got: %s", rollbackShowValidationOutput)
507507
}
508508
}
509509
} else {
510510
if strings.TrimSpace(rollbackShowValidationOutput) != "none" {
511-
return fmt.Errorf("expected 'none' from 'rollback --dry-run', got: %s", rollbackShowValidationOutput)
511+
return fmt.Errorf("expected 'none' from 'rollback --check', got: %s", rollbackShowValidationOutput)
512512
}
513513
}
514514

0 commit comments

Comments
 (0)