pulseha

package
v1.1.24 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	PluginHealthCheck pluginType = 1 + iota
	PluginNetworking
	PluginGeneral
)

Variables

View Source
var (
	CLUSTER_REQUIRED_MESSAGE = "You must be in a configured cluster to complete this action."
)

Functions

func BringDownIPs added in v1.1.22

func BringDownIPs(iface string, ips []string) error

* Bring down an []ips for a specific interface

func BringUpIPs added in v1.1.22

func BringUpIPs(iface string, ips []string) error

* Bring up an []ips for a specific interface

func CanCommunicate added in v1.1.22

func CanCommunicate(ctx context.Context) bool

* Determine if a connection is coming in is a member of our config

func GetFailOverCountWinner added in v1.1.22

func GetFailOverCountWinner(members []*rpc.MemberlistMember) string

* Determine who is the correct active node if more than one active is brought online TODO: Note: THIS ONLY WORKS WITH TWO NODES ATM

func InformMLSChange added in v1.1.22

func InformMLSChange()

* Inform our plugins that our member list state has changed

func MakeLocalActive added in v1.1.22

func MakeLocalActive()

* Networking - Bring up the groups on the current node

func MakeLocalPassive added in v1.1.22

func MakeLocalPassive()

* Networking - Bring down the ip groups on the current node

func MyCaller added in v1.1.22

func MyCaller() string

*

Types

type CLIServer added in v1.1.22

type CLIServer struct {
	sync.Mutex
	Server   *Server
	Listener net.Listener
}

* Server struct type

func (*CLIServer) Config added in v1.1.22

func (s *CLIServer) Config(ctx context.Context, in *rpc.PulseConfig) (*rpc.PulseConfig, error)

Config - Update any key's value in the pulsectl section of the config

func (*CLIServer) Create added in v1.1.22

func (s *CLIServer) Create(ctx context.Context, in *rpc.PulseCreate) (*rpc.PulseCreate, error)

* Create new PulseHA cluster

func (*CLIServer) DeleteGroup added in v1.1.22

func (s *CLIServer) DeleteGroup(ctx context.Context, in *rpc.PulseGroupDelete) (*rpc.PulseGroupDelete, error)

* Delete floating IP group

func (*CLIServer) Describe added in v1.1.22

func (s *CLIServer) Describe(ctx context.Context, in *rpc.PulseDescribe) (*rpc.PulseDescribe, error)

func (*CLIServer) GroupAssign added in v1.1.22

func (s *CLIServer) GroupAssign(ctx context.Context, in *rpc.PulseGroupAssign) (*rpc.PulseGroupAssign, error)

* Assign group to interface

func (*CLIServer) GroupIPAdd added in v1.1.22

func (s *CLIServer) GroupIPAdd(ctx context.Context, in *rpc.PulseGroupAdd) (*rpc.PulseGroupAdd, error)

* Add IP to group

func (*CLIServer) GroupIPRemove added in v1.1.22

func (s *CLIServer) GroupIPRemove(ctx context.Context, in *rpc.PulseGroupRemove) (*rpc.PulseGroupRemove, error)

* Remove IP from group

func (*CLIServer) GroupList added in v1.1.22

func (s *CLIServer) GroupList(ctx context.Context, in *rpc.GroupTable) (*rpc.GroupTable, error)

* Show all groups

func (*CLIServer) GroupUnassign added in v1.1.22

func (s *CLIServer) GroupUnassign(ctx context.Context, in *rpc.PulseGroupUnassign) (*rpc.PulseGroupUnassign, error)

* Unassign group from interface

func (*CLIServer) Join added in v1.1.22

func (s *CLIServer) Join(ctx context.Context, in *rpc.PulseJoin) (*rpc.PulseJoin, error)

* Attempt to join a configured cluster Notes: We create a new client in attempt to communicate with our peer.

If successful we acknowledge it and update our memberlist.

func (*CLIServer) Leave added in v1.1.22

func (s *CLIServer) Leave(ctx context.Context, in *rpc.PulseLeave) (*rpc.PulseLeave, error)

* Break cluster / Leave from cluster TODO: Remember to reassign active role on leave

func (*CLIServer) Network added in v1.1.22

func (s *CLIServer) Network(ctx context.Context, in *rpc.PulseNetwork) (*rpc.PulseNetwork, error)

Network -

