Documentation ¶
Index ¶
- Variables
- type Assign
- type ChaosOnPOD
- type ChaosOnProcessGroup
- type Creator
- type Injectable
- type IsID
- type LockMap
- type Mergeable
- type Object
- type PodContainerName
- type PodContainerNameProcessMap
- type PodHandler
- type ProcessGroupHandler
- type Recoverable
- type SysPID
- type TaskConfig
- type TaskConfigManager
- func (m TaskConfigManager) AddTaskConfig(id TaskID, task TaskConfig) error
- func (m TaskConfigManager) CheckTask(uid TaskID, pid IsID) error
- func (m TaskConfigManager) DeleteTaskConfig(id TaskID) error
- func (m TaskConfigManager) GetConfigWithUID(id TaskID) (TaskConfig, error)
- func (m TaskConfigManager) GetUIDsWithPID(id IsID) []TaskID
- func (m TaskConfigManager) MergeTaskConfig(uid TaskID) (TaskConfig, error)
- func (m TaskConfigManager) UpdateTaskConfig(id TaskID, task TaskConfig) (TaskConfig, error)
- type TaskExecutor
- type TaskID
- type TaskManager
- func (cm TaskManager) Apply(uid TaskID, pid IsID, config TaskExecutor) error
- func (cm TaskManager) CheckTasks(uid TaskID, pid IsID) error
- func (cm TaskManager) ClearTask(pid IsID, ignoreRecoverErr bool) error
- func (cm TaskManager) CopyTaskConfigManager() TaskConfigManager
- func (cm TaskManager) CopyTaskMap() map[IsID]Injectable
- func (cm TaskManager) Create(uid TaskID, pid IsID, config TaskExecutor, values interface{}) error
- func (cm TaskManager) GetConfigWithUID(id TaskID) (TaskConfig, error)
- func (cm TaskManager) GetTaskWithPID(pid IsID) (Injectable, error)
- func (cm TaskManager) GetUIDsWithPID(pid IsID) []TaskID
- func (cm TaskManager) Recover(uid TaskID, pid IsID) error
- func (cm TaskManager) Update(uid TaskID, pid IsID, config TaskExecutor) error
Constants ¶
This section is empty.
Variables ¶
var ErrDiffID = cerr.FromErr(errors.New("different IsID"))
var ErrNotFoundID = cerr.NotFound("ID")
var ErrNotFoundSysID = cerr.NotFoundType[SysPID]()
var ErrNotFoundTaskID = cerr.NotFound("TaskID")
var ErrNotFoundTypeTaskConfig = cerr.NotFoundType[TaskConfig]()
var ErrNotPodContainerName = cerr.NotType[PodContainerName]()
var ErrNotTypeSysID = cerr.NotType[SysPID]()
var ErrPodProcessMapNotInit = cerr.NotInit[map[PodContainerName]SysPID]().WrapName("PodContainerNameProcessMap").Err()
var ErrTaskConfigMapNotInit = cerr.NotInit[map[TaskID]TaskConfig]().WrapName("TaskConfigMap").Err()
Functions ¶
This section is empty.
Types ¶
type Assign ¶
type Assign interface {
Assign(Injectable) error
}
Assign change some of an Injectable task with its own values. We use it in a case that we use TaskConfig.Data to update an Injectable task.
type ChaosOnPOD ¶
type ChaosOnPOD interface { Injectable Recoverable }
ChaosOnPOD stand for the inner process injector for container.
type ChaosOnProcessGroup ¶
type ChaosOnProcessGroup interface { Fork() (ChaosOnProcessGroup, error) Assign Injectable Recoverable }
ChaosOnProcessGroup is used for inject a chaos on a linux process group. Fork is used for create a new chaos on child process. Assign is used for update a chaos on child process.
type Creator ¶
type Creator interface {
New(values interface{}) (Injectable, error)
}
Creator init an Injectable with values. We use it in a case that TaskConfig.Data init an Injectable task here.
type Injectable ¶
Injectable stand for the base behavior of task : inject a process with IsID.
type LockMap ¶
type LockMap[K comparable] struct { sync.Map }
func NewLockMap ¶
func NewLockMap[K comparable]() LockMap[K]
type Object ¶
type Object interface {
DeepCopy() Object
}
Object ensure the outer config change will not change the data inside the TaskManager.
type PodContainerName ¶
type PodContainerName string
func (PodContainerName) ToID ¶
func (p PodContainerName) ToID() string
type PodContainerNameProcessMap ¶
type PodContainerNameProcessMap struct {
// contains filtered or unexported fields
}
func NewPodProcessMap ¶
func NewPodProcessMap() PodContainerNameProcessMap
func (*PodContainerNameProcessMap) Delete ¶
func (p *PodContainerNameProcessMap) Delete(podPID PodContainerName)
func (*PodContainerNameProcessMap) Read ¶
func (p *PodContainerNameProcessMap) Read(PodContainerName PodContainerName) (SysPID, error)
func (*PodContainerNameProcessMap) Write ¶
func (p *PodContainerNameProcessMap) Write(PodContainerName PodContainerName, sysPID SysPID)
type PodHandler ¶
type PodHandler struct { PodProcessMap *PodContainerNameProcessMap SubProcess ChaosOnPOD Logger logr.Logger }
PodHandler implements injecting & recovering on a kubernetes POD.
func NewPodHandler ¶
func NewPodHandler(podProcessMap *PodContainerNameProcessMap, sub ChaosOnPOD, logger logr.Logger) PodHandler
func (*PodHandler) Inject ¶
func (p *PodHandler) Inject(id IsID) error
Inject get the container process IsID and Inject it with major injector. Be careful about the error handling here.
func (*PodHandler) Recover ¶
func (p *PodHandler) Recover(id IsID) error
Recover get the container process IsID and Recover it with major injector. Be careful about the error handling here.
type ProcessGroupHandler ¶
type ProcessGroupHandler struct { LeaderProcess ChaosOnProcessGroup Logger logr.Logger // contains filtered or unexported fields }
ProcessGroupHandler implements injecting & recovering on a linux process group.
func NewProcessGroupHandler ¶
func NewProcessGroupHandler(logger logr.Logger, leader ChaosOnProcessGroup) ProcessGroupHandler
func (*ProcessGroupHandler) Inject ¶
func (gp *ProcessGroupHandler) Inject(pid IsID) error
Inject try to inject the leader process and then try to inject child process. If something wrong in injecting a child process, Inject will just log error & continue.
func (*ProcessGroupHandler) Recover ¶
func (gp *ProcessGroupHandler) Recover(pid IsID) error
Recover try to recover the leader process and then try to recover child process.
type Recoverable ¶
Recoverable introduce the task recovering ability. Used in Recover.
type TaskConfig ¶
TaskConfig defines a composite of flexible config with an immutable target. TaskConfig.Id is the ID of task. TaskConfig.Data is the config provided by developer.
func NewTaskConfig ¶
func NewTaskConfig(id IsID, data Object) TaskConfig
type TaskConfigManager ¶
type TaskConfigManager struct {
TaskConfigMap map[TaskID]TaskConfig
}
TaskConfigManager provides some basic methods on TaskConfig. If developers wants to use MergeTaskConfig, they must implement Mergeable for the TaskConfig.
func NewTaskConfigManager ¶
func NewTaskConfigManager() TaskConfigManager
func (TaskConfigManager) AddTaskConfig ¶
func (m TaskConfigManager) AddTaskConfig(id TaskID, task TaskConfig) error
func (TaskConfigManager) CheckTask ¶
func (m TaskConfigManager) CheckTask(uid TaskID, pid IsID) error
func (TaskConfigManager) DeleteTaskConfig ¶
func (m TaskConfigManager) DeleteTaskConfig(id TaskID) error
DeleteTaskConfig Delete task inside the TaskConfigManager
func (TaskConfigManager) GetConfigWithUID ¶
func (m TaskConfigManager) GetConfigWithUID(id TaskID) (TaskConfig, error)
func (TaskConfigManager) GetUIDsWithPID ¶
func (m TaskConfigManager) GetUIDsWithPID(id IsID) []TaskID
func (TaskConfigManager) MergeTaskConfig ¶
func (m TaskConfigManager) MergeTaskConfig(uid TaskID) (TaskConfig, error)
MergeTaskConfig will sum the TaskConfig with a same TaskConfig.Id. If developers want to use it with type T, they must implement Mergeable for *T. IMPORTANT: Just here , we do not assume A.Merge(B) == B.Merge(A). What MergeTaskConfig do : A := new(TaskConfig), A.Merge(B).Merge(C).Merge(D)... , A marked as uid.
func (TaskConfigManager) UpdateTaskConfig ¶
func (m TaskConfigManager) UpdateTaskConfig(id TaskID, task TaskConfig) (TaskConfig, error)
type TaskExecutor ¶
TaskExecutor indicate that the type can be used for execute task here as a task config. Mergeable means we can sum many task config in to one for apply. Creator means we can use the task config to create a running task which can Inject on IsID. Assign means we can use the task config to update an existing running task.
type TaskManager ¶
type TaskManager struct {
// contains filtered or unexported fields
}
TaskManager is a Manager for chaos tasks. A task base on a target marked with its IsID. We assume task should implement Injectable. We use TaskConfig.Data which implement TaskExecutor to:
Sum task configs on same IsID into one. Create task. Assign or update task.
SO if developers wants to use functions in TaskManager , their imported TaskConfig need to implement interface TaskExecutor. If developers wants to recover task successfully, the task must implement Recoverable. If not implement , the Recover function will return a ErrNotImplement("Recoverable") error. IMPORTANT: We assume task config obey that TaskConfig.Data A,B. A.Merge(B) is approximately equal to B.Merge(A)
func NewTaskManager ¶
func NewTaskManager(logger logr.Logger) TaskManager
func (TaskManager) Apply ¶
func (cm TaskManager) Apply(uid TaskID, pid IsID, config TaskExecutor) error
Apply the task when the target pid of task is already be Created. If it comes a TaskID injected , Apply will return ChaosErr.ErrDuplicateEntity. If the Process has not been Created , Apply will return ChaosErr.NotFound("IsID").
func (TaskManager) CheckTasks ¶
func (cm TaskManager) CheckTasks(uid TaskID, pid IsID) error
func (TaskManager) ClearTask ¶
func (cm TaskManager) ClearTask(pid IsID, ignoreRecoverErr bool) error
ClearTask clear the task totally. IMPORTANT: Developer should only use this function when want to force clear task with ignoreRecoverErr==true.
func (TaskManager) CopyTaskConfigManager ¶
func (cm TaskManager) CopyTaskConfigManager() TaskConfigManager
func (TaskManager) CopyTaskMap ¶
func (cm TaskManager) CopyTaskMap() map[IsID]Injectable
func (TaskManager) Create ¶
func (cm TaskManager) Create(uid TaskID, pid IsID, config TaskExecutor, values interface{}) error
Create the first task, the New function of TaskExecutor:Creator will only be used here. values is only the import parameter of New function in TaskExecutor:Creator. If it comes a task are already be injected on the IsID, Create will return ChaosErr.ErrDuplicateEntity.
func (TaskManager) GetConfigWithUID ¶
func (cm TaskManager) GetConfigWithUID(id TaskID) (TaskConfig, error)
func (TaskManager) GetTaskWithPID ¶
func (cm TaskManager) GetTaskWithPID(pid IsID) (Injectable, error)
func (TaskManager) GetUIDsWithPID ¶
func (cm TaskManager) GetUIDsWithPID(pid IsID) []TaskID
func (TaskManager) Recover ¶
func (cm TaskManager) Recover(uid TaskID, pid IsID) error
Recover the task when there is no task config on IsID or recovering the task with last task config on IsID. Recover in Recoverable will be used here, if it runs failed it will just return the error. If Recover is failed but developer wants to clear it, just run : TaskManager.ClearTask(pid, true). If IsID is already recovered successfully, Recover will return ChaosErr.NotFound("IsID"). If TaskID is not Applied or Created or the target IsID of TaskID is not the import pid, Recover will return ChaosErr.NotFound("TaskID").
func (TaskManager) Update ¶
func (cm TaskManager) Update(uid TaskID, pid IsID, config TaskExecutor) error
Update the task with a same TaskID, IsID and new task config. If it comes a TaskID not injected , Update will return ChaosErr.NotFound("TaskID"). If it comes the import IsID of task do not equal to the last one, Update will return ErrDiffID.