Skip to content

Ready status is true when outputs fail to apply #75

@colinodell

Description

@colinodell

tl;dr:

Whenever the fsmReconciler fails to applyOutputs(), the object's Ready status is always unexpectedly True 🙀

Details

The "Ready" condition's status is always set to:

  • True if all other conditions are True; or,
  • False if any other condition is False

However, when the fsmReconciler fails to applyOutputs(), no False condition is ever set within the returned conditions!

if err := r.applyOutputs(ctx, log, obj, out); err != nil {
return obj, conditions, types.ErrorResult(fmt.Errorf("applying outputs: %w", err))
}
// accumulate status conditions, overwrites duplicate conditions with those of later states
if !condition.IsEmpty() {
conditions.SetConditions(condition)
}

As a result, the resource's Ready status will always show as True despite this failure.

Proposed Fix

All other code paths through the main loop seem to apply the current condition to conditions before returning:

  • When the result is not done:

    // mark the state's condition as failed if not done or the state signals a requeue after FSM completion
    if !result.IsDone() {
    // falsify condition if provided, set message and reason
    if !condition.IsEmpty() {
    condition.Status = corev1.ConditionFalse
    condition.Message, condition.Reason = result.GetMessageAndReason()
    conditions.SetConditions(condition)
    }
    return obj, conditions, result.WrapError(fmt.Sprintf("transitioning state %q", currentState.Name))

  • When the result is done, and the outputs are applied successfully:

    // accumulate status conditions, overwrites duplicate conditions with those of later states
    if !condition.IsEmpty() {
    conditions.SetConditions(condition)
    }

So perhaps failures applying outputs should take any non-empty condition and:

  • Falsify the status
  • Set the reason and message to something indicating the failure to apply resources
  • Set that onto conditions before returning

That would align the condition handling with the other code paths and ensure that output failures don't cause the resource to report an "incorrect" status of being ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions