worker

package
v0.0.0-...-1eec387 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitHubDownloadURL

func GetGitHubDownloadURL(ctx context.Context, gh *github.Client, pkg *neco.DebianPackage) (string, error)

GetGitHubDownloadURL returns URL of specified Debian package hosted in GitHub releases.

func InstallDebianPackage

func InstallDebianPackage(ctx context.Context, client *http.Client, ghClient *http.Client, pkg *neco.DebianPackage, background bool) error

InstallDebianPackage installs a debian package client uses for downloading a debian package. ghClient uses for getting download URL by GitHub API.

func UpdateAborted

func UpdateAborted(version string, mylrn int, statuses map[int]*neco.UpdateStatus) bool

UpdateAborted returns true if the current update process was aborted.

The condition is checked as follows: 1. If the status is not for the current version, it is ignored. 2. If the status has Cond==CondComplete, it is ignored. 3. If the status has Cond==CondAbort, this returns true. 4. If the status has Step==1 for other workers, it is ignored. 5. Otherwise, the process was aborted.

Types

type Barrier

type Barrier map[int]struct{}

Barrier is used for barrier synchronization between boot servers.

func NewBarrier

func NewBarrier(lrns []int) Barrier

NewBarrier returns Barrier to synchronize boot servers listed in lrns.

func (Barrier) Check

func (b Barrier) Check(lrn int) bool

Check inform the barrier of the arrival of a boot server to a check point. It returns true when all boot servers reach the check point.

type Operator

type Operator interface {
	// UpdateNeco updates neco package.
	UpdateNeco(ctx context.Context, req *neco.UpdateRequest) error

	// FinalStep is the step number of the final operation.
	FinalStep() int

	// RunStep executes operations for given step.
	RunStep(ctx context.Context, req *neco.UpdateRequest, step int) error

	// RestoreServices starts installed services at startup.
	StartServices(ctx context.Context) error

	// RestartEtcd restarts etcd.
	RestartEtcd(index int, req *neco.UpdateRequest) error
}

Operator installs or updates programs

func NewOperator

func NewOperator(ctx context.Context, ec *clientv3.Client, mylrn int) (Operator, error)

NewOperator creates an Operator

type Worker

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

Worker implements Neco auto update worker process. This is a state machine.

func NewWorker

func NewWorker(ec *clientv3.Client, op Operator, version string, mylrn int) *Worker

NewWorker returns a *Worker.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Run waits for update request from neco-updater, then executes update process with other workers. To communicate with neco-updater and other workers, etcd objects are used.

Run works as follows:

1. Check the current request. If the request is not found, go to 5.

  1. If locally installed neco package is older than the requested version, neco-worker updates the package, then exits to be restarted by systemd.
  1. Check the status of request and workers; if the update process was aborted, or if the update process has completed successfully, also go to 5.

4. Update programs for the requested version.

  1. Wait for the new request. If there is a new one, neco-worker updates the package and exits to be restarted by systemd.

Jump to

Keyboard shortcuts

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