releaseupdater

package
v1.72.5 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManualApprovalRequired     = "manualApproval"
	DisruptionApprovalRequired = "disruptionApproval"
	RequirementsNotMet         = "requirementsNotMet"
	ReleaseQueueDepth          = "releaseQueueDepth"
	NotificationNotSent        = "notificationNotSent"
)
View Source
const (
	SubjectDeckhouse = "Deckhouse"
	SubjectModule    = "Module"
)
View Source
const D8ReleaseBlockedMetricName = "d8_release_info"
View Source
const (
	MigratedModulesRequirementFieldName = "migratedModules"
)
View Source
const ModuleReleaseBlockedMetricName = "d8_module_release_info"

Variables

View Source
var ErrReleaseIsAlreadyDeployed = errors.New("release is already deployed")
View Source
var ErrReleasePhaseIsNotPending = errors.New("release phase is not pending")

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Basic *BasicAuth `json:"basic,omitempty"`
	Token *string    `json:"bearerToken,omitempty"`
}

func (*Auth) Fill

func (a *Auth) Fill(req *http.Request)

type BasicAuth

type BasicAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ByVersion

type ByVersion[R v1alpha1.Release] []R

func (ByVersion[R]) Len

func (a ByVersion[R]) Len() int

func (ByVersion[R]) Less

func (a ByVersion[R]) Less(i, j int) bool

func (ByVersion[R]) Swap

func (a ByVersion[R]) Swap(i, j int)

type Check

type Check[T any] interface {
	GetName() string
	Verify(ctx context.Context, v *T) error
}

type Checker

type Checker[T any] struct {
	// contains filtered or unexported fields
}

func NewDeckhouseReleaseRequirementsChecker

func NewDeckhouseReleaseRequirementsChecker(k8sclient client.Client, enabledModules []string, exts *extenders.ExtendersStack, metricStorage metric.Storage, options ...CheckerOption) (*Checker[v1alpha1.DeckhouseRelease], error)

NewDeckhouseReleaseRequirementsChecker returns DeckhouseRelease checker with this checks:

1) deckhouse version check 2) deckhouse requirements check 3) deckhouse kubernetes version check 4) migrated modules check

for more checks information - look at extenders

func NewModuleReleaseRequirementsChecker

func NewModuleReleaseRequirementsChecker(exts *extenders.ExtendersStack, options ...CheckerOption) (*Checker[v1alpha1.ModuleRelease], error)

NewModuleReleaseRequirementsChecker returns ModuleRelease checker with this checks:

1) module release requirements check

for more checks information - look at extenders

func NewPreApplyChecker

func NewPreApplyChecker(settings *Settings, logger *log.Logger) *Checker[v1alpha1.Release]

NewPreApplyChecker returns Release checker with this checks:

1) disruption check

func (*Checker[T]) MetRequirements

func (c *Checker[T]) MetRequirements(ctx context.Context, v *T) []NotMetReason

type CheckerConfig added in v1.72.0

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

CheckerConfig holds configuration for a Checker

type CheckerOption added in v1.72.0

type CheckerOption func(*CheckerConfig)

CheckerOption represents an option for configuring a Checker

func WithLogger added in v1.72.0

func WithLogger(logger *log.Logger) CheckerOption

WithLogger sets the logger for the checker

type DeployDelayReason

type DeployDelayReason byte

func (DeployDelayReason) GoString

func (r DeployDelayReason) GoString() string

func (DeployDelayReason) IsNoDelay

func (r DeployDelayReason) IsNoDelay() bool

func (DeployDelayReason) Message

func (r DeployDelayReason) Message(release v1alpha1.Release, applyTime time.Time) string

func (DeployDelayReason) String

func (r DeployDelayReason) String() string

type DeployTimeResult

type DeployTimeResult struct {
	ReleaseApplyTime      time.Time
	ReleaseApplyAfterTime time.Time
	Reason                DeployDelayReason
}

type DeployTimeService

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

func NewDeployTimeService

func NewDeployTimeService(dc dependency.Container, settings *Settings, logger *log.Logger) *DeployTimeService

func (*DeployTimeService) CalculateMinorDeployTime

func (c *DeployTimeService) CalculateMinorDeployTime(release v1alpha1.Release, metricLabels MetricLabels) *DeployTimeResult

CalculatePatchDeployTime calculates deploy time, returns deploy time or postpone time and reason. To calculate deploy time, we need to check:

1) Cooldown (TODO: deprecated?) 1) Canary (in any mode, except "Manual") 2) Notify 3) Window (only in "Auto" mode) 4) Manual approve (in any mode, except "Auto")

Notify reason must override any other reason

func (*DeployTimeService) CalculatePatchDeployTime

func (c *DeployTimeService) CalculatePatchDeployTime(release v1alpha1.Release, metricLabels MetricLabels) *DeployTimeResult

CalculatePatchDeployTime calculates deploy time, returns deploy time or postpone time and reason. To calculate deploy time, we need to check:

1) Canary 2) Notify 3) Window (in not "Manual" mode) 4) Manual approve (only in "Manual" mode)

Notify reason must override any other reason

func (*DeployTimeService) ProcessMinorReleaseDeployTime

func (c *DeployTimeService) ProcessMinorReleaseDeployTime(release v1alpha1.Release, res *DeployTimeResult) *ProcessedDeployTimeResult

ProcessMinorReleaseDeployTime for minor release we check: - Deckhouse pod is ready - No delay from calculated deploy time

func (*DeployTimeService) ProcessPatchReleaseDeployTime

func (c *DeployTimeService) ProcessPatchReleaseDeployTime(release v1alpha1.Release, res *DeployTimeResult) *ProcessedDeployTimeResult

ProcessPatchReleaseDeployTime for patch release we check: - No delay from calculated deploy time

type MetricLabels

type MetricLabels map[string]string

func NewReleaseMetricLabels

func NewReleaseMetricLabels(release v1alpha1.Release) MetricLabels

func (MetricLabels) SetFalse

func (ml MetricLabels) SetFalse(key string)

func (MetricLabels) SetTrue

func (ml MetricLabels) SetTrue(key string)

type MetricsUpdater

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

func NewMetricsUpdater

func NewMetricsUpdater(metricStorage metric.Storage, metricName string) *MetricsUpdater

func (*MetricsUpdater) PurgeReleaseMetric

func (mu *MetricsUpdater) PurgeReleaseMetric(name string)

func (*MetricsUpdater) UpdateReleaseMetric

func (mu *MetricsUpdater) UpdateReleaseMetric(name string, metricLabels MetricLabels)

type NotMetReason

type NotMetReason struct {
	Reason  string
	Message string
}

type NotificationConfig

type NotificationConfig struct {
	WebhookURL              string          `json:"webhook"`
	SkipTLSVerify           bool            `json:"tlsSkipVerify"`
	MinimalNotificationTime libapi.Duration `json:"minimalNotificationTime"`
	Auth                    *Auth           `json:"auth,omitempty"`
	ReleaseType             ReleaseType     `json:"releaseType"`
}

func (*NotificationConfig) IsEmpty

func (cfg *NotificationConfig) IsEmpty() bool

type ProcessedDeployTimeResult

type ProcessedDeployTimeResult struct {
	Reason                DeployDelayReason
	Message               string
	ReleaseApplyAfterTime time.Time
}

type ReleaseInfo

type ReleaseInfo struct {
	Name    string
	Version *semver.Version
}

type ReleaseNotifier

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

func NewReleaseNotifier

func NewReleaseNotifier(settings *Settings) *ReleaseNotifier

func (*ReleaseNotifier) SendMinorReleaseNotification

func (u *ReleaseNotifier) SendMinorReleaseNotification(ctx context.Context, release v1alpha1.Release, applyTime time.Time, metricLabels MetricLabels) error

func (*ReleaseNotifier) SendPatchReleaseNotification

func (u *ReleaseNotifier) SendPatchReleaseNotification(ctx context.Context, release v1alpha1.Release, applyTime time.Time, metricLabels MetricLabels) error

SendPatchReleaseNotification sending patch notification (only if notification config has release type "All")

type ReleaseQueueDepthDelta added in v1.72.0

type ReleaseQueueDepthDelta struct {
	Major int // Major versions delta, not used right now, for future usage
	Minor int // Minor versions delta
	Patch int // Patch versions delta
}

ReleaseQueueDepthDelta represents the difference between deployed and latest releases

func (*ReleaseQueueDepthDelta) GetReleaseQueueDepth added in v1.72.0

func (d *ReleaseQueueDepthDelta) GetReleaseQueueDepth() int

GetReleaseQueueDepth calculates the effective queue depth for monitoring and alerting purposes. This method transforms the internal delta representation into a simplified metric value that represents how many releases are pending deployment.

Queue depth calculation logic:

  • If minor version differences exist: return the minor delta count
  • If only patch version differences exist: return 1 (normalized patch indicator)
  • If no differences exist: return 0 (up to date)

The function prioritizes minor version gaps over patch version gaps because:

  1. Minor version updates typically contain more significant changes
  2. Multiple patch versions are normalized to a single indicator (1)
  3. This provides a cleaner metric for alerting thresholds

Examples:

  • Delta{Major: 0, Minor: 3, Patch: 0} → Returns: 3 (3 minor versions behind)
  • Delta{Major: 0, Minor: 0, Patch: 5} → Returns: 1 (patch updates available, normalized)
  • Delta{Major: 1, Minor: 2, Patch: 0} → Returns: 2 (focuses on minor gap, major handled separately)
  • Delta{Major: 0, Minor: 0, Patch: 0} → Returns: 0 (up to date)

Note: Major version deltas are intentionally excluded from this calculation. A separate alerting mechanism is planned for major version updates due to their potentially breaking nature and different handling requirements.

type ReleaseType

type ReleaseType string
const (
	ReleaseTypeMinor ReleaseType = "Minor"
	ReleaseTypeAll   ReleaseType = "All"
)

type RequirementsChecker

type RequirementsChecker[T any] interface {
	MetRequirements(ctx context.Context, v *T) []NotMetReason
}

type Settings

type Settings struct {
	NotificationConfig     NotificationConfig
	DisruptionApprovalMode string
	Mode                   v1alpha2.UpdateMode
	Windows                update.Windows
	Subject                string
}

func (*Settings) InDisruptionApprovalMode

func (s *Settings) InDisruptionApprovalMode() bool

func (*Settings) InManualMode

func (s *Settings) InManualMode() bool

type StatusPatch

type StatusPatch v1alpha1.DeckhouseReleaseStatus

TODO: replace patch marshalling with controller-runtime patch

func (StatusPatch) MarshalJSON

func (sp StatusPatch) MarshalJSON() ([]byte, error)

type Task

type Task struct {
	TaskType TaskType
	Message  string

	IsPatch  bool
	IsSingle bool
	IsLatest bool

	DeployedReleaseInfo *ReleaseInfo
	QueueDepth          *ReleaseQueueDepthDelta
}

type TaskCalculator

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

func NewDeckhouseReleaseTaskCalculator

func NewDeckhouseReleaseTaskCalculator(k8sclient client.Client, logger *log.Logger, releaseChannel string) *TaskCalculator

func NewModuleReleaseTaskCalculator

func NewModuleReleaseTaskCalculator(k8sclient client.Client, logger *log.Logger) *TaskCalculator

func (*TaskCalculator) CalculatePendingReleaseTask

func (p *TaskCalculator) CalculatePendingReleaseTask(ctx context.Context, release v1alpha1.Release) (*Task, error)

CalculatePendingReleaseTask determines the appropriate action for a pending release within the context of all available releases. This is the main orchestration function that evaluates release precedence, version constraints, and deployment readiness to produce a task decision.

Decision Flow Architecture:

  1. Validation: Ensure release is in pending state
  2. Force Release Check: Handle administratively forced releases
  3. Deployed Release Analysis: Consider currently deployed version
  4. Constraint Evaluation: Check for version jumping opportunities
  5. Sequential Logic: Apply standard version progression rules
  6. Neighbor Analysis: Determine if release should process or wait

Task Types Returned:

  • Skip: Release should be bypassed (superseded by force/deployed/newer release)
  • Await: Release must wait for dependencies (previous releases, constraints)
  • Process: Release is ready for deployment

Key Features:

  • Version Jumping: Supports constraint-based skipping of intermediate releases
  • Channel-aware Logic: Different rules for LTS vs regular channels
  • Major Version Control: Special handling for 0→1 transitions vs breaking changes
  • Queue Depth Calculation: Provides metrics for monitoring and alerting
  • Force Release Priority: Administrative overrides take precedence

Version Progression Rules:

  1. FORCE RELEASE: Always takes precedence, skips any lower versions
  2. DEPLOYED VERSION: Cannot deploy older than currently deployed
  3. MAJOR VERSION RESTRICTIONS: - 0→1: Allowed (development to stable transition) - 1→2+: Blocked (requires manual intervention)
  4. MINOR VERSION LIMITS: - Regular channels: Sequential (+1 minor at a time) - LTS channels: Up to +10 minor versions allowed
  5. PATCH VERSIONS: No restrictions, highest patch wins

Constraint-Based Version Jumping:

When update constraints are present, releases can jump to specified endpoints:
- Deployed: 1.67.5, Constraint: {from: "1.67", to: "1.70"}
- Result: Direct jump to 1.70.x (highest patch), skipping 1.68.x, 1.69.x
- Endpoint releases are processed as minor updates (not patches)

Examples:

Scenario 1 - Force Release Override:
Input: Pending v1.68.0, Force v1.70.0 exists
Result: Skip (v1.68.0 < v1.70.0)

Scenario 2 - Sequential Minor Update:
Input: Pending v1.68.0, Deployed v1.67.5, No constraints
Result: Process (valid +1 minor progression)

Scenario 3 - Major Version Block:
Input: Pending v2.0.0, Deployed v1.67.5
Result: Await (major version jump requires manual approval)

Scenario 4 - Constraint Jumping:
Input: Pending v1.70.0, Deployed v1.67.5, Constraint: {from: "1.67", to: "1.70"}
Result: Process (constraint allows jumping to v1.70.0)

Scenario 5 - Patch Priority:
Input: Pending v1.67.3, Next v1.67.5 exists
Result: Skip (higher patch available)

Queue Depth Calculation:

  • Counts releases between current and latest (max 3 for alerting)
  • Used for monitoring release lag and alert thresholds
  • Includes current release in count (off-by-one correction)

Channel-Specific Behavior:

  • Regular Channels: Strict +1 minor version progression
  • LTS Channels: Allow up to +10 minor version jumps for stability
  • All Channels: No restrictions on patch version progression

type TaskType

type TaskType int
const (
	Skip TaskType = iota
	Await
	Process
)

type WebhookData

type WebhookData struct {
	Subject       string            `json:"subject"`
	Version       string            `json:"version"`
	Requirements  map[string]string `json:"requirements,omitempty"`
	ChangelogLink string            `json:"changelogLink,omitempty"`

	ApplyTime string `json:"applyTime,omitempty"`
	Message   string `json:"message"`
}

Jump to

Keyboard shortcuts

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