node

package
v3.0.0-rc41 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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")
)
View Source
var (
	MonitorGlobalExpectStrings map[MonitorGlobalExpect]string
	MonitorGlobalExpectValues  map[string]MonitorGlobalExpect
)
View Source
var (
	MonitorLocalExpectStrings map[MonitorLocalExpect]string
	MonitorLocalExpectValues  map[string]MonitorLocalExpect
)
View Source
var (
	// MonitorStateStrings is a map that associates MonitorState enums with
	// their corresponding string representations.
	MonitorStateStrings map[MonitorState]string

	// MonitorStateValues maps string representations of various states to their
	// corresponding MonitorState constants.
	MonitorStateValues map[string]MonitorState

	// MonitorStatesFailure is the node monitor states an orchestration ends
	// on when it gave up rather than reached what it was for.
	MonitorStatesFailure = []MonitorState{
		MonitorStateDrainFailure,
		MonitorStateFreezeFailure,
		MonitorStateShutdownFailure,
		MonitorStateUnfreezeFailure,
	}

	// MonitorStateUnrankable is the node monitor states evicting a node from ranking algorithms
	MonitorStateUnrankable = map[MonitorState]any{
		MonitorStateInit:             nil,
		MonitorStateRejoin:           nil,
		MonitorStateMaintenance:      nil,
		MonitorStateUpgrade:          nil,
		MonitorStateShutdownSuccess:  nil,
		MonitorStateShutdownFailure:  nil,
		MonitorStateShutdownProgress: nil,
	}
)

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"`
	Weight int      `json:"weight"`
}

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

type Config

type Config struct {
	Collector              *collector.Config `json:"collector,omitempty"`
	Env                    string            `json:"env"`
	Hooks                  Hooks             `json:"hooks"`
	Labels                 label.M           `json:"labels"`
	MaintenanceGracePeriod time.Duration     `json:"maintenance_grace_period"`
	MaxParallel            int               `json:"max_parallel"`
	MaxKeySize             int64             `json:"max_key_size"`
	MinAvailMemPct         int               `json:"min_avail_mem_pct"`
	MinAvailSwapPct        int               `json:"min_avail_swap_pct"`
	ReadyPeriod            time.Duration     `json:"ready_period"`
	RejoinGracePeriod      time.Duration     `json:"rejoin_grace_period"`
	Schedules              []schedule.Config `json:"schedules"`
	SplitAction            string            `json:"split_action"`
	SSHKey                 string            `json:"sshkey"`
	PRKey                  string            `json:"prkey"`

	// Issues are the configuration faults found on this node that
	// a human has to correct, as the cluster configuration has its
	// own. They are found by the node they name, and travel with
	// its configuration so that a peer, om mon and the tui can
	// report them without repeating the search.
	Issues []string `json:"issues"`
}

func (*Config) DeepCopy

func (cfg *Config) DeepCopy() *Config

func (Config) Equal

func (c Config) Equal(other Config) bool

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]) GetAll

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

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

func (*Data[T]) GetByNode

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

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

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

func (*Gen) DeepCopy

func (t *Gen) DeepCopy() *Gen

type Hook

type Hook struct {
	Name    string   `json:"name"`
	Events  []string `json:"events"`
	Command []string `json:"command"`
}

func (*Hook) DeepCopy

func (t *Hook) DeepCopy() *Hook

func (*Hook) Diff

func (t *Hook) Diff(other Hook) string

func (*Hook) Equal

func (t *Hook) Equal(o *Hook) bool

type Hooks

type Hooks []Hook

func (Hooks) DeepCopy

func (t Hooks) DeepCopy() Hooks

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 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

type MonitorGlobalExpect

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

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 (
	// Initialization and Miscellaneous states
	MonitorStateInit MonitorState = iota
	MonitorStateIdle
	MonitorStateRejoin
	MonitorStateMaintenance
	MonitorStateUpgrade

	// Freezing process states
	MonitorStateFreezeProgress
	MonitorStateFreezeFailure
	MonitorStateFreezeSuccess

	// Unfreezing process states
	MonitorStateUnfreezeProgress
	MonitorStateUnfreezeFailure
	MonitorStateUnfreezeSuccess

	// Draining process states
	MonitorStateDrainProgress
	MonitorStateDrainFailure
	MonitorStateDrainSuccess

	// Shutdown process states
	MonitorStateShutdownProgress
	MonitorStateShutdownFailure
	MonitorStateShutdownSuccess
)

func (MonitorState) IsDoing

func (t MonitorState) IsDoing() bool

func (MonitorState) IsOneOf

func (t MonitorState) IsOneOf(states ...MonitorState) bool

IsOneOf says the state is one of those listed.

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"`
	Pool     map[string]pool.Status       `json:"pool"`
	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

DeepCopy returns a copy of the node dataset sharing nothing with it.

A nil Instance or Pool map is kept nil rather than made empty: neither field has omitempty, so the two do not serialize alike.

type Os

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

Os defines Os details

func (Os) DeepCopy

func (t Os) DeepCopy() Os

DeepCopy returns a copy of the os details sharing nothing with them.

A nil Paths is kept nil rather than made empty: the field has no omitempty, so the two do not serialize alike.

type Stats

type Stats struct {
	Load15M      float64 `json:"load_15m"`
	MemAvailPct  int     `json:"mem_avail"`
	MemTotalMB   uint64  `json:"mem_total"`
	Score        int     `json:"score"`
	SwapAvailPct int     `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          Gen                         `json:"gen"`
	IsLeader     bool                        `json:"is_leader"`
	IsOverloaded bool                        `json:"is_overloaded"`
	BootedAt     time.Time                   `json:"booted_at"`

	// LeftAt is the last time the nmon advanced the last_shutdown file,
	// i.e. the last time it proved it was alive and rejoined.
	LeftAt time.Time `json:"left_at"`

	// RejoinedAt is the time nmon state transitioned from rejoin to idle.
	// This happens either when the rejoin_grace_period expires or when
	// we received data from all peers.
	RejoinedAt time.Time `json:"rejoined_at"`
}

func (*Status) DeepCopy

func (t *Status) DeepCopy() *Status

func (Status) IsFrozen

func (t Status) IsFrozen() bool

func (Status) IsUnfrozen

func (t Status) IsUnfrozen() bool

Jump to

Keyboard shortcuts

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