upgrade

package
v0.4.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

README

Upgrade module

The upgrade module is responsible to keep a 0-OS node always up to date.

It checks the network for new releases of 0-OS pkg.

When a new release is found, it will download the flist containing the new version of the module.

If there is one available, this will then copy the new module in place, execute the migration scripts if any, and then restart the updated module with the new binaries.

Publisher

The upgrade module implements the Publisher interface

// Publisher is the interface that defines how the upgrade is published
type Publisher interface {
	// Get retrieves the Upgrade object for a specific version
	Get(version semver.Version) (Upgrade, error)
	// Latest returns the latest version available
	Latest() (semver.Version, error)
	// List all the versions this publisher has available
	List() ([]semver.Version, error)
}

This interfaces defines how the module gets information about new releases.

For now, the module only implements an HTTP publisher. The HTTP publisher relies on an HTTP server to get information. Here is a description of what is expected from the HTTP server:

Imagine the HTTP publisher has a base URL of: https://releases.grid.tf

It needs to expose 3 endpoints:

  • GET https://releases.grid.tf/versions: return a list of all the versions this publisher knows about, for example:
[
    "0.0.1",
    "0.0.2",
    "0.0.3",
    "0.1.0",
    "0.1.1"
]
  • GET https://releases.grid.tf/latest return the latest version, example:
"0.1.1"
  • GET https://releases.grid.tf/{versions} : return the upgrade object for this version, example for https://releases.grid.tf/0.0.1:
{
    "flist":"https://hub.grid.tf/tf-official-apps/threefoldtech-0-db-release-1.0.0.flist",
    "transaction_id":"",
    "signature":"e5b2cab466e43d8765e6dcf968d1af9e"
}

Documentation

Index

Constants

View Source
const (

	// FlistNameFile file contains boot flist repo/name
	FlistNameFile = "/tmp/flist.name"
	// FlistInfoFile file container boot flist infor
	FlistInfoFile = "/tmp/flist.info"
	// BinariesFile file contains binaries database
	BinariesFile = "/tmp/bins.info"
)

Variables

View Source
var (
	// ErrRestartNeeded is returned if upgraded requires a restart
	ErrRestartNeeded = fmt.Errorf("restart needed")
)

Functions

This section is empty.

Types

type Boot

type Boot struct{}

Boot struct

func (*Boot) Current

func (b *Boot) Current() (FListEvent, error)

Current returns current flist information

func (*Boot) CurrentBins

func (b *Boot) CurrentBins() (map[string]RepoFList, error)

CurrentBins returns a list of current binaries installed

func (Boot) DetectBootMethod

func (b Boot) DetectBootMethod() BootMethod

DetectBootMethod tries to detect the boot method of the node

func (*Boot) MustVersion

func (b *Boot) MustVersion() semver.Version

MustVersion must returns the current version or panic

func (*Boot) Name

func (b *Boot) Name() string

Name always return name of the boot flist. If name file does not exist, an empty string is returned

func (*Boot) Set

func (b *Boot) Set(c FListEvent) error

Set updates the stored flist info

func (*Boot) SetBins

func (b *Boot) SetBins(current map[string]RepoFList) error

SetBins sets the current list of binaries in boot files

func (*Boot) Version

func (b *Boot) Version() (semver.Version, error)

Version always returns curent version of flist

type BootMethod

type BootMethod string

BootMethod defines the node boot method

const (
	// BootMethodFList booted from an flist
	BootMethodFList BootMethod = "flist"

	// BootMethodOther booted with other methods
	BootMethodOther BootMethod = "other"
)

type Event

type Event interface {
	EventType() EventType
}

Event interface

type EventType

type EventType string

EventType of the watcher

const (
	//FList event type
	FList EventType = "flist"
	//Repo event type
	Repo EventType = "repo"
)

type FListEvent

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

FListEvent struct

func (*FListEvent) Commit

func (b *FListEvent) Commit(path string) error

Commit write version to version file

func (*FListEvent) EventType

func (f *FListEvent) EventType() EventType

EventType of the event

func (*FListEvent) TryVersion

func (f *FListEvent) TryVersion() semver.Version

TryVersion will try to parse the version from flist other wise return empty version 0.0.0

type FListRepoWatcher

type FListRepoWatcher struct {
	Repo     string
	Current  map[string]RepoFList
	Duration time.Duration
	// contains filtered or unexported fields
}

FListRepoWatcher type

func (*FListRepoWatcher) Diff

func (w *FListRepoWatcher) Diff() (all map[string]RepoFList, toAdd, toDell []RepoFList, err error)

Diff return the remote changes related to current list of packages

func (*FListRepoWatcher) Watch

func (w *FListRepoWatcher) Watch(ctx context.Context) (<-chan Event, error)

Watch watches a full repo for changes. Event is always of concrete type RepoEvent

type FListSemverWatcher

type FListSemverWatcher struct {
	FList    string
	Duration time.Duration
	Current  semver.Version
	// contains filtered or unexported fields
}

FListSemverWatcher watches a single FList for changes in it's semver the semver to change without the flist name itself changes, means that this flist is mostly a symlink

func (*FListSemverWatcher) Watch

func (w *FListSemverWatcher) Watch(ctx context.Context) (<-chan Event, error)

Watch an flist change in version The Event returned by the channel is of concrete type FListEvent

type RepoEvent

type RepoEvent struct {
	Repo  string
	ToAdd []RepoFList
	ToDel []RepoFList
}

RepoEvent is returned by the repo watcher

func (*RepoEvent) EventType

func (e *RepoEvent) EventType() EventType

EventType returns event type

type RepoFList

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

RepoFList holds information of flist from a repo list operation

func (*RepoFList) Absolute

func (b *RepoFList) Absolute() string

Absolute returns the actual flist name

func (*RepoFList) Files

func (b *RepoFList) Files() ([]fileInfo, error)

Files gets the list of the files of an flist

func (*RepoFList) Fqdn

func (b *RepoFList) Fqdn() string

func (*RepoFList) Version

func (b *RepoFList) Version() (semver.Version, error)

Version returns the version of the flist

type Upgrader

type Upgrader struct {
	FLister      pkg.Flister
	Zinit        *zinit.Client
	NoSelfUpdate bool
	// contains filtered or unexported fields
}

Upgrader is the component that is responsible to keep 0-OS up to date

func (*Upgrader) InstallBinary

func (u *Upgrader) InstallBinary(flist RepoFList) error

InstallBinary from a single flist.

func (*Upgrader) UninstallBinary

func (u *Upgrader) UninstallBinary(flist RepoFList) error

UninstallBinary from a single flist.

func (*Upgrader) Upgrade

func (u *Upgrader) Upgrade(from, to FListEvent) error

Upgrade is the method that does a full upgrade flow first check if a new version is available if yes, applies the upgrade on a successfully update, upgrade WILL NOT RETURN instead the upgraded daemon will be completely stopped

type Watcher

type Watcher interface {
	Watch(ctx context.Context) (<-chan Event, error)
}

Watcher interface

Jump to

Keyboard shortcuts

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