Documentation
¶
Overview ¶
Package upgrade provides CUE version-compatibility helpers for KubeVela. The core engine lives in github.com/kubevela/pkg/cue/upgrade; this package wires KubeVela-specific concerns (version provider, Prometheus metrics) and re-exports the public API so existing call sites need no import change.
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 )
var CUECompatCacheEvictionsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "kubevela_cue_compat_cache_evictions_total", Help: "Total number of CUE compatibility cache evictions, 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)
A sustained capacity eviction rate means the working set exceeds cache size; increase --cue-compatibility-cache-size or migrate definitions to compliant CUE syntax (run `vela def compat` to identify which definitions need remediation).
var CUECompatRewriteTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "kubevela_cue_compat_rewrite_total", Help: "Total number of CUE compatibility rewrites applied at 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. "Component"
- template_area: which part of the definition was rewritten, e.g. "template", "health"
Use this metric to track which legacy syntax fixes are still active cluster-wide. The metric is the smoke detector; run `vela def compat definitions` to identify which specific definitions need remediation.
var CUECompatUpgradeDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "kubevela_cue_compat_upgrade_duration_seconds", Help: "Duration of CUE version compatibility checks at 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. "Component"
Use histogram_quantile() in PromQL to compute aggregated latency percentiles across replicas. Cache hits are not recorded — they are too cheap to be meaningful.
var CompatibilityCacheSize = pkgupgrade.CompatibilityCacheSize
var EnableCUEVersionCompatibility = &pkgupgrade.EnableCUEVersionCompatibility
Functions ¶
func EnsureCueVersionCompatibility ¶
func EnsureCueVersionCompatibility(cueStr, defName string, defKind DefinitionKind, area TemplateArea) (string, bool)
func InitCompatibilityCache ¶
func RequiresUpgrade ¶
func SetCacheEntryTTL ¶
Types ¶
type CUEUpgradeFunc ¶
type CUEUpgradeFunc = pkgupgrade.CUEUpgradeFunc
type DefinitionKind ¶
type DefinitionKind = pkgupgrade.DefinitionKind
const ( ComponentKind DefinitionKind = "Component" TraitKind DefinitionKind = "Trait" PolicyKind DefinitionKind = "Policy" WorkflowStepKind DefinitionKind = "WorkflowStep" )
type KubeVelaUpgradeFunc ¶
type KubeVelaUpgradeFunc = pkgupgrade.KubeVelaUpgradeFunc
type TemplateArea ¶
type TemplateArea = pkgupgrade.TemplateArea
const ( TemplateAreaMain TemplateArea = "template" TemplateAreaHealth TemplateArea = "health" TemplateAreaCustomStatus TemplateArea = "custom_status" TemplateAreaStatusDetail TemplateArea = "status_detail" )
type UpgradeFunc ¶
type UpgradeFunc = pkgupgrade.UpgradeFunc //nolint:revive
type Version ¶
type Version = pkgupgrade.Version