nemesis

package
v0.0.0-...-f78b0ad Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK = iota
	StatusError
)

nemesis status

View Source
const (
	TaskCreate = iota
	TaskTerminate
)

Task operations

View Source
const (
	WEPERM  = 1
	WEINTR  = 4
	WEIO    = 5
	WEBADF  = 9
	WEINVAL = 22
	WEFBIG  = 27
	WENOSPC = 28
	WEDQUOT = 122
)

write error

View Source
const (
	REINTR  = 4
	RIO     = 5
	REBADF  = 9
	REINVAL = 22
)

read error

Variables

View Source
var (
	ErrNotFount       = errors.New("not founnd")
	ErrUnknown        = errors.New("unknown")
	ErrEmptyNodes     = errors.New("empty nodes")
	ErrInvalidateArgs = errors.New("invalidate arguments")
)

errors to return

View Source
var (
	ReadErrorList  = []int{REINTR, RIO, REBADF, REINVAL}
	WriteErrorList = []int{WEPERM, WEINTR, WEIO, WEBADF, WEINVAL, WEFBIG, WENOSPC, WEDQUOT}
)

error list

Functions

This section is empty.

Types

type Manager

type Manager struct {
	NemesisDict map[string]Nemesis // nemesis instances dict
	sync.Mutex
}

Manager create, kill and maintain the nemesis

func NewManager

func NewManager() *Manager

NewManager create a new nemesis manager

func (*Manager) CreateNemesis

func (m *Manager) CreateNemesis(task *Task) (string, error)

CreateNemesis create or run a existed nemesis

func (*Manager) NumberOfNemesis

func (m *Manager) NumberOfNemesis() int

NumberOfNemesis returns total number of nemesis

func (*Manager) TerminateAllNemesis

func (m *Manager) TerminateAllNemesis()

TerminateAllNemesis kill all nemesis

func (*Manager) TerminateNemesis

func (m *Manager) TerminateNemesis(task *Task) error

TerminateNemesis kill a existed nemesis

type Nemesis

type Nemesis interface {
	GetID() string
	GetType() int
	GetStatus() int
	Run() error
	Terminate() error
}

Nemesis interface

type Partition

type Partition struct {
	ID           string   // unique id
	Type         int      // nemesis type
	Status       int      // runtime status
	LasterError  error    // last error
	RejectedNode []string // nodes to disable
	Debug        bool     // if is in debug mod
}

Partition disable the communication with specified nodes Note: for the sake of safty, all the nodes of partition must not be the controller TODO: unilateral disable

func NewPartition

func NewPartition(agents []string) *Partition

NewPartition create a new partition nemesis

func (*Partition) GetID

func (p *Partition) GetID() string

GetID implement Nemesis

func (*Partition) GetStatus

func (p *Partition) GetStatus() int

GetStatus implement Nemesis

func (*Partition) GetType

func (p *Partition) GetType() int

GetType implement Nemesis

func (*Partition) Run

func (p *Partition) Run() error

Run start the nemesis with inner run function

func (*Partition) Terminate

func (p *Partition) Terminate() error

Terminate ends the nemesis with inner terminate function

type Persistence

type Persistence struct {
	ID          string    // unique id
	Type        int       // nemesis type
	Status      int       // runtime status
	LasterError error     // last error
	Command     string    // long running command
	Process     *exec.Cmd // inner command struct
	Debug       bool      // if is in debug mod
}

Persistence manages the long running nemesis

func NewPersistence

func NewPersistence(command string) *Persistence

NewPersistence create a new persistent nemesis

func (*Persistence) Run

func (p *Persistence) Run() error

Run start the persistent nemesis

func (*Persistence) Terminate

func (p *Persistence) Terminate() error

Terminate stop the persistent nemesis

type Service

type Service struct {
	ID            string // unique id
	Type          int    // nemesis type
	Status        int    // runtime status
	LasterError   error  // last error
	CommandRun    string // command to kill the process
	CommandRevive string // command to revive the process
	Debug         bool   // if is in debug mod
}

Service process service level nemesis

func NewService

func NewService(run, revive string) *Service

NewService create a nemesis to stop and revive a process

func (*Service) GetID

func (s *Service) GetID() string

GetID implement Nemesis

func (*Service) GetStatus

func (s *Service) GetStatus() int

GetStatus implement Nemesis

func (*Service) GetType

func (s *Service) GetType() int

GetType implement Nemesis

func (*Service) Run

func (s *Service) Run() error

Run start the nemesis

func (*Service) Terminate

func (s *Service) Terminate() error

Terminate revives the process with CommandRevive

type SystemTap

type SystemTap struct {
	P         *Persistence   // persistent nemesis
	Arguments []string       // aguments for the systemtap script
	Class     SystemTapClass // system tap class
}

SystemTap wrapper

func NewSTP

func NewSTP(argument map[string]string, class SystemTapClass) (*SystemTap, error)

NewSTP create a new systemtap runtime

func (*SystemTap) GetID

func (s *SystemTap) GetID() string

GetID implement Nemesis

func (*SystemTap) GetStatus

func (s *SystemTap) GetStatus() int

GetStatus implement Nemesis

func (*SystemTap) GetType

func (s *SystemTap) GetType() int

GetType implement Nemesis

func (*SystemTap) Run

func (s *SystemTap) Run() error

Run start the systemtap probe

func (*SystemTap) Terminate

func (s *SystemTap) Terminate() error

Terminate stop the systemtap probe

type SystemTapClass

type SystemTapClass int

SystemTapClass specifies which kind of script to run

const (
	SystemTapIOError SystemTapClass = iota
	SystemTapIODelay
)

systemtap types

type Task

type Task struct {
	Name      string
	Type      int
	ID        string
	Arguments map[string]string
	Op        int
}

Task contains the infomation to operate a nemesis

Jump to

Keyboard shortcuts

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