Documentation ¶
Overview ¶
The actions package contains the code for interacting directly with Redis instances and taking actions against them. This includes higher level actions which apply to componets and to lower level actions which are taken against components directly.
Index ¶
- Constants
- Variables
- func GetAddressPair(astring string) (host string, port int, err error)
- func NewMasterFromMasterInfo(mi structures.MasterInfo, authtoken string) (rp common.RedisPod, err error)
- func NewPod(name, address string, port int, auth string) (rp common.RedisPod, err error)
- type By
- type Constellation
- func (c *Constellation) AddSentinel(ip string, port int) error
- func (c *Constellation) AddSentinelByAddress(address string) error
- func (c *Constellation) Balance()
- func (c *Constellation) BalancePod(pod *common.RedisPod)
- func (c *Constellation) ErrorPodCount() (count int)
- func (c *Constellation) Failover(podname string) (ok bool, err error)
- func (c *Constellation) GetAllSentinels() (sentinels []*Sentinel, err error)
- func (c *Constellation) GetAllSentinelsQuietly() (sentinels []*Sentinel)
- func (c *Constellation) GetAnySentinel() (sentinel Sentinel, err error)
- func (c *Constellation) GetAuthForPodFromConfig(podname string) string
- func (c *Constellation) GetAvailableSentinels(podname string, needed int) (sentinels []*Sentinel, err error)
- func (c *Constellation) GetMaster(podname string) (master structures.MasterAddress, err error)
- func (c *Constellation) GetNode(name, podname, auth string) (node *common.RedisNode, err error)
- func (c *Constellation) GetPod(podname string) (pod *common.RedisPod, err error)
- func (c *Constellation) GetPodAuth(podname string) string
- func (c *Constellation) GetPodMap() (pods map[string]*common.RedisPod, err error)
- func (c *Constellation) GetPods() (pods []*common.RedisPod)
- func (c *Constellation) GetPodsInError() (errors []*common.RedisPod)
- func (c *Constellation) GetSentinelsForPod(podname string) (sentinels []*Sentinel)
- func (c *Constellation) GetSlaves(podname string) (slaves []structures.SlaveInfo, err error)
- func (c *Constellation) GetStats() ConstellationStats
- func (c *Constellation) HasPodsInErrorState() bool
- func (c *Constellation) IsBalanced() (isbal bool)
- func (c *Constellation) LoadLocalPods() error
- func (c *Constellation) LoadNodesForPod(pod *common.RedisPod, sentinel *Sentinel)
- func (c *Constellation) LoadRemotePods() error
- func (c *Constellation) LoadRemoteSentinels()
- func (c *Constellation) LoadSentinelConfigFile() error
- func (c *Constellation) MonitorPod(podname, address string, port, quorum int, auth string) (ok bool, err error)
- func (c *Constellation) PodCount() int
- func (c *Constellation) RemovePod(podname string) (bool, error)
- func (c *Constellation) ResetPod(podname string, simultaneous bool)
- func (c *Constellation) SentinelCount() int
- func (c *Constellation) SetPeers() error
- func (c *Constellation) StartCache()
- func (c *Constellation) ValidatePodSentinels(podname string) (map[string]bool, error)
- type ConstellationStats
- type LocalSentinelConfig
- type PodAuthCache
- type Sentinel
- func (s *Sentinel) DoFailover(podname string) (ok bool, err error)
- func (s *Sentinel) GetConnection() (conn *client.Redis, err error)
- func (s *Sentinel) GetMaster(podname string) (master structures.MasterAddress, err error)
- func (s *Sentinel) GetMasters() (master []structures.MasterInfo, err error)
- func (s *Sentinel) GetPod(podname string) (rp common.RedisPod, err error)
- func (s *Sentinel) GetPodAuthFromConfig(podname string) (string, error)
- func (s *Sentinel) GetPods() (pods map[string]common.RedisPod, err error)
- func (s *Sentinel) GetSentinels(podname string) (sentinels []*Sentinel, err error)
- func (s *Sentinel) GetSlaves(podname string) (slaves []structures.SlaveInfo, err error)
- func (s *Sentinel) LoadPods() error
- func (s *Sentinel) MonitorPod(podname, address string, port, quorum int, auth string) (rp common.RedisPod, err error)
- func (s *Sentinel) PodCount() int
- func (s *Sentinel) RemovePod(podname string) (ok bool, err error)
- func (s *Sentinel) ResetPod(podname string)
- type SentinelOverrides
- type SentinelPodConfig
Constants ¶
const GCPORT = "8008"
Variables ¶
var DialTimeout time.Duration = 900 * time.Millisecond
var NodeRefreshInterval float64
var NodesMap map[string]*common.RedisNode
Functions ¶
func GetAddressPair ¶
GetAddressPair is a convenience function for converting an ip and port into the ip:port string. Probably need to move this to the common package
func NewMasterFromMasterInfo ¶
func NewMasterFromMasterInfo(mi structures.MasterInfo, authtoken string) (rp common.RedisPod, err error)
NewMasterFromMasterInfo accepts a MasterInfo struct from libredis/client combined with an authentication token to use and returns a common.RedisPod instance.
func NewPod ¶
// common.RedisPod is the construct used for holding data about a Redis Pod and taking // action against it.
type common.RedisPod struct { Name string Info structures.MasterInfo Slaves []structures.InfoSlaves Master *RedisNode SentinelCount int ActiveSentinelCount int ReportedSentinelCount int AuthToken string ValidAuth bool ValidMasterConnection bool NeededSentinels int MissingSentinels bool TooManySentinels bool HasInfo bool NeedsReset bool HasValidSlaves bool }
NewPod will return a common.RedisPod construct. It requires the nae, address, port, and authentication token.
Types ¶
type Constellation ¶
type Constellation struct { Name string PodMap map[string]*common.RedisPod LocalPodMap map[string]*common.RedisPod RemotePodMap map[string]*common.RedisPod PodsInError []*common.RedisPod NumErrorPods int LastErrorCheck time.Time Connected bool RemoteSentinels map[string]*Sentinel BadSentinels map[string]*Sentinel LocalSentinel Sentinel SentinelConfigName string SentinelConfig LocalSentinelConfig PodToSentinelsMap map[string][]*Sentinel Balanced bool AuthCache *PodAuthCache Groupname string Peers *groupcache.HTTPPool PeerList map[string]string PodAuthMap map[string]string NodeMap map[string]*common.RedisNode NodeNameToPodMap map[string]string ConfiguredSentinels map[string]interface{} Metrics ConstellationStats LocalOverrides SentinelOverrides }
Constellation is a construct which holds information about the constellation as well providing an interface for taking actions against it.
func GetConstellation ¶
func GetConstellation(name, cfg, group, sentinelAddress string) (Constellation, error)
GetConstellation returns an instance of a constellation. It requires the configuration and a group name. The group name identifies the cluster the constellation, and hence this RedSkull instance, belongs to. In the future this will be used in clsuter coordination as well as for a protective measure against cluster merge
func (*Constellation) AddSentinel ¶
func (c *Constellation) AddSentinel(ip string, port int) error
AddSentinel adds a sentinel to the constellation
func (*Constellation) AddSentinelByAddress ¶
func (c *Constellation) AddSentinelByAddress(address string) error
AddSentinelByAddress is a convenience function to add a sentinel by it's ip:port string
func (*Constellation) Balance ¶
func (c *Constellation) Balance()
Balance will attempt to balance the constellation A constellation is unbalanced if any pod is not listed as managed by enough sentinels to achieve quorum+1 It will first verify the current balance state to avoid unnecessary balance attempts. This will likely be deprecated
func (*Constellation) BalancePod ¶
func (c *Constellation) BalancePod(pod *common.RedisPod)
BalancePod is used to rebalance a pod. This means pulling a lis tof available sentinels, determining how many are "missing" and adding the pod to the appropriate number of sentinels to bring it up to spec
func (*Constellation) ErrorPodCount ¶
func (c *Constellation) ErrorPodCount() (count int)
ErrorPodCount returns the number of pods currently reporting errors
func (*Constellation) Failover ¶
func (c *Constellation) Failover(podname string) (ok bool, err error)
Initiates a failover on a given pod.
func (*Constellation) GetAllSentinels ¶
func (c *Constellation) GetAllSentinels() (sentinels []*Sentinel, err error)
GetAllSentinels returns all known sentinels
func (*Constellation) GetAllSentinelsQuietly ¶
func (c *Constellation) GetAllSentinelsQuietly() (sentinels []*Sentinel)
GetAllSentinelsQuietly is a convenience function used primarily in the UI.
func (*Constellation) GetAnySentinel ¶
func (c *Constellation) GetAnySentinel() (sentinel Sentinel, err error)
GetAnySentinel is deprecated and calls to it need to be found and refactored so it can die.
func (*Constellation) GetAuthForPodFromConfig ¶
func (c *Constellation) GetAuthForPodFromConfig(podname string) string
GetAuthForPodFromConfig looks in the local sentinel config file to find an authentication token for the given pod.
func (*Constellation) GetAvailableSentinels ¶
func (c *Constellation) GetAvailableSentinels(podname string, needed int) (sentinels []*Sentinel, err error)
GetAvailableSentinels returns a list of sentinels the give pod is *not* already monitored by. It will return the least-used of the available sentinels in an effort to level sentinel use.
func (*Constellation) GetMaster ¶
func (c *Constellation) GetMaster(podname string) (master structures.MasterAddress, err error)
Getmaster returns the current structures.MasterAddress struct for the given pod
func (*Constellation) GetNode ¶
func (c *Constellation) GetNode(name, podname, auth string) (node *common.RedisNode, err error)
GetNode will retun an instance of a common.RedisNode. It also attempts to determine dynamic data such as sentinels and booleans like CanFailover
func (*Constellation) GetPod ¶
func (c *Constellation) GetPod(podname string) (pod *common.RedisPod, err error)
GetPod returns a *common.RedisPod instance for the given podname
func (*Constellation) GetPodAuth ¶
func (c *Constellation) GetPodAuth(podname string) string
GetPodAuth will return an authstring from the local config and/or the groupcache group if it is in there. This probably still needs a bit of work to be reliable enough for me.
func (*Constellation) GetPodMap ¶
func (c *Constellation) GetPodMap() (pods map[string]*common.RedisPod, err error)
GetPodMap returs the current pod mapping. This combines local and remote sentinels to get all known pods in the cluster
func (*Constellation) GetPods ¶
func (c *Constellation) GetPods() (pods []*common.RedisPod)
GetPods returns the list of known pods
func (*Constellation) GetPodsInError ¶
func (c *Constellation) GetPodsInError() (errors []*common.RedisPod)
GetPodsInError is used to get the list of pods currently reporting errors
func (*Constellation) GetSentinelsForPod ¶
func (c *Constellation) GetSentinelsForPod(podname string) (sentinels []*Sentinel)
GetSentinelsForPod returns all sentinels the pod is monitored by. In other words, the pod's constellation
func (*Constellation) GetSlaves ¶
func (c *Constellation) GetSlaves(podname string) (slaves []structures.SlaveInfo, err error)
GetSlaves return a list of client.SlaveInfo structs for the given pod
func (*Constellation) GetStats ¶
func (c *Constellation) GetStats() ConstellationStats
GetStats returns metrics about the constellation
func (*Constellation) HasPodsInErrorState ¶
func (c *Constellation) HasPodsInErrorState() bool
HasPodsInErrorState returns true if at least one pod is in an error state. TODO: this needs to be "cloned" to a HasPodsInWarningState when that refoctoring takes place.
func (*Constellation) IsBalanced ¶
func (c *Constellation) IsBalanced() (isbal bool)
IsBalanced is likely to be deprecated. What it currently does is to look across the known sentinels and pods and determine if any pod is "unbalanced".
func (*Constellation) LoadLocalPods ¶
func (c *Constellation) LoadLocalPods() error
LoadLocalPods uses the PodConfigs read from the sentinel config file and talks to the local sentinel to develop the list of pods the local sentinel knows about.
func (*Constellation) LoadNodesForPod ¶
func (c *Constellation) LoadNodesForPod(pod *common.RedisPod, sentinel *Sentinel)
common.LoadNodesForPod is called to add the master and slave nodes for the given pod.
func (*Constellation) LoadRemotePods ¶
func (c *Constellation) LoadRemotePods() error
LoadRemotePods loads pods discovered through remote sentinel interrogation or througg known-sentinel directives
func (*Constellation) LoadRemoteSentinels ¶
func (c *Constellation) LoadRemoteSentinels()
LoadRemoteSentinels interrogates all known remote sentinels and crawls the results to explore non-local configuration
func (*Constellation) LoadSentinelConfigFile ¶
func (c *Constellation) LoadSentinelConfigFile() error
LoadSentinelConfigFile loads the local config file pulled from the environment variable "REDSKULL_SENTINELCONFIGFILE"
func (*Constellation) MonitorPod ¶
func (c *Constellation) MonitorPod(podname, address string, port, quorum int, auth string) (ok bool, err error)
MonitorPod is used to add a pod/master to the constellation cluster.
func (*Constellation) PodCount ¶
func (c *Constellation) PodCount() int
PodCount updates current pod information and returns the number of pods managed by the constellation
func (*Constellation) RemovePod ¶
func (c *Constellation) RemovePod(podname string) (bool, error)
RemovePod removes a pod from each of it's sentinels.
func (*Constellation) ResetPod ¶
func (c *Constellation) ResetPod(podname string, simultaneous bool)
ResetPod this is the constellation cluster level call to issue a reset against the sentinels for the given pod.
func (*Constellation) SentinelCount ¶
func (c *Constellation) SentinelCount() int
SentinelCount returns the number of known sentinels, including this one
func (*Constellation) SetPeers ¶
func (c *Constellation) SetPeers() error
SetPeers is used when the peers list for groupcache may have changed
func (*Constellation) StartCache ¶
func (c *Constellation) StartCache()
StartCache is used to start up the groupcache mechanism
func (*Constellation) ValidatePodSentinels ¶
func (c *Constellation) ValidatePodSentinels(podname string) (map[string]bool, error)
ValidatePodSentinels will attempt to connect to each sentinel listed for a pod and pull the master info from it. This is to validate we can 1) connect to it, and 2) it actually has the pod in it's list
type ConstellationStats ¶
type ConstellationStats struct { PodCount int NodeCount int TotalPodMemory int64 TotalNodeMemory int64 SentinelCount int PodSizes map[int64]int64 MemoryUsed int64 MemoryPctAvail float64 }
ConstellationStats holds mtrics about the constellation. As the Constellation term is undergoing a change, this will also need to change to reflect the new terminology. As soon as it is determined
type LocalSentinelConfig ¶
type LocalSentinelConfig struct { Name string Host string Port int ManagedPodConfigs map[string]SentinelPodConfig Dir string }
LocalSentinelConfig is a struct holding information about the sentinel RS is running on.
type PodAuthCache ¶
type PodAuthCache struct { CacheType string // contains filtered or unexported fields }
PodAuthCache is a struct used for groupcache to propogate authentication informaton for a pod.
func NewCache ¶
func NewCache(cacheGroup *groupcache.Group) *PodAuthCache
NewCache creates a new PodAuthCache
func (*PodAuthCache) Get ¶
func (pc *PodAuthCache) Get(podname string) string
Get is used by GroupCache to load a key not found in the cache
func (*PodAuthCache) GetHotStats ¶
func (pc *PodAuthCache) GetHotStats() groupcache.CacheStats
GetStats returns the HotCache metrics
func (*PodAuthCache) GetStats ¶
func (pc *PodAuthCache) GetStats() groupcache.CacheStats
GetStats returns the MainCache metrics
type Sentinel ¶
type Sentinel struct { Name string Host string Port int Connection *client.Redis Errors int Info structures.RedisInfoAll PodMap map[string]common.RedisPod Pods []common.RedisPod PodsInError []common.RedisPod KnownSentinels map[string]*Sentinel DialConfig client.DialConfig }
func (*Sentinel) GetMaster ¶
func (s *Sentinel) GetMaster(podname string) (master structures.MasterAddress, err error)
func (*Sentinel) GetMasters ¶
func (s *Sentinel) GetMasters() (master []structures.MasterInfo, err error)
func (*Sentinel) GetPodAuthFromConfig ¶
GetPodAuthFromConfig is a bit of a hack. It parses the sentinel config file looking for pods with an authtoken.
func (*Sentinel) GetSentinels ¶
func (*Sentinel) GetSlaves ¶
func (s *Sentinel) GetSlaves(podname string) (slaves []structures.SlaveInfo, err error)
func (*Sentinel) MonitorPod ¶
type SentinelOverrides ¶
type SentinelOverrides struct {
BindAddress string
}