Skip to content

Controller create/update handling called even if exception when applying finalizer  #310

Closed
@ppatierno

Description

@ppatierno

Due to a different problem that I have to figure out, I noticed the following possibly wrong behavior of the sdk ...
I apply the custom resource handled by my controller and the handleDispatch reaches the point where a finalizer is applied to the resource itself. At that point an exception happens (in my case a 404 NOT FOUND) and the handleExecution of the dispatcher is executed and the execution ends (without calling the createOrUpdateResource of my controller which is ok).
AFAIK the operator sdk has a retry logic so the event is handled again but at this point in the handleCreateOrUpdate the ControllerUtils.hasGivenFinalizer return true because the resource (is it in a cache of the operator sdk?) has the finalizer in the metadata even if the corresponding apply in the previous step was failed against the Kubernetes cluster.
Due to the fact that the finalizer is there, the operator sdk goes ahead handling the event calling the createOrUpdateResource of the controller.
I guess it's wrong, because applying the finalizer didn't end well actually due to a problem that could be of any type and could happen even in the controller.

Metadata

Metadata

Assignees

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