upgrade

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 20 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

func Storage added in v0.4.9

func Storage(url string) func(u *Upgrader) error

Storage option overrides the default hub storage url

func Zinit added in v0.4.9

func Zinit(socket string) func(u *Upgrader) error

Zinit option overrides the default zinit socket

Types

type Boot

type Boot struct{}

Boot struct

func (*Boot) Current

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

Current returns current flist information

func (*Boot) CurrentBins

func (b *Boot) CurrentBins() (map[string]FListInfo, 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 FullFListInfo) error

Set updates the stored flist info

func (*Boot) SetBins

func (b *Boot) SetBins(current map[string]FListInfo) 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 FListInfo added in v0.4.9

type FListInfo struct {
	Name       string `json:"name"`
	Target     string `json:"target"`
	Type       string `json:"type"`
	Updated    uint64 `json:"updated"`
	Repository string `json:"-"`
}

FListInfo is information of flist as returned by repo list operation

func (*FListInfo) Absolute added in v0.4.9

func (b *FListInfo) Absolute() string

Absolute returns the actual flist name

func (*FListInfo) Files added in v0.4.9

func (b *FListInfo) Files() ([]FileInfo, error)

Files gets the list of the files of an flist

func (*FListInfo) Fqdn added in v0.4.9

func (b *FListInfo) Fqdn() string

Fqdn return the full flist name

func (*FListInfo) TryVersion added in v0.5.5

func (b *FListInfo) TryVersion() semver.Version

func (*FListInfo) Version added in v0.4.9

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

Version returns the version of the flist

type FListRepo added in v0.5.5

type FListRepo struct {
	Repo    string
	Current map[string]FListInfo
	// contains filtered or unexported fields
}

FListRepo type

func (*FListRepo) Diff added in v0.5.5

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

Diff return the remote changes related to current list of packages

type FileInfo added in v0.4.9

type FileInfo struct {
	Path string `json:"path"`
	Size uint64 `json:"size"`
}

FileInfo is the file of an flist

type FullFListInfo added in v0.4.9

type FullFListInfo struct {
	FListInfo
	Hash string `json:"md5"`
	Size uint64 `json:"size"`
}

FullFListInfo reflects node boot information (flist + version)

func (*FullFListInfo) Commit added in v0.4.9

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

Commit write version to version file

type HubClient added in v0.4.9

type HubClient struct{}

HubClient API for f-list

func (*HubClient) Download added in v0.4.9

func (h *HubClient) Download(cache, flist string) (string, error)

Download downloads an flist (fqn: repo/name) to cache and return the full path to the extraced meta data directory. the returned path is in format {cache}/{hash}/

func (*HubClient) Info added in v0.4.9

func (h *HubClient) Info(flist string) (info FullFListInfo, err error)

Info gets flist info from hub

func (*HubClient) List added in v0.4.9

func (h *HubClient) List(repo string) ([]FListInfo, error)

List list repo flists

func (*HubClient) MountURL added in v0.4.9

func (h *HubClient) MountURL(flist string) string

MountURL returns the full url of given flist.

func (*HubClient) StorageURL added in v0.4.9

func (h *HubClient) StorageURL() string

StorageURL return hub storage url

type Upgrader

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

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

func NewUpgrader added in v0.4.9

func NewUpgrader(cache string, opts ...UpgraderOption) (*Upgrader, error)

NewUpgrader creates a new upgrader instance

func (*Upgrader) InstallBinary

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

InstallBinary from a single flist.

func (*Upgrader) UninstallBinary

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

UninstallBinary from a single flist.

func (*Upgrader) Upgrade

func (u *Upgrader) Upgrade(from, to FullFListInfo) 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 UpgraderOption added in v0.4.9

type UpgraderOption func(u *Upgrader) error

UpgraderOption interface

func NoSelfUpgrade added in v0.4.9

func NoSelfUpgrade(o bool) UpgraderOption

NoSelfUpgrade option

Jump to

Keyboard shortcuts

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