Skip to content

Commit

Permalink
Using a different Reason to reflect better the state.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Filho committed Oct 25, 2023
1 parent 96a6711 commit c47aa79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const (
TargetClusterNotReadyReason string = "TargetClusterNotReady"
// ReconciliationSucceededReason signals that a Pipeline has been successfully reconciled.
ReconciliationSucceededReason string = "ReconciliationSucceeded"
// TargetDifferentRevisionReason signals there are targets with different revisions.
TargetDifferentRevisionReason string = "TargetDifferentRevision"
// EnvironmentNotReadyReason signals the environment is not ready.
EnvironmentNotReadyReason string = "EnvironmentNotReady"
)

// Reasons used by the level-triggered controller.
Expand Down
4 changes: 2 additions & 2 deletions controllers/leveltriggered/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (r *PipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
latestRevision := checkAllTargetsHaveSameRevision(pipeline.Status.Environments[firstEnv.Name])
if latestRevision == "" {
// not all targets have the same revision, or have no revision set, so we can't proceed
if err := r.setPendingCondition(ctx, pipeline, v1alpha1.TargetDifferentRevisionReason, "Waiting for all targets to have the same revision"); err != nil {
if err := r.setPendingCondition(ctx, pipeline, v1alpha1.EnvironmentNotReadyReason, "Waiting for all targets to have the same revision"); err != nil {
return ctrl.Result{Requeue: true}, fmt.Errorf("error setting pending condition: %w", err)
}

Expand All @@ -199,7 +199,7 @@ func (r *PipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c

if !checkAllTargetsAreReady(pipeline.Status.Environments[firstEnv.Name]) {
// not all targets are ready, so we can't proceed
if err := r.setPendingCondition(ctx, pipeline, v1alpha1.TargetClusterNotReadyReason, "Waiting for all targets to be ready"); err != nil {
if err := r.setPendingCondition(ctx, pipeline, v1alpha1.EnvironmentNotReadyReason, "Waiting for all targets to be ready"); err != nil {
return ctrl.Result{}, fmt.Errorf("error setting pending condition: %w", err)
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/leveltriggered/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ func TestReconcile(t *testing.T) {

g.Expect(k8sClient.Create(ctx, pipeline)).To(Succeed())
checkCondition(ctx, g, client.ObjectKeyFromObject(pipeline), meta.ReadyCondition, metav1.ConditionTrue, v1alpha1.ReconciliationSucceededReason)
checkCondition(ctx, g, client.ObjectKeyFromObject(pipeline), pipelineconditions.PromotionPendingCondition, metav1.ConditionTrue, v1alpha1.TargetDifferentRevisionReason)
checkCondition(ctx, g, client.ObjectKeyFromObject(pipeline), pipelineconditions.PromotionPendingCondition, metav1.ConditionTrue, v1alpha1.EnvironmentNotReadyReason)

setAppRevision(ctx, g, devApp2, "v1.0.0")
checkCondition(ctx, g, client.ObjectKeyFromObject(pipeline), pipelineconditions.PromotionPendingCondition, metav1.ConditionTrue, v1alpha1.TargetClusterNotReadyReason)
checkCondition(ctx, g, client.ObjectKeyFromObject(pipeline), pipelineconditions.PromotionPendingCondition, metav1.ConditionTrue, v1alpha1.EnvironmentNotReadyReason)

setAppStatusReadyCondition(ctx, g, devApp2)

Expand Down

0 comments on commit c47aa79

Please sign in to comment.