Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/fuchsia_ctl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG



## 0.0.18 - 0.0.21

- Add retries to paving operations.
- Add timeouts to paving and ssh operations.
- Add arguments parameter to test command.



## 0.0.17

- Add "push-packages" option.
Expand Down
36 changes: 32 additions & 4 deletions packages/fuchsia_ctl/bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:fuchsia_ctl/src/operation_result.dart';
import 'package:fuchsia_ctl/src/tar.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:retry/retry.dart';
import 'package:uuid/uuid.dart';

typedef AsyncResult = Future<OperationResult> Function(
Expand Down Expand Up @@ -163,11 +164,21 @@ Future<OperationResult> pave(
ArgResults args,
) async {
const ImagePaver paver = ImagePaver();
return await paver.pave(
args['image'],
deviceName,
publicKeyPath: args['public-key'],
const RetryOptions r = RetryOptions(
maxDelay: Duration(seconds: 30),
maxAttempts: 3,
);
return await r.retry(() async {
final OperationResult result = await paver.pave(
args['image'],
deviceName,
publicKeyPath: args['public-key'],
);
if (!result.success) {
throw RetryException('Exit code different from 0', result);
}
return result;
}, retryIf: (Exception e) => e is RetryException);
}

@visibleForTesting
Expand Down Expand Up @@ -309,3 +320,20 @@ Future<OperationResult> test(
}
}
}

/// The exception thrown when an operation needs a retry.
class RetryException implements Exception {
/// Creates a new [RetryException] using the specified [cause] and [result]
/// to force a retry.
const RetryException(this.cause, this.result);

/// The user-facing message to display.
final String cause;

/// Contains the result of the executed target command.
final OperationResult result;

@override
String toString() =>
'$runtimeType, cause: "$cause", underlying exception: $result.';
}
3 changes: 2 additions & 1 deletion packages/fuchsia_ctl/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: >
Fuchsia Device. This package is primarily intended for use in Flutter's
continuous integration/testing infrastructure.
homepage: https://github.com/flutter/packags/tree/master/packages/fuchsia_ctl
version: 0.0.17
version: 0.0.21

environment:
sdk: ">=2.4.0 <3.0.0"
Expand All @@ -15,6 +15,7 @@ dependencies:
meta: ^1.1.7
path: ^1.6.4
process: ^3.0.12
retry: ^3.0.0+1
uuid: ^2.0.2

dev_dependencies:
Expand Down