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:
Standalone workflow controller: the workflow binary sets GetCurrentVersion in its own init() and owns the version provider.
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 ¶
- Variables
- func EnsureCueVersionCompatibility(cueStr, defName string, defKind DefinitionKind, area TemplateArea) (string, bool)
- func InitCompatibilityCache(ctx context.Context, size int)
- func RequiresUpgrade(cueStr string, targetVersion ...Version) (bool, []string, error)
- func SetCacheEntryTTL(d time.Duration)
- func Upgrade(cueStr string, targetVersion ...Version) (string, error)
- type CUEUpgradeFunc
- type DefinitionKind
- type KubeVelaUpgradeFunc
- type TemplateArea
- type UpgradeFunc
- type Version
Constants ¶
This section is empty.
Variables ¶
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 )
var ( ParseVersion = pkgupgrade.ParseVersion RegisterUpgrade = pkgupgrade.RegisterUpgrade GetSupportedVersions = pkgupgrade.GetSupportedVersions )
Re-export functions.
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)
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"
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"
var CompatibilityCacheSize = pkgupgrade.CompatibilityCacheSize
CompatibilityCacheSize mirrors pkgupgrade.CompatibilityCacheSize.
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 ¶
InitCompatibilityCache reinitialises the LRU cache.
func RequiresUpgrade ¶
RequiresUpgrade checks whether cueStr needs upgrading.
func SetCacheEntryTTL ¶
SetCacheEntryTTL sets how long an unaccessed cache entry lives before eviction. Must be called before InitCompatibilityCache to take effect.
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.