events

package
v0.0.0-...-b364e49 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-2-Clause-Patent Imports: 15 Imported by: 0

README

DAOS RAS Events

RAS events can be raised either in the control or engines. Each event will have at minimum an ID, Severity and Type as defined in ras.go. The canonical list of RAS Event IDs is maintained in src/include/daos_srv/ras.h.

Events raised in the engine will be written to the engine log file (configured in the engine section of the server config file with log_ prefixed parameters) and subsequently forwarded to the control server over dRPC.

Events raised in the control server or received over dRPC will be written to syslog at a relevant priority level.

A subset of events are actionable (type 'STATE_CHANGE' as opposed to 'INFO_ONLY') and will be forwarded to the management service (MS) leader. On receipt of an actionable event, the MS will update the membership and backing database based on the event's contents.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EngineStateInfoToProto

func EngineStateInfoToProto(rsi *EngineStateInfo) (*sharedpb.RASEvent_EngineStateInfo, error)

EngineStateInfoToProto converts event info from native to proto format.

func PoolSvcInfoToProto

func PoolSvcInfoToProto(psi *PoolSvcInfo) (*sharedpb.RASEvent_PoolSvcInfo, error)

PoolSvcInfoToProto converts event info from native to proto format.

func StrInfoToProto

func StrInfoToProto(si *StrInfo) (*sharedpb.RASEvent_StrInfo, error)

StrInfoToProto converts event info from native to proto format.

Types

type DebounceKeyFn

type DebounceKeyFn func(*RASEvent) string

DebounceKeyFn defines a function that returns a key to be used for determining if the event matches a previously-seen event.

type EngineStateInfo

type EngineStateInfo struct {
	InstanceIdx uint32 `json:"instance_idx"`
	ExitErr     error  `json:"-"`
}

EngineStateInfo describes details of a engine's state.

func EngineStateInfoFromProto

func EngineStateInfoFromProto(pbInfo *sharedpb.RASEvent_EngineStateInfo) (*EngineStateInfo, error)

EngineStateInfoFromProto converts event info from proto to native format.

type Handler

type Handler interface {
	// OnEvent takes an event to be processed and a context,
	// implementation must return on context.Done() and be thread safe.
	OnEvent(context.Context, *RASEvent)
}

Handler defines an interface to be implemented by event receivers.

type HandlerFunc

type HandlerFunc func(context.Context, *RASEvent)

HandlerFunc is an adapter to allow an ordinary function to be used as a Handler.

func (HandlerFunc) OnEvent

func (f HandlerFunc) OnEvent(ctx context.Context, evt *RASEvent)

OnEvent implements the Handler interface.

type PoolSvcInfo

type PoolSvcInfo struct {
	SvcReplicas    []uint32 `json:"svc_reps"`
	RaftLeaderTerm uint64   `json:"version"`
}

PoolSvcInfo describes details of a pool service.

func PoolSvcInfoFromProto

func PoolSvcInfoFromProto(pbInfo *sharedpb.RASEvent_PoolSvcInfo) (*PoolSvcInfo, error)

PoolSvcInfoFromProto converts event info from proto to native format.

type PubSub

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

PubSub stores subscriptions to event topics and handlers to be called on receipt of events pertaining to a particular topic.

func NewPubSub

func NewPubSub(parent context.Context, log logging.Logger) *PubSub

NewPubSub returns a reference to a newly initialized PubSub struct.

func (*PubSub) Close

func (ps *PubSub) Close()

Close terminates event loop by calling shutdown to cancel context.

func (*PubSub) Debounce

func (ps *PubSub) Debounce(id RASID, cooldown time.Duration, keyFn DebounceKeyFn)

Debounce accepts an event ID and a key function to be used to determine if an event matches a previously-seen event with that ID. This mechanism provides control over publication of duplicate events. The cooldown parameter determines the minimum amount of time required between publication of duplicate events. If cooldown is zero, then a given event may only be published at most once.

func (*PubSub) DisableEventIDs

func (ps *PubSub) DisableEventIDs(ids ...RASID)

DisableEventIDs adds event IDs to the filter preventing those event IDs from being published.

func (*PubSub) EnableEventIDs

func (ps *PubSub) EnableEventIDs(ids ...RASID)

EnableEventIDs removes event IDs from the filter enabling those event IDs to be published.

func (*PubSub) HandleClusterEvent

func (ps *PubSub) HandleClusterEvent(req *sharedpb.ClusterEventReq, forwarded bool) (*sharedpb.ClusterEventResp, error)