func (*CLIServer) NewGroup added in v1.1.22

func (s *CLIServer) NewGroup(ctx context.Context, in *rpc.PulseGroupNew) (*rpc.PulseGroupNew, error)

* Add a new floating IP group

func (*CLIServer) Promote added in v1.1.22

func (s *CLIServer) Promote(ctx context.Context, in *rpc.PulsePromote) (*rpc.PulsePromote, error)

* Handle CLI promote request

func (*CLIServer) Remove added in v1.1.22

func (s *CLIServer) Remove(ctx context.Context, in *rpc.PulseRemove) (*rpc.PulseRemove, error)

Remove - Remove node from cluster by hostname

func (*CLIServer) Setup added in v1.1.22

func (s *CLIServer) Setup()

* Setup pulse cli type

func (*CLIServer) Status added in v1.1.22

func (s *CLIServer) Status(ctx context.Context, in *rpc.PulseStatus) (*rpc.PulseStatus, error)

* Return the status for each node within the cluster

func (*CLIServer) TLS added in v1.1.22

func (s *CLIServer) TLS(ctx context.Context, in *rpc.PulseCert) (*rpc.PulseCert, error)

* Handle CLI promote request

func (*CLIServer) Token added in v1.1.22

func (s *CLIServer) Token(ctx context.Context, in *rpc.PulseToken) (*rpc.PulseToken, error)

Token - Generate a new cluster token

type Database added in v1.1.22

type Database struct {
	Config        *config.Config
	Plugins       *Plugins
	MemberList    *MemberList
	Logging       logging.Logging
	StartDelay    bool
	StartInterval int
}
var (
	DB *Database
)

func (*Database) SetConfig added in v1.1.22

func (d *Database) SetConfig(config *config.Config)

type Member added in v1.1.22

type Member struct {
	// The hostname of the repented node
	Hostname string
	// The status of the local member
	Status rpc.MemberStatus_Status
	// The last time a health check was received
	LastHCResponse time.Time
	// The latency between the active and the current passive member
	Latency string
	// Determines if the health check is being made.
	HCBusy bool
	// The client for the member that is used to send GRPC calls
	*client.Client
	// The mutex to lock the member object
	sync.Mutex
}

* Member struct type

func (*Member) BringUpIPs added in v1.1.22

func (m *Member) BringUpIPs(ips []string, group string) bool

* Used to bring up a single IP on member Note: We need to know the group to work out what interface to bring it up on. TODO: Return an error instead of a boolean

func (*Member) Close added in v1.1.22

func (m *Member) Close()

* Close the client connection

func (*Member) Connect added in v1.1.22

func (m *Member) Connect() error

* Note: Hostname is required for TLS as the certs are named after the hostname.

func (*Member) GetHCBusy added in v1.1.22

func (m *Member) GetHCBusy() bool

*

func (*Member) GetHostname added in v1.1.22

func (m *Member) GetHostname() string

* Get member hostname

func (*Member) GetLastHCResponse added in v1.1.22

func (m *Member) GetLastHCResponse() time.Time

* Get the last time this member received a health check

func (*Member) GetLatency added in v1.1.22

func (m *Member) GetLatency() string

*

func (*Member) GetStatus added in v1.1.22

func (m *Member) GetStatus() rpc.MemberStatus_Status

* Get member status

func (*Member) Lock added in v1.1.22

func (m *Member) Lock()

*

func (*Member) MakeActive added in v1.1.22

func (m *Member) MakeActive() bool

Make the node active (bring up its groups)

func (*Member) MakePassive added in v1.1.22

func (m *Member) MakePassive() error

* Make the node passive (take down its groups)

func (*Member) MonitorReceivedHCs added in v1.1.22

func (m *Member) MonitorReceivedHCs() bool

* Monitor the last time we received a health check and or failover

func (*Member) RoutineHC added in v1.1.22

func (m *Member) RoutineHC(data *rpc.PulseHealthCheck)

* Send health check via a go routine and mark the HC busy/not

func (*Member) SendHealthCheck added in v1.1.22

func (m *Member) SendHealthCheck(data *rpc.PulseHealthCheck) (interface{}, error)

* Active function - Send GRPC health check to current member

func (*Member) SetClient added in v1.1.22

func (m *Member) SetClient(client *client.Client)

* Set member Client GRPC

