splitrootwf

package
v0.0.0-...-4450389 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package `splitrootwf` implements the split-root ephemeral workflow, which analyzes the disk usage below a root an suggests new repos.

Registry Configuration Events

The configuration is stored as essential registry state.

`RegistryEvent_EV_FSO_SPLIT_ROOT_ENABLED` enables the workflow for a root, so that an admin can use `nogfsoctl split-root begin`.

`RegistryEvent_EV_FSO_SPLIT_ROOT_DISABLED` disables the workflow.

`RegistryEvent_FSO_SPLIT_ROOT_PARAMS_UPDATED` sets new workflow parameters for a root. A workflow uses default parameters if the parameters were never set.

`RegistryEvent_EV_FSO_PATH_FLAG_SET` adds a path flag, such as `DONT_SPLIT`. Path flags are conceptually a set `{ (path, flag) }`. The flags are encoded as a bit mask. `RegistryEvent_EV_FSO_PATH_FLAG_UNSET` removes a path flag.

Workflow Events

An admin uses `nogfsoctl split-root begin` to initialize a workflow to determine the current disk usage and compare it to the existing repos in order to suggest new repos. The first events are `WorkflowEvent_EV_FSO_SPLIT_REPO_STARTED` on the workflow and a corresponding `WorkflowEvent_EV_FSO_SPLIT_REPO_STARTED` on the ephemeral registry workflow index.

Nogfsostad observes the workflow. It posts the `du` output as multiple `WorkflowEvent_EV_FSO_SPLIT_ROOT_DU_APPENDED`, followed by `WorkflowEvent_EV_FSO_SPLIT_ROOT_DU_COMPLETED`.

Nogfsoregd analyzes the disk usage and posts suggestions as a series of `WorkflowEvent_EV_FSO_SPLIT_ROOT_SUGGESTION_APPENDED` followed by `WorkflowEvent_EV_FSO_SPLIT_ROOT_ANALYSIS_COMPLETED`.

The admin uses `nogfsoctl split-root get` and `nogfsoctl split-root decide` to post the conclusion as a series of `WorkflowEvent_EV_FSO_SPLIT_ROOT_DECISION_APPENDED`, which may initialize new repos and modify the registry split-root configuration.

The admin finally uses `nogfsoctl split-root commit` to complete the workflow with `WorkflowEvent_EV_FSO_SPLIT_ROOT_COMPLETED` on the workflow, `WorkflowEvent_EV_FSO_SPLIT_ROOT_COMPLETED` on the workflow index, and a final `WorkflowEvent_EV_FSO_SPLIT_ROOT_COMMITTED` on the workflow.

The admin can use `nogfsoctl split-root abort` to cancel the workflow without decisions.

XXX Nogfsoregd could be change to automatically commit the workflow when there are no more pending decisions.

The final workflow event has no observable side effect. Its only purpose is to explicitly confirm termination of the workflow history. The final event may be missing if a multi-step command to complete the workflow gets interrupted.

Workflows are eventually deleted from the index with `WorkflowEvent_EV_FSO_SPLIT_ROOT_DELETED` on the index. Workflows may be deleted with or without the final `WorkflowEvent_EV_FSO_SPLIT_ROOT_COMMITTED` on the workflow.

Authorization

See implementation in `nogfsoregd/registryd/split-root.go` for details.

Workflow config:

  • A root admin may read the config.

  • But only an registry admin may change it.

  • read: action `fso/read-root` on root path.

  • create, update, delete: action `fso/admin-registry` on registry name.

Path flags:

  • A root admin may read and add flags.

  • But only an registry admin may delete flags.

  • Nogfsoregd may list the flags for workflow execution.

  • create: action `fso/admin-root` on root path.

  • delete: action `fso/admin-registry` on registry name.

  • list: action `fso/read-root` or `fso/exec-split-root` on root path.

Workflow:

  • A root admin may start a workflow.

  • Nogfsostad and Nogfsoregd may execute their tasks.

  • A root admin may append decisions and commit.

  • Nogfsoregd may abort the workflow to handle errors.

  • begin: action `fso/admin-root` on root path.

  • append, commit, abort du: action `fso/exec-du` on root path.

  • append, commit, abort suggestions: action `fso/exec-split-root` on root path.

  • decisions: action `fso/admin-root` on root path and `fso/init-repo` for new repo paths.

  • commit workflow: action `fso/admin-root` on root path.

  • abort workflow: action `fso/admin-root` or `fso/exec-split-root` on root path.

Index

Constants

View Source
const ConfigMaxDuPaths = 300
View Source
const ConfigMaxSuggestions = 300
View Source
const StatusCodeExpired = int32(pb.GetSplitRootO_SC_EXPIRED)

