Documentation ¶
Index ¶
- Constants
- Variables
- type Snapshot
- type StatusWatcher
- type Storage
- func (s Storage) ClearStatusAndContents(ctx context.Context) error
- func (s Storage) DeleteBootServer(ctx context.Context, lrn int) error
- func (s Storage) DeleteVaultRootToken(ctx context.Context) error
- func (s Storage) DeleteVaultUnsealKey(ctx context.Context) error
- func (s Storage) Finish(ctx context.Context, lrn int, stage int) error
- func (s Storage) GetBMCBMCUser(ctx context.Context) (string, error)
- func (s Storage) GetBMCIPMIPassword(ctx context.Context) (string, error)
- func (s Storage) GetBMCIPMIUser(ctx context.Context) (string, error)
- func (s Storage) GetCKEContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
- func (s Storage) GetCKETemplateContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
- func (s Storage) GetCKEWeight(ctx context.Context) (map[string]float64, error)
- func (s Storage) GetCheckUpdateInterval(ctx context.Context) (time.Duration, error)
- func (s Storage) GetContainerTag(ctx context.Context, lrn int, name string) (string, error)
- func (s Storage) GetDHCPJSONContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
- func (s Storage) GetDebVersion(ctx context.Context, lrn int, name string) (string, error)
- func (s Storage) GetEnvConfig(ctx context.Context) (string, error)
- func (s Storage) GetExternalIPAddressBlock(ctx context.Context) (string, error)
- func (s Storage) GetFinished(ctx context.Context, stage int) ([]int, error)
- func (s Storage) GetGitHubToken(ctx context.Context) (string, error)
- func (s Storage) GetLBAddressBlockBastion(ctx context.Context) (string, error)
- func (s Storage) GetLBAddressBlockDefault(ctx context.Context) (string, error)
- func (s Storage) GetLBAddressBlockInternet(ctx context.Context) (string, error)
- func (s Storage) GetNecoRelease(ctx context.Context) (string, error)
- func (s Storage) GetNodeProxy(ctx context.Context) (string, error)
- func (s Storage) GetProxyConfig(ctx context.Context) (string, error)
- func (s Storage) GetQuayPassword(ctx context.Context) (string, error)
- func (s Storage) GetQuayUsername(ctx context.Context) (string, error)
- func (s Storage) GetRequest(ctx context.Context) (*neco.UpdateRequest, error)
- func (s Storage) GetRequestWithRev(ctx context.Context) (req *neco.UpdateRequest, modRev int64, rev int64, err error)
- func (s Storage) GetSSHPubkey(ctx context.Context) (string, error)
- func (s Storage) GetSabakanContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
- func (s Storage) GetSlackNotification(ctx context.Context) (string, error)
- func (s Storage) GetStatus(ctx context.Context, lrn int) (*neco.UpdateStatus, error)
- func (s Storage) GetStatuses(ctx context.Context) (map[int]*neco.UpdateStatus, error)
- func (s Storage) GetTeleportAuthToken(ctx context.Context) (string, error)
- func (s Storage) GetUserResourcesContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
- func (s Storage) GetVaultRootToken(ctx context.Context) (string, error)
- func (s Storage) GetVaultUnsealKey(ctx context.Context) (string, error)
- func (s Storage) GetWorkerTimeout(ctx context.Context) (time.Duration, error)
- func (s Storage) NewSnapshot(ctx context.Context) (*Snapshot, error)
- func (s Storage) PutBMCBMCUser(ctx context.Context, value string) error
- func (s Storage) PutBMCIPMIPassword(ctx context.Context, value string) error
- func (s Storage) PutBMCIPMIUser(ctx context.Context, value string) error
- func (s Storage) PutCKEContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
- func (s Storage) PutCKETemplateContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
- func (s Storage) PutCKEWeight(ctx context.Context, value map[string]float64) error
- func (s Storage) PutCheckUpdateInterval(ctx context.Context, d time.Duration) error
- func (s Storage) PutDHCPJSONContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
- func (s Storage) PutEnvConfig(ctx context.Context, env string) error
- func (s Storage) PutExternalIPAddressBlock(ctx context.Context, ipBlock string) error
- func (s Storage) PutGitHubToken(ctx context.Context, token string) error
- func (s Storage) PutLBAddressBlockBastion(ctx context.Context, ipBlock string) error
- func (s Storage) PutLBAddressBlockDefault(ctx context.Context, ipBlock string) error
- func (s Storage) PutLBAddressBlockInternet(ctx context.Context, ipBlock string) error
- func (s Storage) PutNodeProxy(ctx context.Context, token string) error
- func (s Storage) PutProxyConfig(ctx context.Context, proxy string) error
- func (s Storage) PutQuayPassword(ctx context.Context, passwd string) error
- func (s Storage) PutQuayUsername(ctx context.Context, username string) error
- func (s Storage) PutReconfigureRequest(ctx context.Context, req neco.UpdateRequest, leaderKey string) error
- func (s Storage) PutRequest(ctx context.Context, req neco.UpdateRequest, leaderKey string) error
- func (s Storage) PutSSHPubkey(ctx context.Context, key string) error
- func (s Storage) PutSabakanContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
- func (s Storage) PutSlackNotification(ctx context.Context, url string) error
- func (s Storage) PutStatus(ctx context.Context, lrn int, st neco.UpdateStatus) error
- func (s Storage) PutTeleportAuthToken(ctx context.Context, token string) error
- func (s Storage) PutUserResourcesContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
- func (s Storage) PutVaultRootToken(ctx context.Context, token string) error
- func (s Storage) PutVaultUnsealKey(ctx context.Context, key string) error
- func (s Storage) PutWorkerTimeout(ctx context.Context, d time.Duration) error
- func (s Storage) RecordContainerTag(ctx context.Context, lrn int, name string) error
- func (s Storage) RecordDebVersion(ctx context.Context, lrn int, name string) error
- func (s Storage) RegisterBootserver(ctx context.Context, lrn int) error
- func (s Storage) UpdateNecoRelease(ctx context.Context, version, leaderKey string) error
- func (s Storage) WaitConfigChange(ctx context.Context) error
- func (s Storage) WaitInfo(ctx context.Context, rev int64) error
- func (s Storage) WaitRequest(ctx context.Context, rev int64) (*neco.UpdateRequest, int64, error)
- func (s Storage) WaitRequestDeletion(ctx context.Context, rev int64) error
- type WorkerWatcher
Constants ¶
const ( DefaultCheckUpdateInterval = 1 * time.Minute DefaultWorkerTimeout = 60 * time.Minute )
Default values
const ( KeySabakanStateSetterLeader = "leader/sabakan-state-setter/" KeyUpdaterLeader = "leader/updater/" KeyWorkerLeader = "leader/worker/" KeyInfoPrefix = "info/" KeyBootserversPrefix = "info/bootservers/" KeyNecoRelease = "info/neco-release" KeySSHPubkey = "info/ssh-pubkey" KeyStatusPrefix = "status/" KeyCurrent = "status/current" KeyWorkerStatusPrefix = "status/bootservers/" KeyContentsPrefix = "contents/" KeySabakanContents = "contents/sabakan" KeyCKEContents = "contents/cke" KeyDHCPJSONContents = "contents/dhcp.json" KeyCKETemplateContents = "contents/cke-template" KeyUserResourcesContents = "contents/user-resources" KeyConfigPrefix = "config/" KeyNotificationSlack = "config/notification/slack" KeyProxy = "config/proxy" KeyQuayUsername = "config/quay-username" KeyQuayPassword = "config/quay-password" KeyEnv = "config/env" KeyCheckUpdateInterval = "config/check-update-interval" KeyWorkerTimeout = "config/worker-timeout" KeyGitHubToken = "config/github-token" KeyNodeProxy = "config/node-proxy" KeyExternalIPAddressBlock = "config/external-ip-address-block" KeyLBAddressBlockDefault = "config/lb-address-block-default" KeyLBAddressBlockBastion = "config/lb-address-block-bastion" KeyLBAddressBlockInternet = "config/lb-address-block-internet" KeyVaultUnsealKey = "vault-unseal-key" KeyVaultRootToken = "vault-root-token" KeyFinishPrefix = "finish/" KeyContainersFormat = "install/%d/containers/%s" KeyDebsFormat = "install/%d/debs/%s" KeyInstallPrefix = "install/" KeyBMCBMCUser = "bmc/bmc-user" KeyBMCIPMIUser = "bmc/ipmi-user" KeyBMCIPMIPassword = "bmc/ipmi-password" KeyTeleportAuthToken = "teleport/auth-token" KeyCKEWeight = "cke/weight" )
etcd keys
Variables ¶
var ( // ErrNotFound is returned when a key is not found in storage. ErrNotFound = errors.New("not found") // ErrNotStopped is returned when the updater did not stop. ErrNotStopped = errors.New("not stopped") // ErrNoLeader is returned when the caller lost leadership. ErrNoLeader = errors.New("lost leadership") // ErrTimedOut is returned when the request is timed out. ErrTimedOut = errors.New("timed out") )
Functions ¶
This section is empty.
Types ¶
type Snapshot ¶
type Snapshot struct { Revision int64 Request *neco.UpdateRequest Statuses map[int]*neco.UpdateStatus Latest string Servers []int }
Snapshot is the up-to-date snapshot of etcd database.
type StatusWatcher ¶
type StatusWatcher struct {
// contains filtered or unexported fields
}
StatusWatcher has callback handlers to handle status changes
func NewStatusWatcher ¶
func NewStatusWatcher( handleRequest func(context.Context, *neco.UpdateRequest) (bool, error), handleStatus func(context.Context, int, *neco.UpdateStatus) (bool, error), handleError func(context.Context, error) error, ) StatusWatcher
NewStatusWatcher creates a new StatusWatcher
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is storage client
func NewStorage ¶
NewStorage returns Storage that stores data in etcd.
func (Storage) ClearStatusAndContents ¶
ClearStatusAndContents removes KeyStatusPrefix/* and KeyContentsPrefix/* from storage.
It first checks that "stop" field in KeyCurrent is true. If not, ErrNotStopped will be returned.
Then it removes status keys in a single transaction.
func (Storage) DeleteBootServer ¶
DeleteBootServer deletes boot server from etcd database.
func (Storage) DeleteVaultRootToken ¶
DeleteVaultRootToken deletes vault root token from storage
func (Storage) DeleteVaultUnsealKey ¶
DeleteVaultUnsealKey deletes vault unseal key from storage
func (Storage) GetBMCBMCUser ¶
GetBMCBMCUser returns bmc-user.json contents
func (Storage) GetBMCIPMIPassword ¶
GetBMCIPMIPassword returns IPMI password.
func (Storage) GetBMCIPMIUser ¶
GetBMCIPMIUser returns IPMI username.
func (Storage) GetCKEContentsStatus ¶
GetCKEContentsStatus returns update status of CKE contents.
func (Storage) GetCKETemplateContentsStatus ¶
func (s Storage) GetCKETemplateContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
GetCKETemplateContentsStatus returns update status of cke-template.yml.
func (Storage) GetCKEWeight ¶
GetCKEWeight returns weights of roles..
func (Storage) GetCheckUpdateInterval ¶
GetCheckUpdateInterval returns check-update-interval config from storage. It returns default value if the key does not exist.
func (Storage) GetContainerTag ¶
GetContainerTag returns installed container image tag
func (Storage) GetDHCPJSONContentsStatus ¶
GetDHCPJSONContentsStatus returns update status of dhcp.json for sabakan.
func (Storage) GetDebVersion ¶
GetDebVersion returns installed debian package version
func (Storage) GetEnvConfig ¶
GetEnvConfig returns proxy config from storage.
func (Storage) GetExternalIPAddressBlock ¶
GetExternalIPAddressBlock returns external ip address block from storage
func (Storage) GetFinished ¶
GetFinished returns a list of bootservers that completed specified stage of setup
func (Storage) GetGitHubToken ¶
GetGitHubToken returns github-token from storage
func (Storage) GetLBAddressBlockBastion ¶
GetLBAddressBlockBastion returns LB address block for bastion from storage
func (Storage) GetLBAddressBlockDefault ¶
GetLBAddressBlockDefault returns LB address block for default from storage
func (Storage) GetLBAddressBlockInternet ¶
GetLBAddressBlockInternet returns LB address block for internet from storage
func (Storage) GetNecoRelease ¶
GetNecoRelease gets the neco package version recorded in etcd.
func (Storage) GetNodeProxy ¶
GetNodeProxy returns node-proxy from storage
func (Storage) GetProxyConfig ¶
GetProxyConfig returns proxy config from storage.
func (Storage) GetQuayPassword ¶
GetQuayPassword returns proxy config from storage.
func (Storage) GetQuayUsername ¶
GetQuayUsername returns proxy config from storage.
func (Storage) GetRequest ¶
GetRequest returns UpdateRequest from storage If there is no request, this returns ErrNotFound
func (Storage) GetRequestWithRev ¶
func (s Storage) GetRequestWithRev(ctx context.Context) (req *neco.UpdateRequest, modRev int64, rev int64, err error)
GetRequestWithRev returns UpdateRequest from storage with ModRevision and Revision. If there is no request, this returns ErrNotFound
func (Storage) GetSSHPubkey ¶
GetSSHPubkey retrieves a SSH public key for nodes.
func (Storage) GetSabakanContentsStatus ¶
GetSabakanContentsStatus returns update status of Sabakan contents.
func (Storage) GetSlackNotification ¶
GetSlackNotification returns SlackNotification from storage If not found, this returns ErrNotFound.
func (Storage) GetStatus ¶
GetStatus returns UpdateStatus of a bootserver from storage If not found, this returns ErrNotFound.
func (Storage) GetStatuses ¶
GetStatuses returns UpdateStatus of existing boot servers.
func (Storage) GetTeleportAuthToken ¶
GetTeleportAuthToken returns auth token
func (Storage) GetUserResourcesContentsStatus ¶
func (s Storage) GetUserResourcesContentsStatus(ctx context.Context) (*neco.ContentsUpdateStatus, error)
GetUserResourcesContentsStatus returns update status of user-defined resources.
func (Storage) GetVaultRootToken ¶
GetVaultRootToken returns vault root token from storage
func (Storage) GetVaultUnsealKey ¶
GetVaultUnsealKey returns vault unseal key from storage
func (Storage) GetWorkerTimeout ¶
GetWorkerTimeout returns worker-timeout config from storage. It returns default value if the key does not exist.
func (Storage) NewSnapshot ¶
NewSnapshot takes the up-to-date snapshot.
func (Storage) PutBMCBMCUser ¶
PutBMCBMCUser stores bmc-user.json contents
func (Storage) PutBMCIPMIPassword ¶
PutBMCIPMIPassword stores IPMI password.
func (Storage) PutBMCIPMIUser ¶
PutBMCIPMIUser stores IPMI username.
func (Storage) PutCKEContentsStatus ¶
func (s Storage) PutCKEContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
PutCKEContentsStatus puts update status of CKE contents, only if caller is the leader.
func (Storage) PutCKETemplateContentsStatus ¶
func (s Storage) PutCKETemplateContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
PutCKETemplateContentsStatus puts update status of cke-template.yml, only if caller is the leader.
func (Storage) PutCKEWeight ¶
PutCKEWeight stores weights of roles.
func (Storage) PutCheckUpdateInterval ¶
PutCheckUpdateInterval stores check-update-interval config to storage.
func (Storage) PutDHCPJSONContentsStatus ¶
func (s Storage) PutDHCPJSONContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
PutDHCPJSONContentsStatus puts update status of dhcp.json for sabakan, only if caller is the leader.
func (Storage) PutEnvConfig ¶
PutEnvConfig stores proxy config to storage.
func (Storage) PutExternalIPAddressBlock ¶
PutExternalIPAddressBlock stores external ip address block config to storage.
func (Storage) PutGitHubToken ¶
PutGitHubToken stores github-token config to storage.
func (Storage) PutLBAddressBlockBastion ¶
PutLBAddressBlockBastion stores LB address block for bastion to storage.
func (Storage) PutLBAddressBlockDefault ¶
PutLBAddressBlockDefault stores LB address block for default to storage.
func (Storage) PutLBAddressBlockInternet ¶
PutLBAddressBlockInternet stores LB address block for internet to storage.
func (Storage) PutNodeProxy ¶
PutNodeProxy stores node-proxy config to storage.
func (Storage) PutProxyConfig ¶
PutProxyConfig stores proxy config to storage.
func (Storage) PutQuayPassword ¶
PutQuayPassword stores proxy config to storage.
func (Storage) PutQuayUsername ¶
PutQuayUsername stores proxy config to storage.
func (Storage) PutReconfigureRequest ¶
func (s Storage) PutReconfigureRequest(ctx context.Context, req neco.UpdateRequest, leaderKey string) error
PutReconfigureRequest stores UpdateRequest to storage and delete worker statuses in a single transaction. leaderKey is the current leader key. If the caller has lost the leadership, this returns ErrNoLeader.
func (Storage) PutRequest ¶
PutRequest stores UpdateRequest to storage leaderKey is the current leader key. If the caller has lost the leadership, this returns ErrNoLeader.
func (Storage) PutSSHPubkey ¶
PutSSHPubkey registers a SSH public key for nodes.
func (Storage) PutSabakanContentsStatus ¶
func (s Storage) PutSabakanContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
PutSabakanContentsStatus puts update status of Sabakan contents, only if caller is the leader.
func (Storage) PutSlackNotification ¶
PutSlackNotification stores SlackNotification to storage
func (Storage) PutTeleportAuthToken ¶
PutTeleportAuthToken stores auth token
func (Storage) PutUserResourcesContentsStatus ¶
func (s Storage) PutUserResourcesContentsStatus(ctx context.Context, st *neco.ContentsUpdateStatus, leaderKey string) error
PutUserResourcesContentsStatus puts update status of user-defined resources, only if caller is the leader.
func (Storage) PutVaultRootToken ¶
PutVaultRootToken stores vault root token to storage
func (Storage) PutVaultUnsealKey ¶
PutVaultUnsealKey stores vault unseal key to storage
func (Storage) PutWorkerTimeout ¶
PutWorkerTimeout stores worker-timeout config to storage.
func (Storage) RecordContainerTag ¶
RecordContainerTag records installed container image tag
func (Storage) RecordDebVersion ¶
RecordDebVersion records installed debian package version
func (Storage) RegisterBootserver ¶
RegisterBootserver registers a bootserver with etcd database.
func (Storage) UpdateNecoRelease ¶
UpdateNecoRelease updates the neco package version with the latest GitHub release.
func (Storage) WaitConfigChange ¶
WaitConfigChange waits config key change and return a non-nil error.
func (Storage) WaitRequest ¶
WaitRequest waits for a UpdateRequest to be written to etcd and returns it.
type WorkerWatcher ¶
type WorkerWatcher struct {
// contains filtered or unexported fields
}
WorkerWatcher has callback handlers to handle status changes
func NewWorkerWatcher ¶
func NewWorkerWatcher( handleStatus func(context.Context, int, *neco.UpdateStatus) bool, ) WorkerWatcher
NewWorkerWatcher creates a new WorkerWatcher