types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayNodeSimplestForm

func DisplayNodeSimplestForm(ctx LogCtx, ip string) string

DisplayNodeSimplestForm is useful to get the most easily to read string for a given IP This only has impacts on display In order of preference: wsrep_node_name (or galera "node" name), hostname, ip

func Identifier added in v1.2.0

func Identifier(ctx LogCtx) string

Identifier is used to identify a node timeline. It will the column headers It will also impacts how logs are merged if we have multiple logs per nodes

In order of preference: wsrep_node_name (or galera "node" name), hostname, ip, filepath

Types

type Conflict added in v1.2.0

type Conflict struct {
	Seqno       string
	InitiatedBy []string
	Winner      string // winner will help the winning md5sum
	VotePerNode map[string]ConflictVote
}

type ConflictVote added in v1.2.0

type ConflictVote struct {
	MD5   string
	Error string
}

type Conflicts added in v1.2.0

type Conflicts []*Conflict

func (Conflicts) ConflictFromMD5 added in v1.2.0

func (cs Conflicts) ConflictFromMD5(md5 string) *Conflict

func (Conflicts) ConflictWithSeqno added in v1.2.0

func (cs Conflicts) ConflictWithSeqno(seqno string) *Conflict

func (Conflicts) Merge added in v1.2.0

func (cs Conflicts) Merge(c Conflict) Conflicts

func (Conflicts) OldestUnresolved added in v1.2.0

func (cs Conflicts) OldestUnresolved() *Conflict

type Date

type Date struct {
	Time        time.Time
	DisplayTime string
	Layout      string
}

func NewDate

func NewDate(t time.Time, layout string) Date

type LocalTimeline

type LocalTimeline []LogInfo

It should be kept already sorted by timestamp

func CutTimelineAt

func CutTimelineAt(t LocalTimeline, at time.Time) LocalTimeline

CutTimelineAt returns a localtimeline with the 1st event starting right after the time sent as parameter

func MergeTimeline

func MergeTimeline(t1, t2 LocalTimeline) LocalTimeline

MergeTimeline is helpful when log files are split by date, it can be useful to be able to merge content a "timeline" come from a log file. Log files that came from some node should not never have overlapping dates

func (LocalTimeline) Add added in v1.1.0

func (lt LocalTimeline) Add(li LogInfo) LocalTimeline

type LogCtx

type LogCtx struct {
	FilePath  string
	FileType  string
	OwnIPs    []string
	OwnHashes []string
	OwnNames  []string

	Version        string
	SST            SST
	MyIdx          string
	MemberCount    int
	Desynced       bool
	HashToIP       map[string]string
	HashToNodeName map[string]string
	IPToHostname   map[string]string
	IPToMethod     map[string]string
	IPToNodeName   map[string]string

	Conflicts Conflicts
	// contains filtered or unexported fields
}

LogCtx is a context for a given file. It is the principal storage of this tool Everything relevant will be stored here

func NewLogCtx

func NewLogCtx() LogCtx

func (*LogCtx) AddOwnHash

func (ctx *LogCtx) AddOwnHash(hash string)

AddOwnHash propagates a hash into the translation maps

func (*LogCtx) AddOwnIP

func (ctx *LogCtx) AddOwnIP(ip string)

AddOwnIP propagates a ip into the translation maps

func (*LogCtx) AddOwnName

func (ctx *LogCtx) AddOwnName(name string)

AddOwnName propagates a name into the translation maps using the trusted node's known own hashes and ips

func (*LogCtx) AllNodeNames

func (ctx *LogCtx) AllNodeNames() []string

func (*LogCtx) HasVisibleEvents added in v1.1.1

func (ctx *LogCtx) HasVisibleEvents(level Verbosity) bool

func (*LogCtx) HashesFromIP

func (ctx *LogCtx) HashesFromIP(ip string) []string

func (*LogCtx) HashesFromNodeName

func (ctx *LogCtx) HashesFromNodeName(nodename string) []string

func (*LogCtx) IPsFromNodeName

func (ctx *LogCtx) IPsFromNodeName(nodename string) []string

func (*LogCtx) Inherit added in v1.1.1

func (base *LogCtx) Inherit(ctx LogCtx)

Inherit will fill the local information from given context into the base It is used when merging, so that we do not start from nothing It helps when dealing with many small files

func (*LogCtx) IsPrimary added in v1.1.1

func (ctx *LogCtx) IsPrimary() bool

func (LogCtx) MarshalJSON added in v1.2.0

func (l LogCtx) MarshalJSON() ([]byte, error)

func (*LogCtx) MergeMapsWith

func (base *LogCtx) MergeMapsWith(ctxs []LogCtx)

MergeMapsWith will take a slice of contexts and merge every translation maps into the base context. It won't touch "local" infos such as "ownNames"

func (*LogCtx) OwnHostname

func (ctx *LogCtx) OwnHostname() string

func (*LogCtx) SetState added in v1.1.1

func (ctx *LogCtx) SetState(s string)

SetState will double-check if the STATE exists, and also store it on the correct status

func (LogCtx) State

func (ctx LogCtx) State() string

State will return the wsrep state of the current file type That is because for operator related logs, we have every type of files Not tracking and differenciating by file types led to confusions in most subcommands as it would seem that sometimes mysql is restarting after a crash, while actually the operator was simply launching a "wsrep-recover" instance while mysql was still running

type LogDisplayer

type LogDisplayer func(LogCtx) string

LogDisplayer is the handler to generate messages thanks to a context The context in parameters should be as updated as possible

func SimpleDisplayer

func SimpleDisplayer(s string) LogDisplayer

SimpleDisplayer satisfies LogDisplayer and ignores any context received

type LogInfo

type LogInfo struct {
	Date *Date

	Log             string // the raw log
	RegexType       RegexType
	RegexUsed       string
	Ctx             LogCtx // the context is copied for each logInfo, so that it is easier to handle some info (current state), and this is also interesting to check how it evolved
	Verbosity       Verbosity
	RepetitionCount int
	// contains filtered or unexported fields
}

LogInfo is to store a single event in log. This is something that should be displayed ultimately, this is what we want when we launch this tool

func NewLogInfo added in v1.1.0

func NewLogInfo(date *Date, displayer LogDisplayer, log string, regex *LogRegex, regexkey string, ctx LogCtx, filetype string) LogInfo

func (*LogInfo) IsDuplicatedEvent added in v1.1.0

func (current *LogInfo) IsDuplicatedEvent(base, previous LogInfo) bool

IsDuplicatedEvent will aim to keep 2 occurences of the same event To be considered duplicated, they must be from the same regexes and have the same message

func (*LogInfo) Msg

func (li *LogInfo) Msg(ctx LogCtx) string

type LogRegex

type LogRegex struct {
	Regex         *regexp.Regexp // to send to grep, should be as simple as possible but without collisions
	InternalRegex *regexp.Regexp // for internal usage in handler func
	Type          RegexType

	// Taking into arguments the current context and log line, returning an updated context and a closure to get the msg to display
	// Why a closure: to later inject an updated context instead of the current partial context
	// This ensure every hash/ip/nodenames are already known when crafting the message
	Handler   func(map[string]string, LogCtx, string) (LogCtx, LogDisplayer)
	Verbosity Verbosity // To be able to hide details from summaries
}

func (*LogRegex) Handle

func (l *LogRegex) Handle(ctx LogCtx, line string) (LogCtx, LogDisplayer)

func (*LogRegex) MarshalJSON added in v1.0.2

func (l *LogRegex) MarshalJSON() ([]byte, error)

type NodeInfo

type NodeInfo struct {
	Input     string   `json:"input"`
	IPs       []string `json:"IPs"`
	NodeNames []string `json:"nodeNames"`
	Hostname  string   `json:"hostname"`
	NodeUUIDs []string `json:"nodeUUIDs:"`
}

NodeInfo is mainly used by "whois" subcommand This is to display its result As it's the base work for "sed" subcommand, it's in types package

type RegexMap

type RegexMap map[string]*LogRegex

func (RegexMap) Compile

func (r RegexMap) Compile() []string

func (RegexMap) Merge

func (r RegexMap) Merge(r2 RegexMap) RegexMap

type RegexType

type RegexType string
var (
	EventsRegexType      RegexType = "events"
	SSTRegexType         RegexType = "sst"
	ViewsRegexType       RegexType = "views"
	IdentRegexType       RegexType = "identity"
	StatesRegexType      RegexType = "states"
	PXCOperatorRegexType RegexType = "pxc-operator"
	ApplicativeRegexType RegexType = "applicative"
)

type SST added in v1.1.0

type SST struct {
	Method           string
	Type             string
	ResyncingNode    string
	ResyncedFromNode string
}

func (*SST) Reset added in v1.1.0

func (s *SST) Reset()

type Timeline

type Timeline map[string]LocalTimeline

"string" key is a node IP

func (Timeline) Dequeue

func (t Timeline) Dequeue(node string)

func (*Timeline) GetLatestUpdatedContextsByNodes

func (t *Timeline) GetLatestUpdatedContextsByNodes() map[string]LogCtx

func (Timeline) IterateNode

func (t Timeline) IterateNode() []string

iterateNode is used to search the source node(s) that contains the next chronological events it returns a slice in case 2 nodes have their next event precisely at the same time, which happens a lot on some versions

type Verbosity

type Verbosity int
const (
	Info Verbosity = iota
	// Detailed is having every suspect/warn
	Detailed
	// DebugMySQL only includes finding that are usually not relevant to show but useful to create the log context (eg: how we found the local address)
	DebugMySQL
	Debug
)

Jump to

Keyboard shortcuts

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