Variables

View Source
var NoVC = events.NoVC
View Source
var RetryNoVC = events.RetryNoVC

Functions

func IsPackageError

func IsPackageError(err error) bool

Types

type Advancer

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

The bools indicate which part of the state has been duplicated.

func (*Advancer) Advance

func (a *Advancer) Advance(s events.State, ev events.Event) events.State

type Behavior

type Behavior struct{}

func (Behavior) NewAdvancer

func (Behavior) NewAdvancer() events.Advancer

func (Behavior) NewEvent

func (Behavior) NewEvent() events.Event

func (Behavior) NewState

func (Behavior) NewState(id uuid.I) events.State

func (Behavior) Tell

func (Behavior) Tell(
	s events.State, c events.Command,
) ([]events.Event, error)

type CmdAbort

type CmdAbort struct {
	Code    int32
	Message string
}

func (*CmdAbort) AggregateCommand

func (*CmdAbort) AggregateCommand()

type CmdAbortAnalysis

type CmdAbortAnalysis struct {
	Code    int32
	Message string
}

func (*CmdAbortAnalysis) AggregateCommand

func (*CmdAbortAnalysis) AggregateCommand()

type CmdAbortDu

type CmdAbortDu struct {
	Code    int32
	Message string
}

func (*CmdAbortDu) AggregateCommand

func (*CmdAbortDu) AggregateCommand()

type CmdAbortExpired

type CmdAbortExpired struct{}

func (*CmdAbortExpired) AggregateCommand

func (*CmdAbortExpired) AggregateCommand()

type CmdAppendDecision

type CmdAppendDecision struct {
	Path     string
	Decision pb.FsoSplitRootDecision_Decision
}

func (*CmdAppendDecision) AggregateCommand

func (*CmdAppendDecision) AggregateCommand()

type CmdAppendDus

type CmdAppendDus struct {
	Paths []PathUsage
}

func (*CmdAppendDus) AggregateCommand

func (*CmdAppendDus) AggregateCommand()

type CmdAppendSuggestions

type CmdAppendSuggestions struct {
	Suggestions []Suggestion
}

func (*CmdAppendSuggestions) AggregateCommand

func (*CmdAppendSuggestions) AggregateCommand()

type CmdCommit

type CmdCommit struct{}

func (*CmdCommit) AggregateCommand

func (*CmdCommit) AggregateCommand()

type CmdCommitAnalysis

type CmdCommitAnalysis struct{}

func (*CmdCommitAnalysis) AggregateCommand

func (*CmdCommitAnalysis) AggregateCommand()

type CmdCommitDu

type CmdCommitDu struct{}

func (*CmdCommitDu) AggregateCommand

func (*CmdCommitDu) AggregateCommand()

type CmdDelete

type CmdDelete struct{}

func (*CmdDelete) AggregateCommand

func (*CmdDelete) AggregateCommand()

type CmdEnd

type CmdEnd struct{}

func (*CmdEnd) AggregateCommand

func (*CmdEnd) AggregateCommand()

type CmdInit

type CmdInit struct {
	RegistryId   uuid.I
	GlobalRoot   string
	Host         string
	HostRoot     string
	MaxDepth     int32
	MinDiskUsage int64
	MaxDiskUsage int64
}

func (*CmdInit) AggregateCommand

func (*CmdInit) AggregateCommand()

type Decision

type Decision struct {
	Path     string
	Decision pb.FsoSplitRootDecision_Decision
}

type Event

type Event struct{ wfev.Event }

func (*Event) UnmarshalProto

func (ev *Event) UnmarshalProto(data []byte) error

type EventTypeError

type EventTypeError struct{}

func (*EventTypeError) Error

func (err *EventTypeError) Error() string

type InvalidCommandError

type InvalidCommandError struct{}

func (*InvalidCommandError) Error

func (err *InvalidCommandError) Error() string

type JournalError

type JournalError struct {
	Err error
}

func (*JournalError) Error

func (err *JournalError) Error() string

func (*JournalError) Unwrap

func (err *JournalError) Unwrap() error

type NewEventsError

type NewEventsError struct {
	Err error
}

func (*NewEventsError) Error

func (err *NewEventsError) Error() string

func (*NewEventsError) Unwrap

func (err *NewEventsError) Unwrap() error

type NotCandidateError

type NotCandidateError struct {
	Path string
}

func (*NotCandidateError) Error

func (err *NotCandidateError) Error() string

type NotIdempotentError

type NotIdempotentError struct {
}

func (*NotIdempotentError) Error

func (err *NotIdempotentError) Error() string

type PathUsage

type PathUsage struct {
	Path  string
	Usage int64
}

type ResourceExhaustedError

type ResourceExhaustedError struct {
	Err string
}

func (*ResourceExhaustedError) Error

func (err *ResourceExhaustedError) Error() string

type State

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

func (*State) AggregateState

func (*State) AggregateState()

func (*State) Decisions

func (st *State) Decisions() []Decision

func (*State) Du

func (st *State) Du() []PathUsage

func (*State) GlobalRoot

func (st *State) GlobalRoot() string

func (*State) Id

func (s *State) Id() uuid.I

func (*State) IsCandidate

func (st *State) IsCandidate(path string) bool

func (*State) RegistryId

func (st *State) RegistryId() uuid.I

func (*State) SetVid

func (s *State) SetVid(vid ulid.I)

func (*State) StateCode

func (st *State) StateCode() StateCode

func (*State) StatusCode

func (st *State) StatusCode() int32

func (*State) StatusMessage

func (st *State) StatusMessage() string

func (*State) Suggestions

func (st *State) Suggestions() []Suggestion

func (*State) Vid

func (s *State) Vid() ulid.I

type StateCode

type StateCode int
const (
	StateUninitialized StateCode = iota
	StateInitialized

	StateDuAppending
	StateDuCompleted
	StateDuFailed

	StateSuggestionsAppending
	StateAnalysisCompleted
	StateAnalysisFailed

	StateDecisionsAppending

	StateCompleted
	StateFailed

	StateTerminated
)

type StateConflictError

type StateConflictError struct{}

func (*StateConflictError) Error

func (err *StateConflictError) Error() string

type Suggestion

type Suggestion struct {
	Path       string
	Suggestion pb.FsoSplitRootSuggestion_Suggestion
}

type UndecidedCandidatesError

type UndecidedCandidatesError struct{}

func (*UndecidedCandidatesError) Error

func (err *UndecidedCandidatesError) Error() string

type UninitializedError

type UninitializedError struct{}

func (*UninitializedError) Error

func (err *UninitializedError) Error() string

type Workflows

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

func New

func New(journal *events.Journal) *Workflows

func (*Workflows) Abort

func (r *Workflows) Abort(
	id uuid.I, vid ulid.I, code int32, message string,
) (ulid.I, error)

func (*Workflows) AbortAnalysis

func (r *Workflows) AbortAnalysis(
	id uuid.I, vid ulid.I, code int32, message string,
) (ulid.I, error)

func (*Workflows) AbortDu

func (r *Workflows) AbortDu(
	id uuid.I, vid ulid.I, code int32, message string,
) (ulid.I, error)

func (*Workflows) AbortExpired

func (r *Workflows) AbortExpired(id uuid.I, vid ulid.I) (ulid.I, error)

func (*Workflows) AppendDecision

func (r *Workflows) AppendDecision(
	id uuid.I, vid ulid.I,
	path string, decision pb.FsoSplitRootDecision_Decision,
) (ulid.I, error)

func (*Workflows) AppendDu

func (r *Workflows) AppendDu(
	id uuid.I, vid ulid.I,
	path string, usage int64,
) (ulid.I, error)

func (*Workflows) AppendDus

func (r *Workflows) AppendDus(
	id uuid.I, vid ulid.I, dus []PathUsage,
) (ulid.I, error)

func (*Workflows) AppendSuggestion

func (r *Workflows) AppendSuggestion(
	id uuid.I, vid ulid.I,
	path string, suggestion pb.FsoSplitRootSuggestion_Suggestion,
) (ulid.I, error)

func (*Workflows) AppendSuggestions

func (r *Workflows) AppendSuggestions(
	id uuid.I, vid ulid.I, suggestions []Suggestion,
) (ulid.I, error)

func (*Workflows) Commit

func (r *Workflows) Commit(
	id uuid.I, vid ulid.I,
) (ulid.I, error)

func (*Workflows) CommitAnalysis

func (r *Workflows) CommitAnalysis(
	id uuid.I, vid ulid.I,
) (ulid.I, error)

func (*Workflows) CommitDu

func (r *Workflows) CommitDu(
	id uuid.I, vid ulid.I,
) (ulid.I, error)

func (*Workflows) Delete

func (w *Workflows) Delete(id uuid.I, vid ulid.I) error

func (*Workflows) End

func (r *Workflows) End(id uuid.I, vid ulid.I) (ulid.I, error)

func (*Workflows) FindId

func (r *Workflows) FindId(id uuid.I) (*State, error)

func (*Workflows) Init

func (r *Workflows) Init(id uuid.I, cmd *CmdInit) (ulid.I, error)

Jump to

Keyboard shortcuts

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