Skip to content

Commit

Permalink
feat(api): fault injection made more generic
Browse files Browse the repository at this point in the history
Fault injection support moved from nexus API to a new testing API,
and made more generic.
Injectiosn removed from v0 API.

Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Jul 31, 2023
1 parent 400c703 commit 5293fcd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 67 deletions.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn main() {
"protobuf/v1/nexus.proto",
"protobuf/v1/registration.proto",
"protobuf/v1/snapshot.proto",
"protobuf/v1/test.proto",
],
&["protobuf/v1"],
)
Expand Down
28 changes: 0 additions & 28 deletions protobuf/mayastor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ service Mayastor {
rpc FaultNexusChild (FaultNexusChildRequest) returns (Null) {}
rpc ShutdownNexus (ShutdownNexusRequest) returns (Null) {}

// Nexus-level fault injection and other development methods
rpc InjectNexusFault (InjectNexusFaultRequest) returns (Null) {}
rpc RemoveInjectedNexusFault (RemoveInjectedNexusFaultRequest) returns (Null) {}
rpc ListInjectedNexusFaults (ListInjectedNexusFaultsRequest) returns (ListInjectedNexusFaultsReply) {}

// This method is called by control plane to construct a block device
// (/dev/...) that will be used to connect the nexus to the OS.
rpc PublishNexus (PublishNexusRequest) returns (PublishNexusReply) {}
Expand Down Expand Up @@ -393,29 +388,6 @@ message FaultNexusChildRequest {
string uri = 2; // URI of the child device to be faulted
}

message InjectNexusFaultRequest {
string uuid = 1; // uuid of the nexus
string uri = 2; // Fault injection URI
}

message RemoveInjectedNexusFaultRequest {
string uuid = 1; // uuid of the nexus
string uri = 2; // Fault injection URI
}

message InjectedFault {
string device_name = 1;
bool is_active = 2;
}

message ListInjectedNexusFaultsRequest {
string uuid = 1; // uuid of the nexus
}

message ListInjectedNexusFaultsReply {
repeated InjectedFault injections = 1;
}

// this message will be subject to change as we will add support for remote
// storage protocols.
message PublishNexusRequest {
Expand Down
28 changes: 0 additions & 28 deletions protobuf/v1/nexus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ service NexusRpc {

rpc ShutdownNexus (ShutdownNexusRequest) returns (ShutdownNexusResponse) {}

// Nexus-level fault injection and other development methods
rpc InjectNexusFault (InjectNexusFaultRequest) returns (google.protobuf.Empty) {}
rpc RemoveInjectedNexusFault (RemoveInjectedNexusFaultRequest) returns (google.protobuf.Empty) {}
rpc ListInjectedNexusFaults (ListInjectedNexusFaultsRequest) returns (ListInjectedNexusFaultsReply) {}

// This method is called by control plane to construct a block device
// (/dev/...) that will be used to connect the nexus to the OS.
rpc PublishNexus (PublishNexusRequest) returns (PublishNexusResponse) {}
Expand Down Expand Up @@ -211,29 +206,6 @@ message FaultNexusChildResponse {
Nexus nexus = 1;
}

message InjectNexusFaultRequest {
string uuid = 1; // uuid of the nexus
string uri = 2; // Fault injection URI
}

message RemoveInjectedNexusFaultRequest {
string uuid = 1; // uuid of the nexus
string uri = 2; // Fault injection URI
}

message InjectedFault {
string device_name = 1;
bool is_active = 2;
}

message ListInjectedNexusFaultsRequest {
string uuid = 1; // uuid of the nexus
}

message ListInjectedNexusFaultsReply {
repeated InjectedFault injections = 1;
}

// this message will be subject to change as we will add support for remote
// storage protocols.
message PublishNexusRequest {
Expand Down
49 changes: 49 additions & 0 deletions protobuf/v1/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
syntax = "proto3";

import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";

package mayastor.v1;

// Service to be used by test code, it is not meant to be used in production!
service TestRpc {
//
// Fault injection methods.
//

// Add a fault injection.
rpc AddInjection (AddInjectionRequest) returns (google.protobuf.Empty) {}

// Remove a fault injection.
rpc RemoveInjection (RemoveInjectionRequest) returns (google.protobuf.Empty) {}

// List existing fault injections.
rpc ListInjections (ListInjectionsRequest) returns (ListInjectionsReply) {}
}

message Injection {
// URI that was used to add the fault injection.
string uri = 1;
// Target device name to which the injection applies.
string device_name = 2;
// True if the injection is currently active (injection active condition
// has been met).
bool is_active = 3;
}

message AddInjectionRequest {
// URI that defines injection target and parameters.
string uri = 1;
}

message RemoveInjectionRequest {
// URI that was used to add the fault injection.
string uri = 1;
}

message ListInjectionsRequest {
}

message ListInjectionsReply {
repeated Injection injections = 1;
}
30 changes: 19 additions & 11 deletions src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,25 @@ pub mod nexus {
AddChildNexusRequest, AddChildNexusResponse, Child, ChildAction, ChildOperationRequest,
ChildOperationResponse, ChildState, ChildStateReason, CreateNexusRequest,
CreateNexusResponse, DestroyNexusRequest, FaultNexusChildRequest, FaultNexusChildResponse,
GetNvmeAnaStateRequest, GetNvmeAnaStateResponse, InjectNexusFaultRequest, InjectedFault,
ListInjectedNexusFaultsReply, ListInjectedNexusFaultsRequest, ListNexusOptions,
ListNexusResponse, ListRebuildHistoryRequest, ListRebuildHistoryResponse, Nexus,
NexusNvmePreemption, NexusState, NvmeAnaState, NvmeReservation, PauseRebuildRequest,
PauseRebuildResponse, PublishNexusRequest, PublishNexusResponse, RebuildHistoryRecord,
RebuildHistoryRequest, RebuildHistoryResponse, RebuildJobState, RebuildStateRequest,
RebuildStateResponse, RebuildStatsRequest, RebuildStatsResponse, RemoveChildNexusRequest,
RemoveChildNexusResponse, RemoveInjectedNexusFaultRequest, ResumeRebuildRequest,
ResumeRebuildResponse, SetNvmeAnaStateRequest, SetNvmeAnaStateResponse, ShareProtocol,
ShutdownNexusRequest, ShutdownNexusResponse, StartRebuildRequest, StartRebuildResponse,
StopRebuildRequest, StopRebuildResponse, UnpublishNexusRequest, UnpublishNexusResponse,
GetNvmeAnaStateRequest, GetNvmeAnaStateResponse, ListNexusOptions, ListNexusResponse,
ListRebuildHistoryRequest, ListRebuildHistoryResponse, Nexus, NexusNvmePreemption,
NexusState, NvmeAnaState, NvmeReservation, PauseRebuildRequest, PauseRebuildResponse,
PublishNexusRequest, PublishNexusResponse, RebuildHistoryRecord, RebuildHistoryRequest,
RebuildHistoryResponse, RebuildJobState, RebuildStateRequest, RebuildStateResponse,
RebuildStatsRequest, RebuildStatsResponse, RemoveChildNexusRequest,
RemoveChildNexusResponse, ResumeRebuildRequest, ResumeRebuildResponse,
SetNvmeAnaStateRequest, SetNvmeAnaStateResponse, ShareProtocol, ShutdownNexusRequest,
ShutdownNexusResponse, StartRebuildRequest, StartRebuildResponse, StopRebuildRequest,
StopRebuildResponse, UnpublishNexusRequest, UnpublishNexusResponse,
};
}

pub mod test {
pub use super::pb::{
test_rpc_client::TestRpcClient,
test_rpc_server::{TestRpc, TestRpcServer},
AddInjectionRequest, Injection, ListInjectionsReply, ListInjectionsRequest,
RemoveInjectionRequest,
};
}

Expand Down

0 comments on commit 5293fcd

Please sign in to comment.