agent

package
v0.0.0-...-73798e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Port            = 9909
	StorageDir      = "/storage"
	DataDir         = StorageDir + "/data"
	ConfigFile      = StorageDir + "/config.yaml"
	LogFile         = StorageDir + "/scout.log"
	ServiceTypeFile = StorageDir + "/service_type"
	UID             = 888
	GID             = 888
)
View Source
const (
	Service_GetStatus_FullMethodName      = "/agent.Service/GetStatus"
	Service_ConfigService_FullMethodName  = "/agent.Service/ConfigService"
	Service_StartService_FullMethodName   = "/agent.Service/StartService"
	Service_StopService_FullMethodName    = "/agent.Service/StopService"
	Service_RestartService_FullMethodName = "/agent.Service/RestartService"
	Service_ResetService_FullMethodName   = "/agent.Service/ResetService"
	Service_GetLogs_FullMethodName        = "/agent.Service/GetLogs"
	Service_RunNemesis_FullMethodName     = "/agent.Service/RunNemesis"
)

Variables

View Source
var (
	ServiceType_name = map[int32]string{
		0: "None",
		1: "Control",
		2: "Data",
		3: "Api",
		4: "Unknown",
	}
	ServiceType_value = map[string]int32{
		"None":    0,
		"Control": 1,
		"Data":    2,
		"Api":     3,
		"Unknown": 4,
	}
)

Enum value maps for ServiceType.

View Source
var File_internal_testing_agent_agent_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "agent.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetStatus",
			Handler:    _Service_GetStatus_Handler,
		},
		{
			MethodName: "ConfigService",
			Handler:    _Service_ConfigService_Handler,
		},
		{
			MethodName: "StartService",
			Handler:    _Service_StartService_Handler,
		},
		{
			MethodName: "StopService",
			Handler:    _Service_StopService_Handler,
		},
		{
			MethodName: "RestartService",
			Handler:    _Service_RestartService_Handler,
		},
		{
			MethodName: "ResetService",
			Handler:    _Service_ResetService_Handler,
		},
		{
			MethodName: "GetLogs",
			Handler:    _Service_GetLogs_Handler,
		},
		{
			MethodName: "RunNemesis",
			Handler:    _Service_RunNemesis_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "internal/testing/agent/agent.proto",
}

Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type BumpTime

type BumpTime struct {
	Delta int32 `protobuf:"varint,1,opt,name=delta,proto3" json:"delta,omitempty"`
	// contains filtered or unexported fields
}

Changes the current system time by the provided delta and then restores it to the original value. Delta is expected in millis.

func (*BumpTime) Descriptor deprecated

func (*BumpTime) Descriptor() ([]byte, []int)

Deprecated: Use BumpTime.ProtoReflect.Descriptor instead.

func (*BumpTime) GetDelta

func (x *BumpTime) GetDelta() int32

func (*BumpTime) ProtoMessage

func (*BumpTime) ProtoMessage()

func (*BumpTime) ProtoReflect

func (x *BumpTime) ProtoReflect() protoreflect.Message

func (*BumpTime) Reset

func (x *BumpTime) Reset()

func (*BumpTime) Run

func (n *BumpTime) Run(ctx context.Context) error

BumpTime changes the current system time by the provided delta and then restores to original time when the ctx is done.

func (*BumpTime) String

func (x *BumpTime) String() string

type Client

