okctlgithub.com/oslokommune/okctl/pkg/upgrade/originalclusterversion Index | Files

package originalclusterversion

import "github.com/oslokommune/okctl/pkg/upgrade/originalclusterversion"

Package originalclusterversion knows how to save the original version of a cluster

Index

Constants

const SaveErrorMessage = "saving original cluster version: %w"

SaveErrorMessage contains the error messsage to return if saving original cluster version fails

Types

type Versioner

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

Versioner stores the version of okctl first used to apply a cluster

func New

func New(
	clusterID api.ID,
	upgradeState client.UpgradeState,
	clusterState client.ClusterState,
) Versioner

New returns a Versioner

func (Versioner) GetOriginalClusterVersion

func (v Versioner) GetOriginalClusterVersion() (string, error)

GetOriginalClusterVersion returns the original cluster version

func (Versioner) OriginalClusterVersionExists

func (v Versioner) OriginalClusterVersionExists() (bool, error)

OriginalClusterVersionExists returns if original cluster version exists

func (Versioner) SaveOriginalClusterVersionFromClusterTagIfNotExists

func (v Versioner) SaveOriginalClusterVersionFromClusterTagIfNotExists() error

SaveOriginalClusterVersionFromClusterTagIfNotExists stores the original cluster version if it doesn't exist, with the value from the cluster tag. (tag UPGR01)

When we're sure all users has run this code, i.e. stored original okctl version in state, the caller of this function can replace the call with a call to SaveOriginalClusterVersionIfNotExists(version.GetVersionInfo().Version).

Ideally, we want to store just version.GetVersionInfo().Version if it's missing. However, this can cause problems. Let's say we release the upgrade functionality in version 0.0.60. A user might have a cluster made with version 0.0.50. They then wait until 0.0.70 to download a new version of okctl, and then runs apply cluster or upgrade.

If we simply store version.GetVersionInfo().Version, i.e. 0.0.70, okctl upgrade won't download upgrades for 0.0.65 - 0.0.70, as these will be considered as too old, when in fact they should run.

To fix this, we use the information from state, i.e. a tag applied to the cluster cloudformation stack, which has been present since 0.0.40 (see: https://github.com/oslokommune/okctl/pull/299).

To check if users has run this code, just check all users' cluster's state, and see if upgrade/OriginalClusterVersion has been set or not. If it's set, it means this code has been run.

func (Versioner) SaveOriginalClusterVersionIfNotExists

func (v Versioner) SaveOriginalClusterVersionIfNotExists(version string) error

SaveOriginalClusterVersionIfNotExists saves the original cluster version

Source Files

api.go

Version
v0.0.106 (latest)
Published
Oct 21, 2022
Platform
linux/amd64
Imports
6 packages
Last checked
7 hours ago

Tools for package owners.