node

package
v0.0.0-...-e053da5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MonitorStateStrings = map[MonitorState]string{
		MonitorStateDraining:       "draining",
		MonitorStateDrainFailed:    "drain failed",
		MonitorStateDrained:        "drained",
		MonitorStateIdle:           "idle",
		MonitorStateThawedFailed:   "unfreeze failed",
		MonitorStateFreezeFailed:   "freeze failed",
		MonitorStateFreezing:       "freezing",
		MonitorStateFrozen:         "frozen",
		MonitorStateThawing:        "thawing",
		MonitorStateShutdown:       "shutdown",
		MonitorStateShutdownFailed: "shutdown failed",
		MonitorStateShutting:       "shutting",
		MonitorStateMaintenance:    "maintenance",
		MonitorStateInit:           "init",
		MonitorStateUpgrade:        "upgrade",
		MonitorStateRejoin:         "rejoin",
	}

	MonitorStateValues = map[string]MonitorState{
		"drained":         MonitorStateDrained,
		"draining":        MonitorStateDraining,
		"drain failed":    MonitorStateDrainFailed,
		"idle":            MonitorStateIdle,
		"unfreeze failed": MonitorStateThawedFailed,
		"freeze failed":   MonitorStateFreezeFailed,
		"freezing":        MonitorStateFreezing,
		"frozen":          MonitorStateFrozen,
		"thawing":         MonitorStateThawing,
		"shutdown":        MonitorStateShutdown,
		"shutdown failed": MonitorStateShutdownFailed,
		"shutting":        MonitorStateShutting,
		"maintenance":     MonitorStateMaintenance,
		"init":            MonitorStateInit,
		"upgrade":         MonitorStateUpgrade,
		"rejoin":          MonitorStateRejoin,
	}

	MonitorLocalExpectStrings = map[MonitorLocalExpect]string{
		MonitorLocalExpectInit:    "init",
		MonitorLocalExpectDrained: "drained",
		MonitorLocalExpectNone:    "none",
	}

	MonitorLocalExpectValues = map[string]MonitorLocalExpect{
		"init":    MonitorLocalExpectInit,
		"drained": MonitorLocalExpectDrained,
		"none":    MonitorLocalExpectNone,
	}

	MonitorGlobalExpectStrings = map[MonitorGlobalExpect]string{
		MonitorGlobalExpectAborted: "aborted",
		MonitorGlobalExpectFrozen:  "frozen",
		MonitorGlobalExpectNone:    "none",
		MonitorGlobalExpectThawed:  "thawed",
		MonitorGlobalExpectInit:    "init",
	}

	MonitorGlobalExpectValues = map[string]MonitorGlobalExpect{
		"aborted": MonitorGlobalExpectAborted,
		"frozen":  MonitorGlobalExpectFrozen,
		"none":    MonitorGlobalExpectNone,
		"thawed":  MonitorGlobalExpectThawed,
		"init":    MonitorGlobalExpectInit,
	}

	// MonitorStateUnrankable is the node monitor states evicting a node from ranking algorithms
	MonitorStateUnrankable = map[MonitorState]any{
		MonitorStateMaintenance:    nil,
		MonitorStateUpgrade:        nil,
		MonitorStateInit:           nil,
		MonitorStateShutdown:       nil,
		MonitorStateShutdownFailed: nil,
		MonitorStateShutting:       nil,
		MonitorStateRejoin:         nil,
	}

	ErrInvalidGlobalExpect = errors.New("invalid node monitor global expect")
	ErrInvalidLocalExpect  = errors.New("invalid node monitor local expect")
	ErrInvalidState        = errors.New("invalid node monitor state")
	ErrSameGlobalExpect    = errors.New("node monitor global expect is already set to the same value")
	ErrSameLocalExpect     = errors.New("node monitor local expect is already set to the same value")
	ErrSameState           = errors.New("node monitor state is already set to the same value")
)

Functions

func DropNode

func DropNode(nodename string)

func InitData

func InitData()

InitData reset package node data, it can be used for tests.

Types

type ArbitratorStatus

type ArbitratorStatus struct {
	URL    string   `json:"url"`
	Status status.T `json:"status"`
}

ArbitratorStatus describes the internet name of an arbitrator and if it is join-able.

type Config

type Config struct {
	Env                    string        `json:"env"`
	MaintenanceGracePeriod time.Duration `json:"maintenance_grace_period"`
	MaxParallel            int           `json:"max_parallel"`
	ReadyPeriod            time.Duration `json:"ready_period"`
	RejoinGracePeriod      time.Duration `json:"rejoin_grace_period"`
	SplitAction            string        `json:"split_action"`
	SSHKey                 string        `json:"sshkey"`
}

func (*Config) DeepCopy

func (t *Config) DeepCopy() *Config

func (*Config) Unstructured

func (t *Config) Unstructured() map[string]any

type Data

type Data[T Dataer] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Data defines a shared holder for all nodes Dataer

var (
	// ConfigData is the package data holder for all nodes Configs
	ConfigData *Data[Config]

	// MonitorData is the package data holder for all nodes Monitors
	MonitorData *Data[Monitor]

	// OsPathsData is the package data holder for all nodes Os paths data
	OsPathsData *Data[san.Paths]

	// StatsData is the package data holder for all nodes stats
	StatsData *Data[Stats]

	// StatusData is the package data holder for all nodes statuses
	StatusData *Data[Status]

	// GenData is the package data holder for all nodes statuses
	GenData *Data[Gen]
)

func NewData

func NewData[T Dataer]() *Data[T]

func (*Data[T]) Get

func (c *Data[T]) Get(nodename string) *T

Get return the stored value for nodename or nil if not found

func (*Data[T]) GetAll

func (c *Data[T]) GetAll() []DataElement[T]

GetAll returns all stored elements as list of DataElement[T]

func (*Data[T]) Set

func (c *Data[T]) Set(nodename string, v *T)

Set add or update v for nodename

func (*Data[T]) Unset

func (c *Data[T]) Unset(nodename string)

Unset existing stored value for nodename

type DataElement

type DataElement[T Dataer] struct {
	Node  string
	Value *T
}

type Dataer

type Dataer interface {
	Config | Monitor | san.Paths | Stats | Status | Gen
}

type Gen

type Gen = map[string]uint64

type Instances

type Instances struct {
	Config  map[string]instance.Config  `json:"config"`
	Status  map[string]instance.Status  `json:"status"`
	Monitor map[string]instance.Monitor `json:"monitor"`
}

Instances groups instances configuration digest and status

type Labels

type Labels map[string]string

Labels holds the key/value pairs defined in the labels section of the node.conf

func (Labels) DeepCopy

func (t Labels) DeepCopy() Labels

type Monitor

type Monitor struct {
	GlobalExpect MonitorGlobalExpect `json:"global_expect"`
	LocalExpect  MonitorLocalExpect  `json:"local_expect"`
	State        MonitorState        `json:"state"`

	GlobalExpectUpdatedAt time.Time `json:"global_expect_updated_at"`
	LocalExpectUpdatedAt  time.Time `json:"local_expect_updated_at"`
	StateUpdatedAt        time.Time `json:"state_updated_at"`
	UpdatedAt             time.Time `json:"updated_at"`

	OrchestrationID     uuid.UUID `json:"orchestration_id"`
	OrchestrationIsDone bool      `json:"orchestration_is_done"`
	SessionID           uuid.UUID `json:"session_id"`

	IsPreserved bool `json:"preserved"`
}

Monitor describes the in-daemon states of a node

func (*Monitor) DeepCopy

func (n *Monitor) DeepCopy() *Monitor

func (*Monitor) Unstructured

func (t *Monitor) Unstructured() map[string]any

type MonitorGlobalExpect

type MonitorGlobalExpect int
const (
	MonitorGlobalExpectInit MonitorGlobalExpect = iota
	MonitorGlobalExpectAborted
	MonitorGlobalExpectFrozen
	MonitorGlobalExpectNone
	MonitorGlobalExpectThawed
)

func (MonitorGlobalExpect) MarshalText

func (t MonitorGlobalExpect) MarshalText() ([]byte, error)

func (MonitorGlobalExpect) String

func (t MonitorGlobalExpect) String() string

func (*MonitorGlobalExpect) UnmarshalText

func (t *MonitorGlobalExpect) UnmarshalText(b []byte) error

type MonitorLocalExpect

type MonitorLocalExpect int
const (
	MonitorLocalExpectInit MonitorLocalExpect = iota
	MonitorLocalExpectDrained
	MonitorLocalExpectNone
)

func (MonitorLocalExpect) MarshalText

func (t MonitorLocalExpect) MarshalText() ([]byte, error)

func (MonitorLocalExpect) String

func (t MonitorLocalExpect) String() string

func (*MonitorLocalExpect) UnmarshalText

func (t *MonitorLocalExpect) UnmarshalText(b []byte) error

type MonitorState

type MonitorState int
const (
	MonitorStateInit MonitorState = iota
	MonitorStateIdle
	MonitorStateDraining
	MonitorStateDrainFailed
	MonitorStateDrained
	MonitorStateThawedFailed
	MonitorStateFreezeFailed
	MonitorStateFreezing
	MonitorStateFrozen
	MonitorStateThawing

	// MonitorStateShutdown is the node monitor state on successfully shutdown
	MonitorStateShutdown

	// MonitorStateShutdownFailed is the node monitor state on failed shutdown
	MonitorStateShutdownFailed

	// MonitorStateShutting is the node monitor state during a shutdown in progress
	MonitorStateShutting

	MonitorStateMaintenance
	MonitorStateUpgrade
	MonitorStateRejoin
)

func (MonitorState) IsDoing

func (t MonitorState) IsDoing() bool

func (MonitorState) IsRankable

func (t MonitorState) IsRankable() bool

func (MonitorState) MarshalText

func (t MonitorState) MarshalText() ([]byte, error)

func (MonitorState) String

func (t MonitorState) String() string

func (*MonitorState) UnmarshalText

func (t *MonitorState) UnmarshalText(b []byte) error

type MonitorUpdate

type MonitorUpdate struct {
	State        *MonitorState        `json:"state"`
	LocalExpect  *MonitorLocalExpect  `json:"local_expect"`
	GlobalExpect *MonitorGlobalExpect `json:"global_expect"`

	// CandidateOrchestrationID is a candidate orchestration id for a new imon orchestration.
	CandidateOrchestrationID uuid.UUID `json:"orchestration_id"`
}

MonitorUpdate is embedded in the SetNodeMonitor message to change some Monitor values. A nil value does not change the current value.

func (MonitorUpdate) String

func (t MonitorUpdate) String() string

type Node

type Node struct {
	Instance map[string]instance.Instance `json:"instance"`
	Monitor  Monitor                      `json:"monitor"`
	Stats    Stats                        `json:"stats"`
	Status   Status                       `json:"status"`
	Os       Os                           `json:"os"`
	Config   Config                       `json:"config"`

	Daemon daemonsubsystem.Daemon `json:"daemon"`
}

Node holds a node DataSet.

func (*Node) DeepCopy

func (n *Node) DeepCopy() *Node

type NodeInfo

type NodeInfo struct {
	Env    string    `json:"env"`
	Labels Labels    `json:"labels"`
	Paths  san.Paths `json:"paths"`

	Lsnr daemonsubsystem.Listener `json:"listener"`
}

type NodesInfo

type NodesInfo map[string]NodeInfo

NodesInfo is the dataset exposed via the GET /nodes_info handler, used by nodes to: * expand node selector expressions based on labels * setup clusterwide lun mapping from pools backed by san arrays

func (NodesInfo) GetNodesWithAnyPaths

func (t NodesInfo) GetNodesWithAnyPaths(paths san.Paths) []string

GetNodesWithAnyPaths return the list of nodes having any of the given paths.

func (NodesInfo) Keys

func (t NodesInfo) Keys() []string

type Os

type Os struct {
	Paths san.Paths `json:"paths"`
}

Os defines Os details

type Stats

type Stats struct {
	Load15M      float64 `json:"load_15m"`
	MemAvailPct  uint64  `json:"mem_avail"`
	MemTotalMB   uint64  `json:"mem_total"`
	Score        uint64  `json:"score"`
	SwapAvailPct uint64  `json:"swap_avail"`
	SwapTotalMB  uint64  `json:"swap_total"`
}

Stats describes systems (cpu, mem, swap) resource usage of a node and an opensvc-specific score.

func (*Stats) DeepCopy

func (n *Stats) DeepCopy() *Stats

type Status

type Status struct {
	Agent           string                      `json:"agent"`
	API             uint64                      `json:"api"`
	Arbitrators     map[string]ArbitratorStatus `json:"arbitrators"`
	Compat          uint64                      `json:"compat"`
	FrozenAt        time.Time                   `json:"frozen_at"`
	Gen             map[string]uint64           `json:"gen"`
	MinAvailMemPct  uint64                      `json:"min_avail_mem"`
	MinAvailSwapPct uint64                      `json:"min_avail_swap"`
	IsLeader        bool                        `json:"is_leader"`
	Labels          Labels                      `json:"labels"`
}

func (*Status) DeepCopy

func (t *Status) DeepCopy() *Status

func (Status) IsFrozen

func (t Status) IsFrozen() bool

func (Status) IsThawed

func (t Status) IsThawed() bool

func (*Status) Unstructured

func (t *Status) Unstructured() map[string]any

Jump to

Keyboard shortcuts

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