upgrade

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package upgrade provides CUE version-compatibility helpers for KubeVela Workflow. The core engine lives in github.com/kubevela/pkg/cue/upgrade; this package wires workflow-specific concerns (version provider, Prometheus metrics) and re-exports the public API so call sites need no import change.

Dual-mode support

The workflow engine supports two operational modes:

  1. Standalone workflow controller: the workflow binary sets GetCurrentVersion in its own init() and owns the version provider.

  2. KubeVela consuming workflow: kubevela's init() runs after this package's init() and overwrites pkgupgrade.GetCurrentVersion with velaversion.VelaVersion, so the kubevela version governs all upgrade decisions. The workflow-specific metrics callbacks remain active in both modes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// EnableListConcatUpgrade controls the list-arithmetic compatibility rewrite pass.
	EnableListConcatUpgrade = true
	// EnableErrorFieldLabelUpgrade controls quoting of legacy unquoted error labels.
	EnableErrorFieldLabelUpgrade = true
	// EnableBoolDefaultGuardUpgrade controls the bool default-guard hazard rewrite pass.
	EnableBoolDefaultGuardUpgrade = false
	// EnableGenericDefaultGuardUpgrade controls generic (non-bool) default-guard hazard rewrites.
	EnableGenericDefaultGuardUpgrade = false
	// EnableKeepValidatorsSingletonUpgrade controls singleton keepvalidators concretization rewrites.
	EnableKeepValidatorsSingletonUpgrade = false
	// EnableEvalv3SelfRefGuardUpgrade controls evalv3 self-reference default-guard rewrites.
	EnableEvalv3SelfRefGuardUpgrade = false
)
View Source
var (
	ParseVersion         = pkgupgrade.ParseVersion
	RegisterUpgrade      = pkgupgrade.RegisterUpgrade
	GetSupportedVersions = pkgupgrade.GetSupportedVersions
)

Re-export functions.

View Source
var CUECompatCacheEvictionsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name: "kubevela_workflow_cue_compat_cache_evictions_total",
	Help: "Total number of CUE compatibility cache evictions in the workflow engine, by reason (capacity or ttl).",
}, []string{"reason"})

CUECompatCacheEvictionsTotal counts cache entries evicted, by reason. Labels:

  • reason: "capacity" (LRU eviction when cache is full) or "ttl" (idle entry swept by background loop)
View Source
var CUECompatRewriteTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name: "kubevela_workflow_cue_compat_rewrite_total",
	Help: "Total number of CUE compatibility rewrites applied at workflow render time, by upgrade ID, version introduced, definition kind, and template area.",
}, []string{"upgrade_id", "upgrade_version", "definition_kind", "template_area"})

CUECompatRewriteTotal counts the number of CUE compatibility rewrites applied at render time. Labels:

  • upgrade_id: stable fix identifier, e.g. "list-arithmetic"
  • upgrade_version: KubeVela version that introduced the incompatibility, e.g. "1.11"
  • definition_kind: definition type, e.g. "WorkflowStep"
  • template_area: which part of the definition was rewritten, e.g. "template"
View Source
var CUECompatUpgradeDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
	Name:    "kubevela_workflow_cue_compat_upgrade_duration_seconds",
	Help:    "Duration of CUE version compatibility checks at workflow render time (cache misses only), by definition kind.",
	Buckets: []float64{0.00001, 0.00005, 0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1},
}, []string{"definition_kind"})

CUECompatUpgradeDuration measures how long EnsureCueVersionCompatibility takes per call. Only recorded on cache misses (i.e. when the actual upgrade logic runs). Labels:

  • definition_kind: definition type, e.g. "WorkflowStep"
View Source
var CompatibilityCacheSize = pkgupgrade.CompatibilityCacheSize

CompatibilityCacheSize mirrors pkgupgrade.CompatibilityCacheSize.

View Source
var EnableCUEVersionCompatibility = &pkgupgrade.EnableCUEVersionCompatibility

EnableCUEVersionCompatibility is an alias for pkgupgrade.EnableCUEVersionCompatibility.

Functions

func EnsureCueVersionCompatibility

func EnsureCueVersionCompatibility(cueStr, defName string, defKind DefinitionKind, area TemplateArea) (string, bool)

EnsureCueVersionCompatibility applies all upgrades for the running workflow version.

func InitCompatibilityCache

func InitCompatibilityCache(ctx context.Context, size int)

InitCompatibilityCache reinitialises the LRU cache.

func RequiresUpgrade

func RequiresUpgrade(cueStr string, targetVersion ...Version) (bool, []string, error)

RequiresUpgrade checks whether cueStr needs upgrading.

func SetCacheEntryTTL

func SetCacheEntryTTL(d time.Duration)

SetCacheEntryTTL sets how long an unaccessed cache entry lives before eviction. Must be called before InitCompatibilityCache to take effect.

func Upgrade

func Upgrade(cueStr string, targetVersion ...Version) (string, error)

Upgrade applies all registered upgrades to cueStr.

Types

type CUEUpgradeFunc

type CUEUpgradeFunc = pkgupgrade.CUEUpgradeFunc

CUEUpgradeFunc is a CUE compatibility fix triggered by the CUE language version.

type DefinitionKind

type DefinitionKind = pkgupgrade.DefinitionKind

DefinitionKind identifies the type of definition for metrics and compatibility reports.

const (
	WorkflowStepKind DefinitionKind = "WorkflowStep"
)

Workflow-specific DefinitionKind constants.

type KubeVelaUpgradeFunc

type KubeVelaUpgradeFunc = pkgupgrade.KubeVelaUpgradeFunc

KubeVelaUpgradeFunc is a CUE compatibility fix triggered by a KubeVela version.

type TemplateArea

type TemplateArea = pkgupgrade.TemplateArea

TemplateArea identifies which part of a definition's CUE template a rewrite was applied to.

const (
	TemplateAreaMain TemplateArea = "template"
)

Workflow-specific TemplateArea constants.

type UpgradeFunc

type UpgradeFunc = pkgupgrade.UpgradeFunc //nolint:revive

UpgradeFunc is a backward-compatible alias for KubeVelaUpgradeFunc.

type Version

type Version = pkgupgrade.Version

Version is a release version for upgrade ordering.

Jump to

Keyboard shortcuts

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