Skip to content

Instantly share code, notes, and snippets.

@ethercflow
Created January 16, 2020 07:39
Show Gist options
  • Save ethercflow/1ed2badb1d35e6b8d8aa8e47f6d49036 to your computer and use it in GitHub Desktop.
Save ethercflow/1ed2badb1d35e6b8d8aa8e47f6d49036 to your computer and use it in GitHub Desktop.
syntax = "proto3";
package timechaos;
import "google/protobuf/empty.proto";
service Inject {
rpc SetTimeval(Request) returns (google.protobuf.Empty) {}
rpc Recover(Request) returns (google.protobuf.Empty) {}
}
message Request {
uint32 pid = 1;
bool tid = 2;
int32 sec = 3;
int32 usec = 4;
}
@ethercflow
Copy link
Author

  1. pid: 容器内进程 root ns 中的 pid 或 tid;
  2. 如果 1 的值是 tid,则设置成 true,否则设置为 false;
    3 和 4 为偏差,假设期望某个进程访问时间函数时,时间超前 2min,则 sec 为 120s, usec 为 0;

当前 timeval 和 timespec 为 union 成员,所以暂时精度按 usec 算,以后根据需求看是否做分离;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment