Skip to content

Commit

Permalink
Merge pull request #339 from werf/fix-prioiritize-readiness-over-fail…
Browse files Browse the repository at this point in the history
…ure-low-level

fix(readiness): prioritize readiness over failure in all low-level trackers
  • Loading branch information
ilya-lesikov authored Feb 28, 2024
2 parents 7dddbbb + 9834fbd commit f5059e3
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
12 changes: 6 additions & 6 deletions pkg/tracker/canary/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,24 @@ func (canary *Tracker) handleCanaryState(ctx context.Context, object *v1beta1.Ca
switch canary.State {
case tracker.Initial:
switch {
case status.IsFailed:
canary.State = tracker.ResourceFailed
canary.Failed <- status
case status.IsSucceeded:
canary.State = tracker.ResourceSucceeded
canary.Succeeded <- status
case status.IsFailed:
canary.State = tracker.ResourceFailed
canary.Failed <- status
default:
canary.State = tracker.ResourceAdded
canary.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
canary.State = tracker.ResourceFailed
canary.Failed <- status
case status.IsSucceeded:
canary.State = tracker.ResourceSucceeded
canary.Succeeded <- status
case status.IsFailed:
canary.State = tracker.ResourceFailed
canary.Failed <- status
default:
canary.Status <- status
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/tracker/daemonset/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,37 +423,37 @@ func (d *Tracker) handleDaemonSetState(ctx context.Context, object *appsv1.Daemo
}

switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.Status <- status
}
case tracker.ResourceSucceeded:
d.Status <- status
case tracker.ResourceDeleted:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
Expand Down
18 changes: 9 additions & 9 deletions pkg/tracker/deployment/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,37 +565,37 @@ func (d *Tracker) handleDeploymentState(ctx context.Context, object *appsv1.Depl
}

switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.Status <- status
}
case tracker.ResourceSucceeded:
d.Status <- status
case tracker.ResourceDeleted:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
Expand Down
18 changes: 9 additions & 9 deletions pkg/tracker/job/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,37 +306,37 @@ func (job *Tracker) handleJobState(ctx context.Context, object *batchv1.Job) err
}

switch {
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
case status.IsSucceeded:
job.State = tracker.ResourceSucceeded
job.Succeeded <- status
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
default:
job.State = tracker.ResourceAdded
job.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
case status.IsSucceeded:
job.State = tracker.ResourceSucceeded
job.Succeeded <- status
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
default:
job.Status <- status
}
case tracker.ResourceSucceeded:
job.Status <- status
case tracker.ResourceDeleted:
switch {
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
case status.IsSucceeded:
job.State = tracker.ResourceSucceeded
job.Succeeded <- status
case status.IsFailed:
job.State = tracker.ResourceFailed
job.Failed <- status
default:
job.State = tracker.ResourceAdded
job.Added <- status
Expand Down
24 changes: 12 additions & 12 deletions pkg/tracker/pod/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,57 +327,57 @@ func (pod *Tracker) handlePodState(ctx context.Context, object *corev1.Pod) erro
switch pod.State {
case tracker.Initial:
switch {
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
case status.IsSucceeded:
pod.State = tracker.ResourceSucceeded
pod.Succeeded <- status
case status.IsReady:
pod.State = tracker.ResourceReady
pod.Ready <- status
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
default:
pod.State = tracker.ResourceAdded
pod.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
case status.IsSucceeded:
pod.State = tracker.ResourceSucceeded
pod.Succeeded <- status
case status.IsReady:
pod.State = tracker.ResourceReady
pod.Ready <- status
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
default:
pod.Status <- status
}
case tracker.ResourceSucceeded:
pod.Status <- status
case tracker.ResourceReady:
switch {
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
case status.IsSucceeded:
pod.State = tracker.ResourceSucceeded
pod.Succeeded <- status
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
default:
pod.Status <- status
}
case tracker.ResourceDeleted:
switch {
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
case status.IsSucceeded:
pod.State = tracker.ResourceSucceeded
pod.Succeeded <- status
case status.IsReady:
pod.State = tracker.ResourceReady
pod.Ready <- status
case status.IsFailed:
pod.State = tracker.ResourceFailed
pod.Failed <- FailedReport{PodStatus: status, FailedReason: status.FailedReason}
default:
pod.State = tracker.ResourceAdded
pod.Added <- status
Expand Down
18 changes: 9 additions & 9 deletions pkg/tracker/statefulset/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,37 +424,37 @@ func (d *Tracker) handleStatefulSetState(ctx context.Context, object *appsv1.Sta
}

switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
}
case tracker.ResourceAdded, tracker.ResourceFailed:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.Status <- status
}
case tracker.ResourceSucceeded:
d.Status <- status
case tracker.ResourceDeleted:
switch {
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
case status.IsReady:
d.State = tracker.ResourceReady
d.Ready <- status
case status.IsFailed:
d.State = tracker.ResourceFailed
d.Failed <- status
default:
d.State = tracker.ResourceAdded
d.Added <- status
Expand Down

0 comments on commit f5059e3

Please sign in to comment.