type Client struct {
	ServiceClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(nodeIP string) (*Client, error)

func (*Client) Close

func (c *Client) Close()

type ConfigRequest

type ConfigRequest struct {
	ServiceType ServiceType `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=agent.ServiceType" json:"service_type,omitempty"`
	ConfigFile  []byte      `protobuf:"bytes,2,opt,name=config_file,json=configFile,proto3" json:"config_file,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfigRequest) Descriptor deprecated

func (*ConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use ConfigRequest.ProtoReflect.Descriptor instead.

func (*ConfigRequest) GetConfigFile

func (x *ConfigRequest) GetConfigFile() []byte

func (*ConfigRequest) GetServiceType

func (x *ConfigRequest) GetServiceType() ServiceType

func (*ConfigRequest) ProtoMessage

func (*ConfigRequest) ProtoMessage()

func (*ConfigRequest) ProtoReflect

func (x *ConfigRequest) ProtoReflect() protoreflect.Message

func (*ConfigRequest) Reset

func (x *ConfigRequest) Reset()

func (*ConfigRequest) String

func (x *ConfigRequest) String() string

func (*ConfigRequest) Validate

func (x *ConfigRequest) Validate() error

type Kill

type Kill struct {
	// contains filtered or unexported fields
}

Kills the service using SIGKILL signal and systemd will auto restart it. Can be used to simulate hard crash-restart fault.

func (*Kill) Descriptor deprecated

func (*Kill) Descriptor() ([]byte, []int)

Deprecated: Use Kill.ProtoReflect.Descriptor instead.

func (*Kill) ProtoMessage

func (*Kill) ProtoMessage()

func (*Kill) ProtoReflect

func (x *Kill) ProtoReflect() protoreflect.Message

func (*Kill) Reset

func (x *Kill) Reset()

func (*Kill) Run

func (n *Kill) Run(ctx context.Context) error

Kills the service using SIGKILL signal and systemd will auto restart it. Can be used to simulate hard crash-restart fault.

func (*Kill) String

func (x *Kill) String() string

type Logs

type Logs struct {
	Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*Logs) Descriptor deprecated

func (*Logs) Descriptor() ([]byte, []int)

Deprecated: Use Logs.ProtoReflect.Descriptor instead.

func (*Logs) GetData

func (x *Logs) GetData() []byte

func (*Logs) ProtoMessage

func (*Logs) ProtoMessage()

func (*Logs) ProtoReflect

func (x *Logs) ProtoReflect() protoreflect.Message

func (*Logs) Reset

func (x *Logs) Reset()

func (*Logs) String

func (x *Logs) String() string

type Nemesis

type Nemesis interface {
	Run(context.Context) error
}

type NemesisRequest

type NemesisRequest struct {
	Duration *durationpb.Duration `protobuf:"bytes,1,opt,name=duration,proto3" json:"duration,omitempty"`
	// Types that are assignable to Payload:
	//
	//	*NemesisRequest_Kill
	//	*NemesisRequest_Pause
	//	*NemesisRequest_Restart
	//	*NemesisRequest_BumpTime
	//	*NemesisRequest_StrobeTime
	Payload isNemesisRequest_Payload `protobuf_oneof:"payload"`
	// contains filtered or unexported fields
}

func NewNemesisRequest

func NewNemesisRequest(nemesis Nemesis, duration time.Duration) *NemesisRequest

func (*NemesisRequest) Descriptor deprecated

func (*NemesisRequest) Descriptor() ([]byte, []int)

Deprecated: Use NemesisRequest.ProtoReflect.Descriptor instead.

func (*NemesisRequest) GetBumpTime

func (x *NemesisRequest) GetBumpTime() *BumpTime

func (*NemesisRequest) GetDuration

func (x *NemesisRequest) GetDuration() *durationpb.Duration

func (*NemesisRequest) GetKill

func (x *NemesisRequest) GetKill() *Kill

func (*NemesisRequest) GetPause

func (x *NemesisRequest) GetPause() *Pause

func (*NemesisRequest) GetPayload

func (m *NemesisRequest) GetPayload() isNemesisRequest_Payload

func (*NemesisRequest) GetRestart

func (x *NemesisRequest) GetRestart() *Restart

func (*NemesisRequest) GetStrobeTime

func (x *NemesisRequest) GetStrobeTime() *StrobeTime

func (*NemesisRequest) Name

func (x *NemesisRequest) Name() string

func (*NemesisRequest) Nemesis

func (x *NemesisRequest) Nemesis() Nemesis

func (*NemesisRequest) ProtoMessage

func (*NemesisRequest) ProtoMessage()

func (*NemesisRequest) ProtoReflect

func (x *NemesisRequest) ProtoReflect() protoreflect.Message

func (*NemesisRequest) Reset

func (x *NemesisRequest) Reset()

func (*NemesisRequest) String

func (x *NemesisRequest) String() string

func (*NemesisRequest) Validate

func (x *NemesisRequest) Validate() error

type NemesisRequest_BumpTime

type NemesisRequest_BumpTime struct {
	BumpTime *BumpTime `protobuf:"bytes,5,opt,name=bump_time,json=bumpTime,proto3,oneof"`
}

type NemesisRequest_Kill

type NemesisRequest_Kill struct {
	Kill *Kill `protobuf:"bytes,2,opt,name=kill,proto3,oneof"`
}

type NemesisRequest_Pause

type NemesisRequest_Pause struct {
	Pause *Pause `protobuf:"bytes,3,opt,name=pause,proto3,oneof"`
}

type NemesisRequest_Restart

type NemesisRequest_Restart struct {
	Restart *Restart `protobuf:"bytes,4,opt,name=restart,proto3,oneof"`
}

type NemesisRequest_StrobeTime

type NemesisRequest_StrobeTime struct {
	StrobeTime *StrobeTime `protobuf:"bytes,6,opt,name=strobe_time,json=strobeTime,proto3,oneof"`
}

type Pause

type Pause struct {
	// contains filtered or unexported fields
}

Pauses the service and then resumes it. Can be used to simulate a GC pause.

func (*Pause) Descriptor deprecated

func (*Pause) Descriptor() ([]byte, []int)

Deprecated: Use Pause.ProtoReflect.Descriptor instead.

func (*Pause) ProtoMessage

func (*Pause) ProtoMessage()

func (*Pause) ProtoReflect

func (x *Pause) ProtoReflect() protoreflect.Message

func (*Pause) Reset

func (x *Pause) Reset()

func (*Pause) Run

func (n *Pause) Run(ctx context.Context) error

Pauses the service until ctx in done and then resumes it. Can be used to simulate a GC pause.

func (*Pause) String

func (x *Pause) String() string

type ResetRequest

type ResetRequest struct {
	Time         *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Service      bool                   `protobuf:"varint,2,opt,name=service,proto3" json:"service,omitempty"`
	Nemesis      bool                   `protobuf:"varint,3,opt,name=nemesis,proto3" json:"nemesis,omitempty"`
	TruncateLogs bool                   `protobuf:"varint,4,opt,name=truncate_logs,json=truncateLogs,proto3" json:"truncate_logs,omitempty"`
	// contains filtered or unexported fields
}

func (*ResetRequest) Descriptor deprecated

func (*ResetRequest) Descriptor() ([]byte, []int)

Deprecated: Use ResetRequest.ProtoReflect.Descriptor instead.

func (*ResetRequest) GetNemesis

func (x *ResetRequest) GetNemesis() bool

func (*ResetRequest) GetService

func (x *ResetRequest) GetService() bool

func (*ResetRequest) GetTime

func (x *ResetRequest) GetTime() *timestamppb.Timestamp

func (*ResetRequest) GetTruncateLogs

func (x *ResetRequest) GetTruncateLogs() bool

func (*ResetRequest) ProtoMessage

func (*ResetRequest) ProtoMessage()

func (*ResetRequest) ProtoReflect

func (x *ResetRequest) ProtoReflect() protoreflect.Message

func (*ResetRequest) Reset

func (x *ResetRequest) Reset()

func (*ResetRequest) String

func (x *ResetRequest) String() string

func (*ResetRequest) Validate

func (x *ResetRequest) Validate() error

type Restart

type Restart struct {
	// contains filtered or unexported fields
}

Stops the service until ctx in done and then starts it back again. Can be used to simulate soft restart as in normal maintenance ops.

func (*Restart) Descriptor deprecated

func (*Restart) Descriptor() ([]byte, []int)

Deprecated: Use Restart.ProtoReflect.Descriptor instead.

func (*Restart) ProtoMessage

func (*Restart) ProtoMessage()

func (*Restart) ProtoReflect

func (x *Restart) ProtoReflect() protoreflect.Message

func (*Restart) Reset

func (x *Restart) Reset()

func (*Restart) Run

func (n *Restart) Run(ctx context.Context) error

Stops the service until ctx in done and then starts it back again. Can be used to simulate soft restart as in normal maintenance ops.

func (*Restart) String

func (x *Restart) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) Start

func (n *Server) Start(ctx context.Context) error

func (*Server) Stop

func (n *Server) Stop()

type ServiceClient

type ServiceClient interface {
	GetStatus(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Status, error)
	ConfigService(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	StartService(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	StopService(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	RestartService(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	ResetService(ctx context.Context, in *ResetRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	GetLogs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Logs, error)
	RunNemesis(ctx context.Context, in *NemesisRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}

ServiceClient is the client API for Service service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

Service represents the agent service.

func NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer interface {
	GetStatus(context.Context, *emptypb.Empty) (*Status, error)
	ConfigService(context.Context, *ConfigRequest) (*emptypb.Empty, error)
	StartService(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	StopService(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	RestartService(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	ResetService(context.Context, *ResetRequest) (*emptypb.Empty, error)
	GetLogs(context.Context, *emptypb.Empty) (*Logs, error)
	RunNemesis(context.Context, *NemesisRequest) (*emptypb.Empty, error)
	// contains filtered or unexported methods
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility.

Service represents the agent service.

type ServiceType

type ServiceType int32
const (
	ServiceType_None    ServiceType = 0
	ServiceType_Control ServiceType = 1
	ServiceType_Data    ServiceType = 2
	ServiceType_Api     ServiceType = 3
	ServiceType_Unknown ServiceType = 4
)

func (ServiceType) Descriptor

func (ServiceType) Enum

func (x ServiceType) Enum() *ServiceType

func (ServiceType) EnumDescriptor deprecated

func (ServiceType) EnumDescriptor() ([]byte, []int)

Deprecated: Use ServiceType.Descriptor instead.

func (ServiceType) IsValid

func (x ServiceType) IsValid() bool

func (ServiceType) Number

func (x ServiceType) Number() protoreflect.EnumNumber

func (ServiceType) String

func (x ServiceType) String() string

func (ServiceType) Type

type Status

type Status struct {
	ServiceType   ServiceType            `protobuf:"varint,1,opt,name=service_type,json=serviceType,proto3,enum=agent.ServiceType" json:"service_type,omitempty"`
	ServiceActive bool                   `protobuf:"varint,2,opt,name=service_active,json=serviceActive,proto3" json:"service_active,omitempty"`
	Time          *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=time,proto3" json:"time,omitempty"`
	NemesisCount  uint32                 `protobuf:"varint,4,opt,name=nemesis_count,json=nemesisCount,proto3" json:"nemesis_count,omitempty"`
	// contains filtered or unexported fields
}

func (*Status) Descriptor deprecated

func (*Status) Descriptor() ([]byte, []int)

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetNemesisCount

func (x *Status) GetNemesisCount() uint32

func (*Status) GetServiceActive

func (x *Status) GetServiceActive() bool

func (*Status) GetServiceType

func (x *Status) GetServiceType() ServiceType

func (*Status) GetTime

func (x *Status) GetTime() *timestamppb.Timestamp

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

type StrobeTime

type StrobeTime struct {
	Delta  int32  `protobuf:"varint,1,opt,name=delta,proto3" json:"delta,omitempty"`
	Period uint32 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"`
	// contains filtered or unexported fields
}

StrobeTime changes the current system time back and forth by adding then removing the provided delta, repeatedly, in each period. Delta and period are expected in millis.

func (*StrobeTime) Descriptor deprecated

func (*StrobeTime) Descriptor() ([]byte, []int)

Deprecated: Use StrobeTime.ProtoReflect.Descriptor instead.

func (*StrobeTime) GetDelta

func (x *StrobeTime) GetDelta() int32

func (*StrobeTime) GetPeriod

func (x *StrobeTime) GetPeriod() uint32

func (*StrobeTime) ProtoMessage

func (*StrobeTime) ProtoMessage()

func (*StrobeTime) ProtoReflect

func (x *StrobeTime) ProtoReflect() protoreflect.Message

func (*StrobeTime) Reset

func (x *StrobeTime) Reset()

func (*StrobeTime) Run

func (n *StrobeTime) Run(ctx context.Context) error

StrobeTime changes the current system time back and forth by adding then removing the provided delta, repeatedly, in each period.

func (*StrobeTime) String

func (x *StrobeTime) String() string

type UnimplementedServiceServer

type UnimplementedServiceServer struct{}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedServiceServer) ConfigService

func (UnimplementedServiceServer) GetLogs

func (UnimplementedServiceServer) GetStatus

func (UnimplementedServiceServer) ResetService

func (UnimplementedServiceServer) RestartService

func (UnimplementedServiceServer) RunNemesis

func (UnimplementedServiceServer) StartService

func (UnimplementedServiceServer) StopService

type UnsafeServiceServer

type UnsafeServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL