Orange-OpenSource / nifikop

The NiFiKop NiFi Kubernetes operator makes it easy to run Apache NiFi on Kubernetes. Apache NiFI is a free, open-source solution that support powerful and scalable directed graphs of data routing, transformation, and system mediation logic.
https://orange-opensource.github.io/nifikop/
Apache License 2.0
128 stars 34 forks source link

NiFiKop Dataflow controller gets stuck in endless reconciliation failure loop #142

Closed mh013370 closed 2 years ago

mh013370 commented 2 years ago

Bug Report

Scenario: Provision a dataflow version controlled in NiFi Registry which does not require any parameters via the parameter context.

Bug: It's not possible to configure an empty parameter context with a dataflow. If you do attempt to configure an empty parameter context, the nifikop Dataflow controller finds itself in an infinite failing reconciliation loop. The NiFiParameterContext attributes parameters and secretRefs are documented as optional, but if you don't provide them (or at least provide 1 property) then the operator finds itself in this failure loop.

https://orange-opensource.github.io/nifikop/docs/5_references/4_nifi_parameter_context#nifiparametercontextsspec

One issue is despite parameters being documented as optional, you must actually provide at least an empty list or resource creation fails. You need not provide a secretRefs. Additionally, if you provide an empty list for parameters, then understandably nifikop does not create a ParameterContext in NiFi. Due to this, when nifikop actually deploys the dataflow (the creation of which succeeds), it cannot subsequently reconcile the state since there's no parameter context configured in NiFi -- empty or otherwise.

Basically, when there's no parameter context in NiFi then the operator can't reconcile the state of the dataflow deployed.

I'd consider this low priority and easily avoidable by providing a dummy property in the parameter context, but it is a bug nonetheless. Perhaps NiFiParameterContext should enforce that at least one property is provided or, if possible, create an empty Parameter Context in NiFi.

What did you do? A clear and concise description of the steps you took (or insert a code snippet).

Create a NiFiParameterContext:

apiVersion: nifi.orange.com/v1alpha1
kind: NifiParameterContext
metadata:
  name: nc-parameter-context
spec:
  description: "NiFi Cluster Parameter Context"
  clusterRef:
    name: nc
    namespace: ns
  parameters: []

and a NiFiDataFlow referencing this parameter context.

What did you expect to see?

NiFiKop correctly deploys the dataflow and reconciles the state.

What did you see instead? Under which circumstances?

Nifikop does create the dataflow in the NiFi canvas and connect to NiFiRegistry to fetch the flow. However, because the NiFiParameterContext contains no properties it does not create a parameter context in NiFi itself. This causes the nifikop dataflow controller to endlessly loop in reconciliation, never resolving the dataflow state.

This start of the issue is here: https://github.com/Orange-OpenSource/nifikop/blob/master/controllers/nifidataflow_controller.go#L133

And then the operator logs these two messages endlessly:

"Failing" https://github.com/Orange-OpenSource/nifikop/blob/master/controllers/nifidataflow_controller.go#L269

"Synchronizing" https://github.com/Orange-OpenSource/nifikop/blob/master/controllers/nifidataflow_controller.go#L329

Environment

Possible Solution

Perhaps NiFiParameterContext should enforce that at least one property is provided or, if possible, create an empty Parameter Context in NiFi.

mh013370 commented 2 years ago

This might be fixed by #144 , but i have not verified.

mh013370 commented 2 years ago

I'm going to close this because i don't believe it's a problem any longer.