HandleClusterEvent extracts event field from protobuf request message and converts to native event type. The Event is then published to make available to locally subscribed consumers to act upon.

func (*PubSub) Publish

func (ps *PubSub) Publish(event *RASEvent)

Publish passes an event to the event channel to be processed by subscribers. Ignore disabled events.

func (*PubSub) Reset

func (ps *PubSub) Reset()

Reset clears registered handlers by sending reset.

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(topic RASTypeID, handler Handler)

Subscribe adds a handler to the list of handlers subscribed to a given topic (event type).

The special case "RASTypeAny" topic will handle all received events.

type Publisher

type Publisher interface {
	// Publish takes an event to be published.
	Publish(event *RASEvent)
}

Publisher defines an interface to be implemented by event publishers.

type RASEvent

type RASEvent struct {
	ID           RASID           `json:"id"`
	Timestamp    string          `json:"timestamp"`
	Type         RASTypeID       `json:"type"`
	Severity     RASSeverityID   `json:"severity"`
	Msg          string          `json:"msg"`
	Hostname     string          `json:"hostname"`
	Rank         uint32          `json:"rank"`
	Incarnation  uint64          `json:"incarnation"`
	HWID         string          `json:"hw_id"`
	ProcID       int             `json:"proc_id"`
	ThreadID     uint64          `json:"thread_id"`
	JobID        string          `json:"job_id"`
	PoolUUID     string          `json:"pool_uuid"`
	ContUUID     string          `json:"cont_uuid"`
	ObjID        string          `json:"obj_id"`
	CtlOp        string          `json:"ctl_op"`
	ExtendedInfo RASExtendedInfo `json:"extended_info"`
	// contains filtered or unexported fields
}

RASEvent describes details of a specific RAS event.

func NewEngineDiedEvent

func NewEngineDiedEvent(hostname string, instanceIdx uint32, rank uint32, exitErr common.ExitStatus, exPid int) *RASEvent

NewEngineDiedEvent creates a specific EngineDied event from given inputs.

func NewEngineFormatRequiredEvent

func NewEngineFormatRequiredEvent(hostname string, instanceIdx uint32, formatType string) *RASEvent

NewEngineFormatRequiredEvent creates a EngineFormatRequired event from given inputs.

func NewEngineJoinFailedEvent

func NewEngineJoinFailedEvent(hostname string, instanceIdx uint32, rank uint32, reason string) *RASEvent

NewEngineJoinFailedEvent creates an EngineJoinFailed event from the given inputs.

func NewFromProto

func NewFromProto(pbEvt *sharedpb.RASEvent) (*RASEvent, error)

NewFromProto creates an Event from given protobuf RASEvent message.

func NewGenericEvent

func NewGenericEvent(id RASID, sev RASSeverityID, msg, info string) *RASEvent

NewGenericEvent returns a generic RAS event with supplied ID.

func NewPoolSvcReplicasUpdateEvent

func NewPoolSvcReplicasUpdateEvent(hostname string, rank uint32, poolUUID string, svcReps []uint32, leaderTerm uint64) *RASEvent

NewPoolSvcReplicasUpdateEvent creates a specific PoolSvcRanksUpdate event from given inputs.

func (*RASEvent) FromProto

func (evt *RASEvent) FromProto(pbEvt *sharedpb.RASEvent) (err error)

FromProto initializes a native event from a provided protobuf event.

func (*RASEvent) GetEngineStateInfo

func (evt *RASEvent) GetEngineStateInfo() *EngineStateInfo

GetEngineStateInfo returns extended info if of type EngineStateInfo.

func (*RASEvent) GetPoolSvcInfo

func (evt *RASEvent) GetPoolSvcInfo() *PoolSvcInfo

GetPoolSvcInfo returns extended info if of type PoolSvcInfo.

func (*RASEvent) GetStrInfo

func (evt *RASEvent) GetStrInfo() *StrInfo

GetStrInfo returns extended info if of type StrInfo.

func (*RASEvent) GetTimestamp

func (evt *RASEvent) GetTimestamp() (time.Time, error)

GetTimestamp returns a time.Time parsed from the event timestamp.

func (*RASEvent) IsForwarded

func (evt *RASEvent) IsForwarded() bool

IsForwarded returns true if event has been forwarded between hosts.

func (*RASEvent) MarshalJSON

func (evt *RASEvent) MarshalJSON() ([]byte, error)

MarshalJSON marshals RASEvent to JSON.

func (*RASEvent) PrintRAS

func (evt *RASEvent) PrintRAS() string

