Documentation
¶
Overview ¶
Package fis provides an in-memory implementation of the AWS Fault Injection Service (FIS) API. It supports experiment templates, experiment lifecycle management, and auto-discovered FIS actions from other registered services.
Index ¶
- Variables
- type ActionParameter
- type ActionSummary
- type ActionTarget
- type ConfigProvider
- type Experiment
- type ExperimentAction
- type ExperimentActionStatus
- type ExperimentCloudWatchLogsConfiguration
- type ExperimentExperimentOptions
- type ExperimentLogConfiguration
- type ExperimentReport
- type ExperimentReportConfiguration
- type ExperimentReportConfigurationCloudWatchDashboard
- type ExperimentReportConfigurationDataSources
- type ExperimentReportConfigurationOutputs
- type ExperimentReportConfigurationOutputsS3Configuration
- type ExperimentReportError
- type ExperimentReportS3Report
- type ExperimentReportState
- type ExperimentResolvedTarget
- type ExperimentS3Configuration
- type ExperimentStatus
- type ExperimentStatusError
- type ExperimentStopCondition
- type ExperimentTarget
- type ExperimentTargetAccountConfiguration
- type ExperimentTemplate
- type ExperimentTemplateAction
- type ExperimentTemplateCloudWatchLogsConfiguration
- type ExperimentTemplateExperimentOptions
- type ExperimentTemplateLogConfiguration
- type ExperimentTemplateReportConfiguration
- type ExperimentTemplateReportConfigurationCloudWatchDashboard
- type ExperimentTemplateReportConfigurationDataSources
- type ExperimentTemplateReportConfigurationOutputs
- type ExperimentTemplateReportConfigurationOutputsS3Configuration
- type ExperimentTemplateS3Configuration
- type ExperimentTemplateStopCondition
- type ExperimentTemplateTarget
- type ExperimentTemplateTargetFilter
- type ExportedActionDTO
- type ExportedCreateTemplateRequest
- type ExportedStartExperimentRequest
- type ExportedStopConditionDTO
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) SetActionProviders(providers []service.FISActionProvider)
- func (h *Handler) SetFaultStore(store *chaos.FaultStore)
- func (h *Handler) Shutdown(_ context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- func (h *Handler) WithJanitor(interval, experimentTTL time.Duration, taskTimeout ...time.Duration) *Handler
- type InMemoryBackend
- func (b *InMemoryBackend) CreateExperimentTemplate(input *createExperimentTemplateRequest, accountID, region string) (*ExperimentTemplate, error)
- func (b *InMemoryBackend) CreateTargetAccountConfiguration(templateID, accountID, roleArn, description string) (*TargetAccountConfiguration, error)
- func (b *InMemoryBackend) DeleteExperimentTemplate(id string) error
- func (b *InMemoryBackend) DeleteTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
- func (b *InMemoryBackend) GetAction(id string) (*ActionSummary, error)
- func (b *InMemoryBackend) GetExperiment(id string) (*Experiment, error)
- func (b *InMemoryBackend) GetExperimentTargetAccountConfiguration(experimentID, accountID string) (*ExperimentTargetAccountConfiguration, error)
- func (b *InMemoryBackend) GetExperimentTemplate(id string) (*ExperimentTemplate, error)
- func (b *InMemoryBackend) GetSafetyLever(id string) (*SafetyLever, error)
- func (b *InMemoryBackend) GetTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
- func (b *InMemoryBackend) GetTargetResourceType(resourceType string) (*TargetResourceTypeSummary, error)
- func (b *InMemoryBackend) ListActions() []ActionSummary
- func (b *InMemoryBackend) ListExperimentResolvedTargets(id string) ([]ExperimentResolvedTarget, error)
- func (b *InMemoryBackend) ListExperimentTargetAccountConfigurations(experimentID string) ([]*ExperimentTargetAccountConfiguration, error)
- func (b *InMemoryBackend) ListExperimentTemplates() ([]*ExperimentTemplate, error)
- func (b *InMemoryBackend) ListExperiments() ([]*Experiment, error)
- func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) ListTargetAccountConfigurations(templateID string) ([]*TargetAccountConfiguration, error)
- func (b *InMemoryBackend) ListTargetResourceTypes() []TargetResourceTypeSummary
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetActionProviders(providers []service.FISActionProvider)
- func (b *InMemoryBackend) SetFaultStore(store *chaos.FaultStore)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartExperiment(_ context.Context, input *startExperimentRequest, accountID, region string) (*Experiment, error)
- func (b *InMemoryBackend) StopAllExperiments()
- func (b *InMemoryBackend) StopExperiment(id string) (*Experiment, error)
- func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(resourceARN string, keys []string) error
- func (b *InMemoryBackend) UpdateExperimentTemplate(id string, input *updateExperimentTemplateRequest) (*ExperimentTemplate, error)
- func (b *InMemoryBackend) UpdateSafetyLeverState(id string, input *updateSafetyLeverStateRequest) (*SafetyLever, error)
- func (b *InMemoryBackend) UpdateTargetAccountConfiguration(templateID, accountID string, roleArn, description *string) (*TargetAccountConfiguration, error)
- type Janitor
- type Provider
- type SafetyLever
- type SafetyLeverState
- type Settings
- type StorageBackend
- type TargetAccountConfiguration
- type TargetResourceTypeParameter
- type TargetResourceTypeSummary
Constants ¶
This section is empty.
Variables ¶
var ErrActionNotFound = errors.New("ActionNotFound")
ErrActionNotFound is returned when a FIS action is not found.
var ErrExperimentNotFound = errors.New("ExperimentNotFound")
ErrExperimentNotFound is returned when an experiment is not found.
var ErrExperimentNotRunning = errors.New("ExperimentNotRunning")
ErrExperimentNotRunning is returned when trying to stop an experiment that is not running.
var ErrNilAppContext = errors.New("AppContext is required")
ErrNilAppContext is returned by Init when appCtx is nil.
var ErrResourceNotFound = errors.New("ResourceNotFound")
ErrResourceNotFound is returned when a tagged resource ARN is not known.
var ErrSafetyLeverEngaged = errors.New("SafetyLeverEngaged")
ErrSafetyLeverEngaged is returned when StartExperiment is blocked by an engaged safety lever.
var ErrSafetyLeverNotFound = errors.New("SafetyLeverNotFound")
ErrSafetyLeverNotFound is returned when the safety lever ID does not match this account.
var ErrTargetAccountConfigNotFound = errors.New("TargetAccountConfigurationNotFound")
ErrTargetAccountConfigNotFound is returned when a target account configuration is not found.
var ErrTargetResourceTypeNotFound = errors.New("TargetResourceTypeNotFound")
ErrTargetResourceTypeNotFound is returned when a target resource type is not found.
var ErrTemplateNotFound = errors.New("ExperimentTemplateNotFound")
ErrTemplateNotFound is returned when an experiment template is not found.
var ErrTooManyExperiments = errors.New("ServiceQuotaExceededException")
ErrTooManyExperiments is returned when the experiment count would exceed the cap.
var ErrTooManyTags = errors.New("TooManyTagsException")
ErrTooManyTags is returned when adding tags would exceed the 50-tag limit.
var ErrValidation = errors.New("ValidationException")
ErrValidation is returned when a required field is missing or has an invalid value.
Functions ¶
This section is empty.
Types ¶
type ActionParameter ¶
ActionParameter describes a parameter accepted by an action.
type ActionSummary ¶
type ActionSummary struct {
Targets map[string]ActionTarget
Parameters map[string]ActionParameter
Tags map[string]string
ID string
Arn string
Description string
}
ActionSummary is the response model for GetAction / ListActions.
type ActionTarget ¶
type ActionTarget struct {
ResourceType string
}
ActionTarget describes the target resource type required by an action.
type ConfigProvider ¶
type ConfigProvider interface {
GetFISSettings() Settings
}
ConfigProvider is a private interface to extract FIS configuration from the abstract AppContext Config.
type Experiment ¶
type Experiment struct {
CreationTime time.Time `json:"creationTime"`
StartTime time.Time `json:"startTime"`
ExperimentOptions *ExperimentExperimentOptions `json:"experimentOptions"`
ExperimentReportConfiguration *ExperimentReportConfiguration `json:"experimentReportConfiguration"`
ExperimentReport *ExperimentReport `json:"experimentReport"`
Targets map[string]ExperimentTarget `json:"targets"`
Actions map[string]ExperimentAction `json:"actions"`
LogConfiguration *ExperimentLogConfiguration `json:"logConfiguration"`
Tags map[string]string `json:"tags"`
EndTime *time.Time `json:"endTime"`
Status ExperimentStatus `json:"status"`
ExperimentTemplateID string `json:"experimentTemplateID"`
RoleArn string `json:"roleArn"`
ID string `json:"id"`
Arn string `json:"arn"`
StopConditions []ExperimentStopCondition `json:"stopConditions"`
TargetAccountConfigurationsCount int `json:"targetAccountConfigurationsCount,omitempty"`
// contains filtered or unexported fields
}
Experiment is the in-memory representation of a running FIS experiment.
type ExperimentAction ¶
type ExperimentAction struct {
Parameters map[string]string `json:"parameters"`
Targets map[string]string `json:"targets"`
StartTime *time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime"`
Status ExperimentActionStatus `json:"status"`
ActionID string `json:"actionID"`
Description string `json:"description"`
}
ExperimentAction tracks the state of an individual experiment action.
type ExperimentActionStatus ¶
ExperimentActionStatus holds the status and reason for a single action.
type ExperimentCloudWatchLogsConfiguration ¶
type ExperimentCloudWatchLogsConfiguration struct {
LogGroupArn string `json:"logGroupArn"`
}
ExperimentCloudWatchLogsConfiguration holds the CloudWatch log group ARN.
type ExperimentExperimentOptions ¶
type ExperimentExperimentOptions struct {
AccountTargeting string `json:"accountTargeting"`
EmptyTargetResolutionMode string `json:"emptyTargetResolutionMode"`
ActionsMode string `json:"actionsMode"`
}
ExperimentExperimentOptions controls account and target resolution behaviour, plus the resolved actions mode ("run-all" or "skip-all") the experiment was started with.
type ExperimentLogConfiguration ¶
type ExperimentLogConfiguration struct {
CloudWatchLogsConfiguration *ExperimentCloudWatchLogsConfiguration `json:"cloudWatchLogsConfiguration"`
S3Configuration *ExperimentS3Configuration `json:"s3Configuration"`
LogSchemaVersion int `json:"logSchemaVersion"`
}
ExperimentLogConfiguration holds resolved log configuration for an experiment.
type ExperimentReport ¶ added in v1.2.0
type ExperimentReport struct {
State *ExperimentReportState `json:"state"`
S3Reports []ExperimentReportS3Report `json:"s3Reports"`
}
ExperimentReport describes the generated report for an experiment: its state (pending/running/completed/cancelled/failed) and, once completed, the S3 objects holding the generated artifacts.
type ExperimentReportConfiguration ¶ added in v1.2.0
type ExperimentReportConfiguration struct {
DataSources *ExperimentReportConfigurationDataSources `json:"dataSources"`
Outputs *ExperimentReportConfigurationOutputs `json:"outputs"`
PreExperimentDuration string `json:"preExperimentDuration"`
PostExperimentDuration string `json:"postExperimentDuration"`
}
ExperimentReportConfiguration describes the report generation settings resolved for a running experiment (copied from its template at StartExperiment time). Shape mirrors ExperimentTemplateReportConfiguration; kept as a distinct Go type to match the real AWS FIS SDK's ExperimentTemplateReportConfiguration / ExperimentReportConfiguration split.
type ExperimentReportConfigurationCloudWatchDashboard ¶ added in v1.2.0
type ExperimentReportConfigurationCloudWatchDashboard struct {
DashboardIdentifier string `json:"dashboardIdentifier"`
}
ExperimentReportConfigurationCloudWatchDashboard identifies a CloudWatch dashboard whose widgets are captured as snapshot graphs in the experiment report.
type ExperimentReportConfigurationDataSources ¶ added in v1.2.0
type ExperimentReportConfigurationDataSources struct {
CloudWatchDashboards []ExperimentReportConfigurationCloudWatchDashboard `json:"cloudWatchDashboards"`
}
ExperimentReportConfigurationDataSources lists the data sources for an experiment report.
type ExperimentReportConfigurationOutputs ¶ added in v1.2.0
type ExperimentReportConfigurationOutputs struct {
S3Configuration *ExperimentReportConfigurationOutputsS3Configuration `json:"s3Configuration"`
}
ExperimentReportConfigurationOutputs holds the output destinations for an experiment report.
type ExperimentReportConfigurationOutputsS3Configuration ¶ added in v1.2.0
type ExperimentReportConfigurationOutputsS3Configuration struct {
BucketName string `json:"bucketName"`
Prefix string `json:"prefix"`
}
ExperimentReportConfigurationOutputsS3Configuration is the S3 destination for a generated experiment report.
type ExperimentReportError ¶ added in v1.2.0
type ExperimentReportError struct {
Code string `json:"code,omitempty"`
}
ExperimentReportError holds the error code when experiment report generation fails.
type ExperimentReportS3Report ¶ added in v1.2.0
type ExperimentReportS3Report struct {
Arn string `json:"arn"`
ReportType string `json:"reportType"`
}
ExperimentReportS3Report identifies a single generated report artifact in S3.
type ExperimentReportState ¶ added in v1.2.0
type ExperimentReportState struct {
Error *ExperimentReportError `json:"error,omitempty"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
ExperimentReportState holds the status, optional human-readable reason, and structured error info for experiment report generation.
type ExperimentResolvedTarget ¶
ExperimentResolvedTarget holds the resolved resources for a single target group.
type ExperimentS3Configuration ¶
type ExperimentS3Configuration struct {
BucketName string `json:"bucketName"`
Prefix string `json:"prefix"`
}
ExperimentS3Configuration holds the S3 bucket for experiment logs.
type ExperimentStatus ¶
type ExperimentStatus struct {
Error *ExperimentStatusError `json:"error,omitempty"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
ExperimentStatus holds the status string, an optional human-readable reason, and structured error info.
type ExperimentStatusError ¶
type ExperimentStatusError struct {
Code string `json:"code,omitempty"`
Location string `json:"location,omitempty"`
AccountID string `json:"accountId,omitempty"`
}
ExperimentStatusError holds structured error info for failed experiments. Field names mirror the real AWS FIS wire shape (types.ExperimentError): "code" and "location", not "exceptionName" — the real deserializer discards unknown keys, so a mismatched field name silently reaches SDK callers as an always-nil Code.
type ExperimentStopCondition ¶
ExperimentStopCondition mirrors ExperimentTemplateStopCondition for running experiments.
type ExperimentTarget ¶
type ExperimentTarget struct {
Parameters map[string]string `json:"parameters"`
ResourceTags map[string]string `json:"resourceTags"`
Filters []ExperimentTemplateTargetFilter `json:"filters"`
ResourceType string `json:"resourceType"`
SelectionMode string `json:"selectionMode"`
ResourceArns []string `json:"resourceArns"`
}
ExperimentTarget holds resolved resource ARNs for a target group. Filters, ResourceTags, and SelectionMode mirror the target's original template definition and are carried through as informational metadata alongside the resolved ResourceArns, matching the real AWS FIS wire shape (types.ExperimentTarget).
type ExperimentTargetAccountConfiguration ¶
type ExperimentTargetAccountConfiguration struct {
ExperimentID string `json:"experimentId"`
AccountID string `json:"accountId"`
Description string `json:"description"`
RoleArn string `json:"roleArn"`
}
ExperimentTargetAccountConfiguration is the in-memory representation of a FIS target account configuration associated with a running experiment.
type ExperimentTemplate ¶
type ExperimentTemplate struct {
CreationTime time.Time `json:"creationTime"`
LastUpdateTime time.Time `json:"lastUpdateTime"`
Tags map[string]string `json:"tags"`
Targets map[string]ExperimentTemplateTarget `json:"targets"`
Actions map[string]ExperimentTemplateAction `json:"actions"`
LogConfiguration *ExperimentTemplateLogConfiguration `json:"logConfiguration"`
ExperimentOptions *ExperimentTemplateExperimentOptions `json:"experimentOptions"`
ExperimentReportConfiguration *ExperimentTemplateReportConfiguration `json:"experimentReportConfiguration"`
ID string `json:"id"`
Arn string `json:"arn"`
Description string `json:"description"`
RoleArn string `json:"roleArn"`
StopConditions []ExperimentTemplateStopCondition `json:"stopConditions"`
}
ExperimentTemplate is the in-memory representation of a FIS experiment template.
type ExperimentTemplateAction ¶
type ExperimentTemplateAction struct {
Parameters map[string]string `json:"parameters"`
Targets map[string]string `json:"targets"`
ActionID string `json:"actionID"`
Description string `json:"description"`
StartAfter []string `json:"startAfter"`
}
ExperimentTemplateAction describes a fault action within a template.
type ExperimentTemplateCloudWatchLogsConfiguration ¶
type ExperimentTemplateCloudWatchLogsConfiguration struct {
LogGroupArn string `json:"logGroupArn"`
}
ExperimentTemplateCloudWatchLogsConfiguration holds the CloudWatch log group ARN.
type ExperimentTemplateExperimentOptions ¶
type ExperimentTemplateExperimentOptions struct {
AccountTargeting string `json:"accountTargeting"`
EmptyTargetResolutionMode string `json:"emptyTargetResolutionMode"`
}
ExperimentTemplateExperimentOptions controls account and target resolution behaviour.
type ExperimentTemplateLogConfiguration ¶
type ExperimentTemplateLogConfiguration struct {
CloudWatchLogsConfiguration *ExperimentTemplateCloudWatchLogsConfiguration `json:"cloudWatchLogsConfiguration"`
S3Configuration *ExperimentTemplateS3Configuration `json:"s3Configuration"`
LogSchemaVersion int `json:"logSchemaVersion"`
}
ExperimentTemplateLogConfiguration specifies where experiment logs are sent.
type ExperimentTemplateReportConfiguration ¶ added in v1.2.0
type ExperimentTemplateReportConfiguration struct {
DataSources *ExperimentTemplateReportConfigurationDataSources `json:"dataSources"`
Outputs *ExperimentTemplateReportConfigurationOutputs `json:"outputs"`
PreExperimentDuration string `json:"preExperimentDuration"`
PostExperimentDuration string `json:"postExperimentDuration"`
}
ExperimentTemplateReportConfiguration describes the experiment report generation settings for an experiment template: which CloudWatch dashboards to snapshot, where to write the generated report, and how much time around the experiment's start/end to include in the report's data sources.
type ExperimentTemplateReportConfigurationCloudWatchDashboard ¶ added in v1.2.0
type ExperimentTemplateReportConfigurationCloudWatchDashboard struct {
DashboardIdentifier string `json:"dashboardIdentifier"`
}
ExperimentTemplateReportConfigurationCloudWatchDashboard identifies a CloudWatch dashboard whose widgets are captured as snapshot graphs in the experiment report.
type ExperimentTemplateReportConfigurationDataSources ¶ added in v1.2.0
type ExperimentTemplateReportConfigurationDataSources struct {
CloudWatchDashboards []ExperimentTemplateReportConfigurationCloudWatchDashboard `json:"cloudWatchDashboards"`
}
ExperimentTemplateReportConfigurationDataSources lists the data sources for an experiment report.
type ExperimentTemplateReportConfigurationOutputs ¶ added in v1.2.0
type ExperimentTemplateReportConfigurationOutputs struct {
S3Configuration *ExperimentTemplateReportConfigurationOutputsS3Configuration `json:"s3Configuration"`
}
ExperimentTemplateReportConfigurationOutputs holds the output destinations for an experiment report.
type ExperimentTemplateReportConfigurationOutputsS3Configuration ¶ added in v1.2.0
type ExperimentTemplateReportConfigurationOutputsS3Configuration struct {
BucketName string `json:"bucketName"`
Prefix string `json:"prefix"`
}
ExperimentTemplateReportConfigurationOutputsS3Configuration is the S3 destination for a generated experiment report.
type ExperimentTemplateS3Configuration ¶
type ExperimentTemplateS3Configuration struct {
BucketName string `json:"bucketName"`
Prefix string `json:"prefix"`
}
ExperimentTemplateS3Configuration holds the S3 bucket for experiment logs.
type ExperimentTemplateStopCondition ¶
type ExperimentTemplateStopCondition struct {
Source string `json:"source"`
Value string `json:"value"`
}
ExperimentTemplateStopCondition defines when an experiment should automatically stop.
type ExperimentTemplateTarget ¶
type ExperimentTemplateTarget struct {
ResourceTags map[string]string `json:"resourceTags"`
Parameters map[string]string `json:"parameters"`
ResourceType string `json:"resourceType"`
SelectionMode string `json:"selectionMode"`
ResourceArns []string `json:"resourceArns"`
Filters []ExperimentTemplateTargetFilter `json:"filters"`
}
ExperimentTemplateTarget defines how resources are selected for a fault action.
type ExperimentTemplateTargetFilter ¶
type ExperimentTemplateTargetFilter struct {
Path string `json:"path"`
Values []string `json:"values"`
}
ExperimentTemplateTargetFilter narrows the set of matching resources.
type ExportedActionDTO ¶
type ExportedActionDTO = experimentTemplateActionDTO
ExportedActionDTO is the exported version of experimentTemplateActionDTO for use by the dashboard package.
type ExportedCreateTemplateRequest ¶
type ExportedCreateTemplateRequest = createExperimentTemplateRequest
ExportedCreateTemplateRequest is the exported version of createExperimentTemplateRequest for use by the dashboard package.
type ExportedStartExperimentRequest ¶
type ExportedStartExperimentRequest = startExperimentRequest
ExportedStartExperimentRequest is the exported version of startExperimentRequest for use by the dashboard package.
type ExportedStopConditionDTO ¶
type ExportedStopConditionDTO = experimentTemplateStopConditionDTO
ExportedStopConditionDTO is the exported version of experimentTemplateStopConditionDTO for use by the dashboard package.
type Handler ¶
type Handler struct {
Backend StorageBackend
DefaultRegion string
AccountID string
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for the FIS REST API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new FIS handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this FIS instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the FIS operation name from the request.
func (*Handler) ExtractResource ¶
ExtractResource extracts the resource ID from the URL path.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported FIS operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for FIS requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority for the FIS handler. FIS uses path-based routing and is inserted between PriorityPathVersioned (85) and PriorityFormRDS (84).
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset implements service.Resettable by delegating to the backend.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches FIS REST API requests by path prefix.
func (*Handler) SetActionProviders ¶
func (h *Handler) SetActionProviders(providers []service.FISActionProvider)
SetActionProviders registers external FIS action providers with the backend.
func (*Handler) SetFaultStore ¶
func (h *Handler) SetFaultStore(store *chaos.FaultStore)
SetFaultStore injects the chaos FaultStore into the backend for inject-api-* actions.
func (*Handler) Shutdown ¶
Shutdown cancels all running experiment goroutines to prevent resource leaks. It satisfies service.Shutdowner.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
func (*Handler) StartWorker ¶
StartWorker starts the background janitor if configured.
func (*Handler) WithJanitor ¶
func (h *Handler) WithJanitor( interval, experimentTTL time.Duration, taskTimeout ...time.Duration, ) *Handler
WithJanitor attaches a background janitor to the handler. If the backend is not an *InMemoryBackend, this is a no-op. The optional taskTimeout bounds each sweep; 0 means no per-task timeout.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory implementation of StorageBackend.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates a new InMemoryBackend with a background service context.
func NewInMemoryBackendWithContext ¶
func NewInMemoryBackendWithContext(svcCtx context.Context, accountID, region string) *InMemoryBackend
NewInMemoryBackendWithContext creates a new InMemoryBackend whose experiment goroutines are parented by svcCtx so they are cancelled on server shutdown. If svcCtx is nil, context.Background is used.
func (*InMemoryBackend) CreateExperimentTemplate ¶
func (b *InMemoryBackend) CreateExperimentTemplate( input *createExperimentTemplateRequest, accountID, region string, ) (*ExperimentTemplate, error)
CreateExperimentTemplate creates a new experiment template.
func (*InMemoryBackend) CreateTargetAccountConfiguration ¶
func (b *InMemoryBackend) CreateTargetAccountConfiguration( templateID, accountID, roleArn, description string, ) (*TargetAccountConfiguration, error)
CreateTargetAccountConfiguration creates or replaces a target account configuration for the given template.
func (*InMemoryBackend) DeleteExperimentTemplate ¶
func (b *InMemoryBackend) DeleteExperimentTemplate(id string) error
DeleteExperimentTemplate deletes an experiment template by ID, including its target account configurations.
func (*InMemoryBackend) DeleteTargetAccountConfiguration ¶
func (b *InMemoryBackend) DeleteTargetAccountConfiguration( templateID, accountID string, ) (*TargetAccountConfiguration, error)
DeleteTargetAccountConfiguration deletes a target account configuration.
func (*InMemoryBackend) GetAction ¶
func (b *InMemoryBackend) GetAction(id string) (*ActionSummary, error)
GetAction returns a single action by ID.
func (*InMemoryBackend) GetExperiment ¶
func (b *InMemoryBackend) GetExperiment(id string) (*Experiment, error)
GetExperiment retrieves an experiment by ID.
func (*InMemoryBackend) GetExperimentTargetAccountConfiguration ¶
func (b *InMemoryBackend) GetExperimentTargetAccountConfiguration( experimentID, accountID string, ) (*ExperimentTargetAccountConfiguration, error)
GetExperimentTargetAccountConfiguration returns the target account configuration for a running experiment. It resolves the configuration from the experiment's source template.
func (*InMemoryBackend) GetExperimentTemplate ¶
func (b *InMemoryBackend) GetExperimentTemplate(id string) (*ExperimentTemplate, error)
GetExperimentTemplate retrieves an experiment template by ID.
func (*InMemoryBackend) GetSafetyLever ¶
func (b *InMemoryBackend) GetSafetyLever(id string) (*SafetyLever, error)
GetSafetyLever returns the current state of the account's safety lever. Accepts either the account ID or the conventional "default" alias.
func (*InMemoryBackend) GetTargetAccountConfiguration ¶
func (b *InMemoryBackend) GetTargetAccountConfiguration( templateID, accountID string, ) (*TargetAccountConfiguration, error)
GetTargetAccountConfiguration returns a single target account configuration by template ID and account ID.
func (*InMemoryBackend) GetTargetResourceType ¶
func (b *InMemoryBackend) GetTargetResourceType(resourceType string) (*TargetResourceTypeSummary, error)
GetTargetResourceType returns a single target resource type by resource type string.
func (*InMemoryBackend) ListActions ¶
func (b *InMemoryBackend) ListActions() []ActionSummary
ListActions returns all available FIS actions: built-in + service-provided, sorted by ID. Built-in actions take precedence over provider-supplied actions with the same ID (dedup by ID).
func (*InMemoryBackend) ListExperimentResolvedTargets ¶
func (b *InMemoryBackend) ListExperimentResolvedTargets(id string) ([]ExperimentResolvedTarget, error)
ListExperimentResolvedTargets returns the resolved target groups for the given experiment.
func (*InMemoryBackend) ListExperimentTargetAccountConfigurations ¶
func (b *InMemoryBackend) ListExperimentTargetAccountConfigurations( experimentID string, ) ([]*ExperimentTargetAccountConfiguration, error)
ListExperimentTargetAccountConfigurations lists all target account configurations for a running experiment, sorted by account ID. It resolves configurations from the experiment's source template.
func (*InMemoryBackend) ListExperimentTemplates ¶
func (b *InMemoryBackend) ListExperimentTemplates() ([]*ExperimentTemplate, error)
ListExperimentTemplates returns all experiment templates sorted by ID.
func (*InMemoryBackend) ListExperiments ¶
func (b *InMemoryBackend) ListExperiments() ([]*Experiment, error)
ListExperiments returns all experiments sorted by ID.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
ListTagsForResource returns tags for a resource identified by its ARN.
func (*InMemoryBackend) ListTargetAccountConfigurations ¶
func (b *InMemoryBackend) ListTargetAccountConfigurations(templateID string) ([]*TargetAccountConfiguration, error)
ListTargetAccountConfigurations returns all target account configurations for a template, sorted by account ID.
func (*InMemoryBackend) ListTargetResourceTypes ¶
func (b *InMemoryBackend) ListTargetResourceTypes() []TargetResourceTypeSummary
ListTargetResourceTypes returns all known target resource types.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all in-memory state, cancelling any running experiments. The safety lever is re-initialised to its default disengaged state.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It cancels any in-flight experiment goroutines before replacing state to prevent goroutine leaks when restored experiments have no cancel func.
func (*InMemoryBackend) SetActionProviders ¶
func (b *InMemoryBackend) SetActionProviders(providers []service.FISActionProvider)
SetActionProviders registers external FIS action providers discovered from the registry.
func (*InMemoryBackend) SetFaultStore ¶
func (b *InMemoryBackend) SetFaultStore(store *chaos.FaultStore)
SetFaultStore injects the chaos FaultStore.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON.
func (*InMemoryBackend) StartExperiment ¶
func (b *InMemoryBackend) StartExperiment( _ context.Context, input *startExperimentRequest, accountID, region string, ) (*Experiment, error)
StartExperiment creates and starts a new experiment from a template.
func (*InMemoryBackend) StopAllExperiments ¶
func (b *InMemoryBackend) StopAllExperiments()
StopAllExperiments cancels every running experiment goroutine. Called during graceful shutdown to prevent goroutine leaks.
func (*InMemoryBackend) StopExperiment ¶
func (b *InMemoryBackend) StopExperiment(id string) (*Experiment, error)
StopExperiment stops a running experiment.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceARN string, tags map[string]string) error
TagResource adds or updates tags on a resource.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceARN string, keys []string) error
UntagResource removes specific tags from a resource.
func (*InMemoryBackend) UpdateExperimentTemplate ¶
func (b *InMemoryBackend) UpdateExperimentTemplate( id string, input *updateExperimentTemplateRequest, ) (*ExperimentTemplate, error)
UpdateExperimentTemplate updates an existing experiment template.
func (*InMemoryBackend) UpdateSafetyLeverState ¶
func (b *InMemoryBackend) UpdateSafetyLeverState( id string, input *updateSafetyLeverStateRequest, ) (*SafetyLever, error)
UpdateSafetyLeverState updates the state of the account's safety lever. Accepts either the account ID or the conventional "default" alias. Setting status to "engaged" blocks new experiments from starting.
func (*InMemoryBackend) UpdateTargetAccountConfiguration ¶
func (b *InMemoryBackend) UpdateTargetAccountConfiguration( templateID, accountID string, roleArn, description *string, ) (*TargetAccountConfiguration, error)
UpdateTargetAccountConfiguration updates an existing target account configuration. Only non-nil pointer fields are applied.
type Janitor ¶
type Janitor struct {
Backend *InMemoryBackend
Interval time.Duration
ExperimentTTL time.Duration
TaskTimeout time.Duration
}
Janitor is the FIS background worker that evicts completed experiments after a configurable TTL to prevent unbounded growth of in-memory state.
func NewJanitor ¶
func NewJanitor(backend *InMemoryBackend, interval, experimentTTL time.Duration) *Janitor
NewJanitor creates a new FIS Janitor for the given backend. Zero values for interval or experimentTTL fall back to defaults.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the FIS service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the FIS service backend and handler.
type SafetyLever ¶
type SafetyLever struct {
Tags map[string]string `json:"tags"`
State SafetyLeverState `json:"state"`
ID string `json:"id"`
Arn string `json:"arn"`
}
SafetyLever is the model for the FIS account-level safety lever.
type SafetyLeverState ¶
type SafetyLeverState struct {
Reason string `json:"reason"`
Status string `json:"status"` // "disengaged" | "engaged"
}
SafetyLeverState holds the status and optional human-readable reason.
type Settings ¶
type Settings struct {
JanitorInterval time.Duration `json:"janitor_interval" env:"FIS_JANITOR_INTERVAL" default:"1m" help:"Janitor tick."`
ExperimentTTL time.Duration `json:"experiment_ttl" env:"FIS_EXPERIMENT_TTL" default:"24h" help:"Done-exp TTL."`
}
Settings holds service-level configuration for the FIS backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.
type StorageBackend ¶
type StorageBackend interface {
// Template operations
CreateExperimentTemplate(
input *createExperimentTemplateRequest,
accountID, region string,
) (*ExperimentTemplate, error)
GetExperimentTemplate(id string) (*ExperimentTemplate, error)
UpdateExperimentTemplate(id string, input *updateExperimentTemplateRequest) (*ExperimentTemplate, error)
DeleteExperimentTemplate(id string) error
ListExperimentTemplates() ([]*ExperimentTemplate, error)
// Experiment operations
StartExperiment(ctx context.Context, input *startExperimentRequest, accountID, region string) (*Experiment, error)
GetExperiment(id string) (*Experiment, error)
StopExperiment(id string) (*Experiment, error)
ListExperiments() ([]*Experiment, error)
// Phase 3 — resolved targets
ListExperimentResolvedTargets(id string) ([]ExperimentResolvedTarget, error)
// Phase 3 — safety lever
GetSafetyLever(id string) (*SafetyLever, error)
UpdateSafetyLeverState(id string, input *updateSafetyLeverStateRequest) (*SafetyLever, error)
// Action / target-resource-type discovery
ListActions() []ActionSummary
GetAction(id string) (*ActionSummary, error)
ListTargetResourceTypes() []TargetResourceTypeSummary
GetTargetResourceType(resourceType string) (*TargetResourceTypeSummary, error)
// Tag operations
ListTagsForResource(resourceARN string) (map[string]string, error)
TagResource(resourceARN string, tags map[string]string) error
UntagResource(resourceARN string, keys []string) error
// Target account configuration operations (template-scoped)
CreateTargetAccountConfiguration(
templateID, accountID, roleArn, description string,
) (*TargetAccountConfiguration, error)
DeleteTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
GetTargetAccountConfiguration(templateID, accountID string) (*TargetAccountConfiguration, error)
UpdateTargetAccountConfiguration(
templateID, accountID string,
roleArn, description *string,
) (*TargetAccountConfiguration, error)
ListTargetAccountConfigurations(templateID string) ([]*TargetAccountConfiguration, error)
// Experiment target account configuration operations (experiment-scoped, read-only)
GetExperimentTargetAccountConfiguration(
experimentID, accountID string,
) (*ExperimentTargetAccountConfiguration, error)
ListExperimentTargetAccountConfigurations(experimentID string) ([]*ExperimentTargetAccountConfiguration, error)
// SetFaultStore injects the chaos FaultStore used for inject-api-* actions.
SetFaultStore(store *chaos.FaultStore)
// SetActionProviders registers external service action providers.
SetActionProviders(providers []service.FISActionProvider)
}
StorageBackend is the interface implemented by the FIS in-memory store.
type TargetAccountConfiguration ¶
type TargetAccountConfiguration struct {
ExperimentTemplateID string `json:"experimentTemplateId"`
AccountID string `json:"accountId"`
Description string `json:"description"`
RoleArn string `json:"roleArn"`
}
TargetAccountConfiguration is the in-memory representation of a FIS target account configuration associated with an experiment template.
type TargetResourceTypeParameter ¶
TargetResourceTypeParameter describes a parameter accepted when targeting a resource type.
type TargetResourceTypeSummary ¶
type TargetResourceTypeSummary struct {
Parameters map[string]TargetResourceTypeParameter
ResourceType string
Description string
}
TargetResourceTypeSummary is the response model for GetTargetResourceType / ListTargetResourceTypes.
Source Files
¶
- actions.go
- errors.go
- experiment_templates.go
- experiments.go
- exports.go
- handler.go
- handler_actions.go
- handler_experiment_templates.go
- handler_experiments.go
- handler_safety_levers.go
- handler_tags.go
- handler_target_account_configurations.go
- interfaces.go
- janitor.go
- models.go
- persistence.go
- provider.go
- safety_levers.go
- settings.go
- store.go
- store_setup.go
- tags.go
- target_account_configurations.go
- target_resource_types.go