upgrade

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

README

Upgrade module

The upgrade module is responsible to keep a zos node always up to date.

It checks the hub for new releases of zos packages. Also check version and safe_to_upgrade flag from the chain.

If safe_to_upgrade is set to false and a new release is available then it will only update the configured farms

If safe_to_upgrade is set to true and a new release is available, it will then update the packages and restart the updated module with the new binaries if required.

Usage

To run the upgrade module you first need to create a new upgrader instance with the supported options.

Option Description Default
NoZosUpgrade enable or disable the update of zos binaries enabled by default
Storage overrides the default hub storage url hub.grid.tf
Zinit overrides the default zinit socket "/var/run/zinit.sock"
upgrader, err := upgrade.NewUpgrader(root, upgrade.NoZosUpgrade(debug))
if err != nil {
    log.Fatal().Err(err).Msg("failed to initialize upgrader")
}

Then run the upgrader upgrader.Run(ctx)

How it works

The upgrader module has two running modes depending on the booting method.

Bootstrap Method

Running the upgrader on a node run with bootstrap will periodically check the hub for latest tag, and if that tag differs from the current one, it updates the local packages to latest.

If the update failed, the upgrader would attempts to install the packages again every 10 seconds until all packages are successfully updated to prevent partial updates.

The upgrader runs periodically every hour to check for new updates.

Other Methods

If the node is booted with any other method, the required packages are likely not installed. The upgrader checks if this is the first run, and if so, it installs all the latest packages and blocks forever.

Documentation

Index

Constants

View Source
const (
	TagFile = "/tmp/tag.info"

	// deprecated file used to detect boot method. we use this
	// as a fall back in case of an upgrade to a running machine
	OldZosFile = "/tmp/flist.name"
)
View Source
const (
	ZosRepo    = "tf-zos"
	ZosPackage = "zos.flist"
)

Variables

View Source
var (
	ErrNotBootstrapped = fmt.Errorf("node was not bootstrapped")
)
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() (flist hub.TagLink, err error)

Current returns current flist information

func (Boot) DetectBootMethod

func (b Boot) DetectBootMethod() BootMethod

DetectBootMethod tries to detect the boot method of the node

func (*Boot) RunMode

func (b *Boot) RunMode() environment.RunMode

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 hub.TagLink) error

Set updates the stored flist info

func (*Boot) Version

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

type BootMethod

type BootMethod string

BootMethod defines the node boot method

const (
	// BootMethodBootstrap booted with bootstrapping.
	// this means that all packages are installed from flist
	BootMethodBootstrap BootMethod = "bootstrap"

	// BootMethodOther booted with other methods
	// only happen during development (VM + overlay)
	BootMethodOther BootMethod = "other"
)

func (BootMethod) IsBootstrapped

func (b BootMethod) IsBootstrapped() bool

type ChainVersion

type ChainVersion struct {
	SafeToUpgrade bool   `json:"safe_to_upgrade"`
	Version       string `json:"version"`
	VersionLight  string `json:"version_light"`
}

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

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

NewUpgrader creates a new upgrader instance

func (*Upgrader) Run

func (u *Upgrader) Run(ctx context.Context) error

Run starts the upgrader module and run the update according to the detected boot method

func (*Upgrader) Version

func (u *Upgrader) Version() semver.Version

type UpgraderOption

type UpgraderOption func(u *Upgrader) error

UpgraderOption interface

func NoZosUpgrade

func NoZosUpgrade(o bool) UpgraderOption

NoZosUpgrade option, enable or disable the update of zos binaries. enabled by default

func Storage

func Storage(url string) UpgraderOption

Storage option overrides the default hub storage url default value is hub.grid.tf

func ZbusClient

func ZbusClient(cl zbus.Client) UpgraderOption

ZbusClient option, adds a zbus client to the upgrader

func Zinit

func Zinit(socket string) UpgraderOption

Zinit option overrides the default zinit socket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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