func (*Member) SetHCBusy added in v1.1.22

func (m *Member) SetHCBusy(busy bool)

*

func (*Member) SetHostname added in v1.1.22

func (m *Member) SetHostname(hostname string)

* Set member hostname

func (*Member) SetLastHCResponse added in v1.1.22

func (m *Member) SetLastHCResponse(time time.Time)

*

Set the last time this member received a health check

func (*Member) SetLatency added in v1.1.22

func (m *Member) SetLatency(latency string)

*

func (*Member) SetStatus added in v1.1.22

func (m *Member) SetStatus(status rpc.MemberStatus_Status)

* Set member status

func (*Member) Unlock added in v1.1.22

func (m *Member) Unlock()

*

type MemberList added in v1.1.22

type MemberList struct {
	Members  []*Member
	StopChan chan bool
	sync.Mutex
}

*

  • MemberList struct type

func (*MemberList) AddHealthCheckHandler added in v1.1.22

func (m *MemberList) AddHealthCheckHandler() bool

* Send health checks to users who have a healthy connection

func (*MemberList) AddMember added in v1.1.22

func (m *MemberList) AddMember(hostname string, client *client.Client)

*

  • Add a member to the client list

func (*MemberList) Broadcast added in v1.1.22

func (m *MemberList) Broadcast(funcName client.ProtoFunction, data interface{})

*

  • Attempt to broadcast a client function to other nodes (clients) within the memberlist

func (*MemberList) GetActiveMember added in v1.1.22

func (m *MemberList) GetActiveMember() (string, *Member)

Return the hostname of the active member or empty string if non are active

func (*MemberList) GetLocalMember added in v1.1.22

func (m *MemberList) GetLocalMember() (*Member, error)

*

Get the local member node

func (*MemberList) GetMemberByHostname added in v1.1.22

func (m *MemberList) GetMemberByHostname(hostname string) *Member

*

  • Return Member by hostname

func (*MemberList) GetNextActiveMember added in v1.1.22

func (m *MemberList) GetNextActiveMember() (*Member, error)

* Calculate who's next to become active in the memberlist

func (*MemberList) LoadMembers added in v1.1.22

func (m *MemberList) LoadMembers()

* load the nodes in our config into our memberlist

func (*MemberList) Lock added in v1.1.22

func (m *MemberList) Lock()

*

func (*MemberList) MemberExists added in v1.1.22

func (m *MemberList) MemberExists(hostname string) bool

*

  • Return true/false whether a member exists or not.

func (*MemberList) MemberGetStatus added in v1.1.22

func (m *MemberList) MemberGetStatus(hostname string) (rpc.MemberStatus_Status, error)

* Get status of a specific member by hostname

func (*MemberList) MemberRemoveByHostname added in v1.1.22

func (m *MemberList) MemberRemoveByHostname(hostname string)

*

  • Remove a member from the client list by hostname

func (*MemberList) MonitorClientConns added in v1.1.22

func (m *MemberList) MonitorClientConns() bool

*

	Function is only to be run on the active appliance
	Note: THis is not the final function name.. or not sure if this is
          where this logic will stay.. just playing around at this point.
	monitors the connections states for each member

func (*MemberList) PromoteMember added in v1.1.22

func (m *MemberList) PromoteMember(hostname string) error

* Promote a member within the memberlist to become the active node

func (*MemberList) Reload added in v1.1.22

func (m *MemberList) Reload()

* Reload the memberlist

func (*MemberList) Reset added in v1.1.22

func (m *MemberList) Reset()

* Reset the memberlist when we are no longer in a cluster.

func (*MemberList) Setup added in v1.1.22

func (m *MemberList) Setup()

* Setup process for the memberlist

func (*MemberList) SyncConfig added in v1.1.22

func (m *MemberList) SyncConfig() error

* Sync local config with each member in the cluster.

func (*MemberList) Unlock added in v1.1.22

func (m *MemberList) Unlock()

*

func (*MemberList) Update added in v1.1.22

func (m *MemberList) Update(memberlist []*rpc.MemberlistMember)

* Update the local memberlist statuses based on the proto memberlist message

type Plugin added in v1.1.22

type Plugin struct {
	Name    string
	Version float64
	Type    interface{}
	Plugin  interface{}
}

* Struct for a specific plugin

type PluginGen added in v1.1.22

type PluginGen interface {
	Name() string
	Version() float64
	Run(db *Database) error
	OnMemberListStatusChange(members []Member)
}

type PluginHC added in v1.1.22

type PluginHC interface {
	Name() string
	Version() float64
	Send() (bool, bool)
}

* Health Check plugin type

type PluginNet added in v1.1.22

type PluginNet interface {
	Name() string
	Version() float64
	BringUpIPs(iface string, ips []string) error
	BringDownIPs(iface string, ips []string) error
}

* Networking plugin type

type Plugins added in v1.1.22

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

* Plugins struct

func (*Plugins) GetGeneralPlugin added in v1.1.22

func (p *Plugins) GetGeneralPlugin() []*Plugin

* Returns a slice of general plugins

func (*Plugins) GetHealthCheckPlugins added in v1.1.22

func (p *Plugins) GetHealthCheckPlugins() []*Plugin

* Returns a slice of health check plugins

func (*Plugins) GetNetworkingPlugin added in v1.1.22

func (p *Plugins) GetNetworkingPlugin() *Plugin

* Returns a single networking plugin (as you should only ever have one loaded)

func (*Plugins) Load added in v1.1.22

func (p *Plugins) Load(pluginType pluginType, pluginList []*plugin.Plugin)

* Load plugins of a specific type TODO: This needs to be cleaned up so code can be reused instead of repeated so much

func (*Plugins) Setup added in v1.1.22

func (p *Plugins) Setup()

* Define each type of plugin to load

func (*Plugins) Validate added in v1.1.22

func (p *Plugins) Validate()

* Validate that we have the required plugins

type Server added in v1.1.22

type Server struct {
	sync.Mutex
	Server      *grpc.Server
	Listener    net.Listener
	HCScheduler func()
}

*

  • Server struct type

func (*Server) BringDownIP added in v1.1.22

func (s *Server) BringDownIP(ctx context.Context, in *rpc.PulseBringIP) (*rpc.PulseBringIP, error)

*

func (*Server) BringUpIP added in v1.1.22

func (s *Server) BringUpIP(ctx context.Context, in *rpc.PulseBringIP) (*rpc.PulseBringIP, error)

*

func (*Server) ConfigSync added in v1.1.22

func (s *Server) ConfigSync(ctx context.Context, in *rpc.PulseConfigSync) (*rpc.PulseConfigSync, error)

* Update our local config from a Resync request

func (*Server) Describe added in v1.1.22

func (s *Server) Describe(ctx context.Context, in *rpc.PulseDescribe) (*rpc.PulseDescribe, error)

func (*Server) HealthCheck added in v1.1.22

func (s *Server) HealthCheck(ctx context.Context, in *rpc.PulseHealthCheck) (*rpc.PulseHealthCheck, error)

* Perform appr. health checks

func (*Server) Init added in v1.1.22

func (s *Server) Init(db *Database)

func (*Server) Join added in v1.1.22

func (s *Server) Join(ctx context.Context, in *rpc.PulseJoin) (*rpc.PulseJoin, error)

* Join request for a configured cluster

func (*Server) Leave added in v1.1.22

func (s *Server) Leave(ctx context.Context, in *rpc.PulseLeave) (*rpc.PulseLeave, error)

* Update our local config from a Resync request

func (*Server) Logs added in v1.1.22

func (s *Server) Logs(ctx context.Context, in *rpc.PulseLogs) (*rpc.PulseLogs, error)

Logs Listens for new log entries and displays them in journal

func (*Server) MakePassive added in v1.1.22

func (s *Server) MakePassive(ctx context.Context, in *rpc.PulsePromote) (*rpc.PulsePromote, error)

* Make a member passive

func (*Server) Promote added in v1.1.22

func (s *Server) Promote(ctx context.Context, in *rpc.PulsePromote) (*rpc.PulsePromote, error)

* Network action functions

func (*Server) Remove added in v1.1.22

func (s *Server) Remove(ctx context.Context, in *rpc.PulseRemove) (*rpc.PulseRemove, error)

Remove - Remove node from cluster by hostname

func (*Server) Setup added in v1.1.22

func (s *Server) Setup()

*

  • Setup pulse server type

func (*Server) Shutdown added in v1.1.22

func (s *Server) Shutdown()

*

  • Shutdown pulse server (not cli/cmd)

Jump to

Keyboard shortcuts

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