PrintRAS generates a string representation of the event consistent with what is logged in the data plane.

func (*RASEvent) ShouldForward

func (evt *RASEvent) ShouldForward() bool

ShouldForward returns true if event is forwardable and has not already been forwarded.

func (*RASEvent) String

func (ev *RASEvent) String() string

func (*RASEvent) ToProto

func (evt *RASEvent) ToProto() (*sharedpb.RASEvent, error)

ToProto returns a protobuf representation of the native event.

func (*RASEvent) UnmarshalJSON

func (evt *RASEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals RASEvent from JSON.

func (*RASEvent) WithForwardable

func (evt *RASEvent) WithForwardable(forwardable bool) *RASEvent

WithForwardable sets the forwardable state of this event.

func (*RASEvent) WithForwarded

func (evt *RASEvent) WithForwarded(forwarded bool) *RASEvent

WithForwarded sets the forwarded state of this event.

func (*RASEvent) WithRank

func (evt *RASEvent) WithRank(rid uint32) *RASEvent

WithRank sets the rank identifier on the event.

type RASExtendedInfo

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

RASExtendedInfo provides extended information for an event.

type RASID

type RASID uint32

RASID identifies a given RAS event.

const (
	RASUnknownEvent            RASID = C.RAS_UNKNOWN_EVENT
	RASEngineFormatRequired    RASID = C.RAS_ENGINE_FORMAT_REQUIRED     // notice
	RASEngineDied              RASID = C.RAS_ENGINE_DIED                // error
	RASPoolRepsUpdate          RASID = C.RAS_POOL_REPS_UPDATE           // info
	RASSwimRankAlive           RASID = C.RAS_SWIM_RANK_ALIVE            // info
	RASSwimRankDead            RASID = C.RAS_SWIM_RANK_DEAD             // info
	RASSystemStartFailed       RASID = C.RAS_SYSTEM_START_FAILED        // error
	RASSystemStopFailed        RASID = C.RAS_SYSTEM_STOP_FAILED         // error
	RASEngineJoinFailed        RASID = C.RAS_ENGINE_JOIN_FAILED         // error
	RASSystemFabricProvChanged RASID = C.RAS_SYSTEM_FABRIC_PROV_CHANGED // info
)

RASID constant definitions matching those used when creating events either in the control or data (engine) planes.

func (RASID) String

func (id RASID) String() string

func (RASID) Uint32

func (id RASID) Uint32() uint32

Uint32 returns uint32 representation of event ID.

type RASSeverityID

type RASSeverityID uint32

RASSeverityID identifies the severity of a given RAS event.

const (
	RASSeverityUnknown RASSeverityID = C.RAS_SEV_UNKNOWN
	RASSeverityError   RASSeverityID = C.RAS_SEV_ERROR
	RASSeverityWarning RASSeverityID = C.RAS_SEV_WARNING
	RASSeverityNotice  RASSeverityID = C.RAS_SEV_NOTICE
)

RASSeverityID constant definitions.

func (RASSeverityID) String

func (sev RASSeverityID) String() string

func (RASSeverityID) SyslogPriority

func (sev RASSeverityID) SyslogPriority() syslog.Priority

SyslogPriority maps RAS severity to syslog package priority.

func (RASSeverityID) Uint32

func (sev RASSeverityID) Uint32() uint32

Uint32 returns uint32 representation of event severity.

type RASTypeID

type RASTypeID uint32

RASTypeID identifies the type of a given RAS event.

const (
	RASTypeAny         RASTypeID = C.RAS_TYPE_ANY
	RASTypeStateChange RASTypeID = C.RAS_TYPE_STATE_CHANGE
	RASTypeInfoOnly    RASTypeID = C.RAS_TYPE_INFO
)

RASTypeID constant definitions.

func (RASTypeID) String

func (typ RASTypeID) String() string

func (RASTypeID) Uint32

func (typ RASTypeID) Uint32() uint32

Uint32 returns uint32 representation of event type.

type StrInfo

type StrInfo string

StrInfo contains opaque blob of type string to hold custom details for a generic RAS event to be forwarded through the control-plane from the data-plane to an external consumer e.g. syslog.

func NewStrInfo

func NewStrInfo(in string) *StrInfo

NewStrInfo returns an initialized StrInfo reference.

func StrInfoFromProto

func StrInfoFromProto(pbInfo *sharedpb.RASEvent_StrInfo) (*StrInfo, error)

StrInfoFromProto converts event info from proto to native format.

Jump to

Keyboard shortcuts

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