Skip to content

Error is logged even if result of status.Preflight doesn't have one #374

Closed
@tomasaschan

Description

@tomasaschan

What happened:

I implemented a custom declarative.Status like this:

type myStatus {}

func (myStatus) Preflight(ctx context.Context, o declarative.DeclarativeObject) error {
    // omitted: some precondition is not fulfilled
    // want to requeue with backoff and try again after some other controller has had a chance to make the precondition true
    return declarative.ErrorResult{
        Result: result.Result{Requeue: true},
        // note: Err: nil implied here
    }
}

func NewMyStatus() declarative.Status {
    return declarative.StatusBuilder{
        Preflight: myStatus{},
    }
}

When my controller reconciles with this, it logs "preflight check failed, not reconciling" with a stack trace that doesn't point to anywhere in my own code. That's annoying and a little confusing.

What you expected to happen: reconciliation is requeued without any errors logged.

How to reproduce it (as minimally and precisely as possible):

Create a declarative controller with a status implementation like the above, reconcile an instance and observe logs.

Anything else we need to know?:

This seems related to, but is different from #232. I imagine if my status also had a Reconcile function, it would be confusing that it gets called even though the preflight check failed (signalled by returning a non-nil result, even if that result has a nil Err). That, in turn, happens because this deferred function doesn't check for the preflight result. (It seems it once did check, but it's unclear to me why that was removed...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions