clusterd

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 The Rook Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	EtcdRequestTimeout = time.Second
	LeaderKey          = "/rook/leader"
)
View Source
const (
	DesiredKey              = "desired"
	AppliedKey              = "applied"
	NodeStatusRootKey       = "/rook/_notify/%s"
	NodeStatusServiceKey    = "/rook/_notify/%s/%s" // node ID, service name
	InfiniteTimeout         = -1
	StatusValue             = "status"
	NodeConfigStatusUnknown = iota
	NodeConfigStatusNotTriggered
	NodeConfigStatusTriggered
	NodeConfigStatusRunning
	NodeConfigStatusFailed
	NodeConfigStatusSucceeded
	NodeConfigStatusTimeout
	NodeConfigStatusAbort
)
View Source
const (
	LeaderElectionKey = "orchestrator-leader"
)
View Source
const (
	SystemLogDir = "/var/log/rook"
)

Variables

This section is empty.

Functions

func ConfigureServiceIfTriggered

func ConfigureServiceIfTriggered(context *Context, agent ServiceAgent) bool

func GetNodeProgressKey

func GetNodeProgressKey(nodeID string) string

Get the general node status key, used for communication between the leader and the agents

func GetNodeStatusKey

func GetNodeStatusKey(service, nodeID string) string

Get the status key for the general node or the specific service on the node.

func IsLeader

func IsLeader(l Lease, nodeID string) bool

func IsNodeUnhealthy

func IsNodeUnhealthy(node *inventory.NodeConfig) (int, bool)

func RunConfigureAgent

func RunConfigureAgent(context *Context, agent ServiceAgent) error

func SetNodeConfigStatus

func SetNodeConfigStatus(etcdClient etcd.KeysAPI, nodeID, taskKey string, nodeStatus NodeConfigStatus) error

SetNodeConfigStatus sets the node configuration status. If a taskKey is specified, set the status for a specific task. If the taskKey is the empty string, set the status for the node.

func SetNodeConfigStatusWithPrevIndex

func SetNodeConfigStatusWithPrevIndex(etcdClient etcd.KeysAPI, nodeID string, nodeStatus NodeConfigStatus,
	prevIndex uint64) (*etcd.Response, error)

func TriggerAgents

func TriggerAgents(etcdClient etcd.KeysAPI, nodeIDs []string, agentKey string) error

Trigger agents that they need to apply new state. The method will not wait for any nodes to respond. Returns success if the etcd trigger keys were set.

func TriggerAgentsAndWait

func TriggerAgentsAndWait(etcdClient etcd.KeysAPI, nodeIDs []string, agentKey string, requiredSuccessCount, waitSeconds int) error

Trigger agents that they need to apply new state. The method will wait for all nodes to respond. Returns success if at least "requiredSuccessCount" of the nodes succeed. Waits at most the designated number of seconds.

func TriggerAgentsAndWaitForCompletion

func TriggerAgentsAndWaitForCompletion(etcdClient etcd.KeysAPI, nodeIDs []string, agentKey string, requiredSuccessCount int) error

Trigger agents that they need to apply new state. The method will wait for all nodes to respond. Returns success if at least "requiredSuccessCount" of the nodes succeed. Waits at most 60s per node.

func WaitForNodeConfigCompletion

func WaitForNodeConfigCompletion(etcdClient etcd.KeysAPI, taskKey string, nodes []string, timeout int) (int, error)

Types

type ClusterMember

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

func (*ClusterMember) ElectLeader

func (r *ClusterMember) ElectLeader() error

type ClusterRefresher

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

ClusterRefresher type

func NewClusterRefresher

func NewClusterRefresher() *ClusterRefresher

Create a new cluster refresher

func (*ClusterRefresher) Start

func (c *ClusterRefresher) Start()

Start consuming refresh events

func (*ClusterRefresher) Stop

func (c *ClusterRefresher) Stop()

Stop consuming refresh events

func (*ClusterRefresher) TriggerDevicesChanged

func (c *ClusterRefresher) TriggerDevicesChanged(nodeID string) bool

Trigger an event for a device being added or removed to a node

func (*ClusterRefresher) TriggerRefresh

func (c *ClusterRefresher) TriggerRefresh() bool

Trigger a general refresh of the cluster

type ClusterService

type ClusterService struct {
	Name   string
	Leader ServiceLeader
	Agents []ServiceAgent
}

type Context

type Context struct {
	// The registered services for cluster configuration
	Services []*ClusterService

	// The latest inventory information
	Inventory *inventory.Config

	// The local node ID
	NodeID string

	// The etcd client for get/set config values
	EtcdClient etcd.KeysAPI

	// The implementation of executing a console command
	Executor exec.Executor

	// The process manager for launching a process
	ProcMan *proc.ProcManager

	// The root configuration directory used by services
	ConfigDir string

	// A value indicating the desired logging/tracing level
	LogLevel capnslog.LogLevel
}

The context for loading or applying the configuration state of a service.

func StartJoinCluster

func StartJoinCluster(services []*ClusterService, configDir, nodeID, discoveryURL,
	etcdMembers, publicIPv4, privateIPv4 string, logLevel capnslog.LogLevel) (*Context, error)

StartJoinCluster initializes the cluster services to enable joining the cluster and listening for orchestration.

func (*Context) GetEtcdClient

func (c *Context) GetEtcdClient() (etcd.KeysAPI, error)

func (*Context) GetExecutor

func (c *Context) GetExecutor() exec.Executor

type Leader

type Leader interface {
	OnLeadershipAcquired() error
	OnLeadershipLost() error
	GetLeaseName() string
}

Interface defining how a leader reacts to gaining or losing election, new members being added, etc.

type Lease

type Lease interface {
	Renew(time.Duration) error
	Release() error
	MachineID() string
	Version() int
	Index() uint64
	TimeRemaining() time.Duration
}

The interfaces and implementation for leasing found in this source file comes from https://github.com/coreos/fleet/tree/master/pkg/lease We cannot reference the fleet package due to the fleet reference to the etcdclient as part of the antiquated godeps _workspace. With the move to the vendor folder, we were required to break this indirect dependency and move the source code to our own repo.

type Manager

type Manager interface {
	GetLease(name string) (Lease, error)
	AcquireLease(name, machID string, ver int, period time.Duration) (Lease, error)
	StealLease(name, machID string, ver int, period time.Duration, idx uint64) (Lease, error)
}

type NodeConfigStatus

type NodeConfigStatus int

func GetNodeConfigStatus

func GetNodeConfigStatus(etcdClient etcd.KeysAPI, taskKey, nodeID string) (NodeConfigStatus, uint64, error)

func ParseNodeConfigStatus

func ParseNodeConfigStatus(status string) NodeConfigStatus

func WatchNodeConfigStatus

func WatchNodeConfigStatus(etcdClient etcd.KeysAPI, taskKey, nodeID string, timeout int, index *uint64) (NodeConfigStatus, error)

WatchNodeConfigStatus watches for changes to the node config status etcd key

func (NodeConfigStatus) String

func (n NodeConfigStatus) String() string

type RefreshEvent

type RefreshEvent struct {
	Context        *Context
	NodesAdded     *util.Set
	NodesRemoved   *util.Set
	NodesChanged   *util.Set
	NodesUnhealthy map[string]*UnhealthyNode
}

RefreshEvent type

func NewRefreshEvent

func NewRefreshEvent() *RefreshEvent

Create a new refresh event

type RefreshKey

type RefreshKey struct {
	Path      string
	Triggered func(response *etcd.Response, refresher *ClusterRefresher)
}

RefreshKey type

type ServiceAgent

type ServiceAgent interface {
	// Get the name of the service agent
	Name() string

	// Initialize the agents from the context, allowing them to store desired state in etcd before orchestration starts.
	Initialize(context *Context) error

	// Configure the service according to the changes requested by the leader
	ConfigureLocalService(context *Context) error

	// Remove a service that is no longer needed
	DestroyLocalService(context *Context) error
}

type ServiceLeader

type ServiceLeader interface {
	// Get the list of etcd keys that when changed should trigger an orchestration
	RefreshKeys() []*RefreshKey

	// Refresh the service
	HandleRefresh(e *RefreshEvent)
}

Interface implemented by a service that has been elected leader

type UnhealthyNode

type UnhealthyNode struct {
	ID         string
	AgeSeconds int
}

UnhealthyNode type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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