Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1alpha1/rollout_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const (
)

const (
BakeStatusPending = "Pending"
BakeStatusDeploying = "Deploying"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: existing "Pending" status resources become orphaned

The constant BakeStatusPending was renamed to BakeStatusDeploying but the string value also changed from "Pending" to "Deploying". Existing Rollout resources in Kubernetes with BakeStatus: "Pending" stored in etcd will no longer be recognized by the controller's switch statements that now check for "Deploying". This causes handleBakeTime to be skipped for those resources, potentially leaving them stuck in an unrecognized state without proper bake time handling. To safely rename while maintaining backward compatibility, the value should remain "Pending" or migration logic is needed.

Additional Locations (2)

Fix in Cursor Fix in Web

BakeStatusInProgress = "InProgress"
BakeStatusSucceeded = "Succeeded"
BakeStatusFailed = "Failed"
Expand Down
20 changes: 10 additions & 10 deletions internal/controller/rollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *RolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

Check failure on line 105 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 65 of func `(*RolloutReconciler).Reconcile` is high (> 30) (gocyclo)

Check failure on line 105 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 65 of func `(*RolloutReconciler).Reconcile` is high (> 30) (gocyclo)
log := logf.FromContext(ctx)

rollout := rolloutv1alpha1.Rollout{}
Expand Down Expand Up @@ -154,7 +154,7 @@
bakeStatus := rollout.Status.History[0].BakeStatus
if bakeStatus != nil {
switch *bakeStatus {
case rolloutv1alpha1.BakeStatusPending, rolloutv1alpha1.BakeStatusInProgress:
case rolloutv1alpha1.BakeStatusDeploying, rolloutv1alpha1.BakeStatusInProgress:
result, err := r.handleBakeTime(ctx, req.Namespace, &rollout)
if err != nil {
return result, err
Expand All @@ -178,7 +178,7 @@
// For automatic deployments, block if bake is still pending or in progress
if !r.hasManualDeployment(&rollout) && len(rollout.Status.History) > 0 && rollout.Status.History[0].BakeStatus != nil {
currentBakeStatus := *rollout.Status.History[0].BakeStatus
if currentBakeStatus == rolloutv1alpha1.BakeStatusPending || currentBakeStatus == rolloutv1alpha1.BakeStatusInProgress {
if currentBakeStatus == rolloutv1alpha1.BakeStatusDeploying || currentBakeStatus == rolloutv1alpha1.BakeStatusInProgress {
return result, nil
}
}
Expand All @@ -195,7 +195,7 @@
// Check if user has requested to unblock failed deployment via annotation
unblockRequested := false
if rollout.Annotations != nil {
if unblock, exists := rollout.Annotations["rollout.kuberik.com/unblock-failed"]; exists && unblock == "true" {

Check failure on line 198 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

string `true` has 4 occurrences, make it a constant (goconst)

Check failure on line 198 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

string `true` has 4 occurrences, make it a constant (goconst)
unblockRequested = true
log.Info("User requested to unblock failed deployment via annotation")
}
Expand Down Expand Up @@ -480,7 +480,7 @@
}

// parseOCIManifest extracts all metadata from OCI image manifest including version, revision, artifact type, source, title, and description.
func (r *RolloutReconciler) parseOCIManifest(ctx context.Context, imageRef string, imagePolicy *imagev1beta2.ImagePolicy) (version, revision, artifactType, source, title, description *string, created *metav1.Time, err error) {

Check failure on line 483 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 48 of func `(*RolloutReconciler).parseOCIManifest` is high (> 30) (gocyclo)

Check failure on line 483 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 48 of func `(*RolloutReconciler).parseOCIManifest` is high (> 30) (gocyclo)
log := logf.FromContext(ctx)

// Get authentication keychain from ImageRepository
Expand Down Expand Up @@ -719,7 +719,7 @@
}

// evaluateGates lists and evaluates gates, updates rollout status, and returns filtered candidates and gatesPassing.
func (r *RolloutReconciler) evaluateGates(ctx context.Context, namespace string, rollout *rolloutv1alpha1.Rollout, releaseCandidates []rolloutv1alpha1.VersionInfo) ([]rolloutv1alpha1.VersionInfo, bool, error) {

Check failure on line 722 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 32 of func `(*RolloutReconciler).evaluateGates` is high (> 30) (gocyclo)

Check failure on line 722 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 32 of func `(*RolloutReconciler).evaluateGates` is high (> 30) (gocyclo)
// Check for gate bypass annotation
bypassVersion := ""
if rollout.Annotations != nil {
Expand Down Expand Up @@ -1071,7 +1071,7 @@
}

// deployRelease finds and patches Flux resources with the wanted version.
func (r *RolloutReconciler) deployRelease(ctx context.Context, rollout *rolloutv1alpha1.Rollout, wantedRelease string) error {

Check failure on line 1074 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 45 of func `(*RolloutReconciler).deployRelease` is high (> 30) (gocyclo)

Check failure on line 1074 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 45 of func `(*RolloutReconciler).deployRelease` is high (> 30) (gocyclo)
log := logf.FromContext(ctx)

// Check if this deployment was done with gate bypass
Expand Down Expand Up @@ -1107,7 +1107,7 @@
// Cancel any existing pending or in-progress bake before starting new deployment
if len(rollout.Status.History) > 0 && rollout.Status.History[0].BakeStatus != nil {
currentBakeStatus := *rollout.Status.History[0].BakeStatus
if currentBakeStatus == rolloutv1alpha1.BakeStatusPending || currentBakeStatus == rolloutv1alpha1.BakeStatusInProgress {
if currentBakeStatus == rolloutv1alpha1.BakeStatusDeploying || currentBakeStatus == rolloutv1alpha1.BakeStatusInProgress {
log.Info("Cancelling existing bake due to new deployment", "previousVersion", rollout.Status.History[0].Version, "previousStatus", currentBakeStatus)
rollout.Status.History[0].BakeStatus = k8sptr.To(rolloutv1alpha1.BakeStatusCancelled)
rollout.Status.History[0].BakeStatusMessage = k8sptr.To("Bake cancelled due to new deployment.")
Expand Down Expand Up @@ -1153,14 +1153,14 @@
bakeStatus = k8sptr.To(rolloutv1alpha1.BakeStatusSucceeded)
bakeStatusMsg = k8sptr.To("No bake time configured, deployment completed immediately.")
} else {
// Bake time configured - initially set to Pending until healthchecks are healthy
// Bake time configured - initially set to Deploying until healthchecks are healthy
// BakeStartTime will be set later when healthchecks become healthy and bake actually starts
bakeStatus = k8sptr.To(rolloutv1alpha1.BakeStatusPending)
bakeStatus = k8sptr.To(rolloutv1alpha1.BakeStatusDeploying)
bakeStatusMsg = k8sptr.To("Waiting for health checks to become healthy before starting bake.")

// Emit event for bake time start
if r.Recorder != nil {
r.Recorder.Event(rollout, corev1.EventTypeNormal, "BakeTimePending", "Bake time pending, waiting for health checks to become healthy before starting bake.")
r.Recorder.Event(rollout, corev1.EventTypeNormal, "BakeTimeDeploying", "Bake time deploying, waiting for health checks to become healthy before starting bake.")
}
}

Expand Down Expand Up @@ -1459,7 +1459,7 @@
return nil
}

func (r *RolloutReconciler) handleBakeTime(ctx context.Context, namespace string, rollout *rolloutv1alpha1.Rollout) (ctrl.Result, error) {

Check failure on line 1462 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 41 of func `(*RolloutReconciler).handleBakeTime` is high (> 30) (gocyclo)

Check failure on line 1462 in internal/controller/rollout_controller.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

cyclomatic complexity 41 of func `(*RolloutReconciler).handleBakeTime` is high (> 30) (gocyclo)
log := logf.FromContext(ctx)
now := r.now()

Expand All @@ -1468,12 +1468,12 @@
}

currentEntry := &rollout.Status.History[0]
// Handle both Pending and InProgress statuses
// Handle both Deploying and InProgress statuses
if currentEntry.BakeStatus == nil {
return ctrl.Result{}, nil
}
bakeStatus := *currentEntry.BakeStatus
if bakeStatus != rolloutv1alpha1.BakeStatusPending && bakeStatus != rolloutv1alpha1.BakeStatusInProgress {
if bakeStatus != rolloutv1alpha1.BakeStatusDeploying && bakeStatus != rolloutv1alpha1.BakeStatusInProgress {
return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -1624,7 +1624,7 @@
// All healthchecks are healthy and LastChangeTime is newer than deployment time - start bake
log.Info("All health checks are healthy, starting bake")
currentEntry.BakeStartTime = &metav1.Time{Time: now}
// Transition from Pending to InProgress when bake actually starts
// Transition from Deploying to InProgress when bake actually starts
currentEntry.BakeStatus = k8sptr.To(rolloutv1alpha1.BakeStatusInProgress)
bakeStartMsg := "Bake started, monitoring for errors."
currentEntry.BakeStatusMessage = &bakeStartMsg
Expand Down Expand Up @@ -1824,7 +1824,7 @@
}

switch *entry.BakeStatus {
case rolloutv1alpha1.BakeStatusPending:
case rolloutv1alpha1.BakeStatusDeploying:
return "Waiting for health checks to become healthy before starting bake"
case rolloutv1alpha1.BakeStatusInProgress:
if entry.BakeStartTime != nil {
Expand Down
Loading
Loading