When I download versioned flows from NiFi Registry, sometimes it does not connect processors to controller services even though one exists in scope and it has the same name as the one it was originally connected to.
NiFi downloads versioned process groups and connects external controller services correctly provided that a compatible controller service is available and has the same name.
NiFi downloads versioned flows but does not connect all external controller services.
- Upload the attached template to your NiFi
- Ensure the necessary Controller Services exist at the ROOT process group.
- Resolve all warnings on processors, maybe need to connect the above controller services.
- Start version control on "Inner Versioned Flow"
- Start version control on "Outer Versioned Flow"
- Clear Canvas
- Delete and Recreate the Controller Services
- Import "Outer Versioned Flow" from your registry
You should observe that one processor in Inner Versioned Flow is invalid because it wasn't connected to an existing controller service and that the other processor is valid because by coincidence it shares the same dependency on an external controller service as the Outer Versioned Flow
I believe the issue is that the code falls into this line here because the externalControllerServiceReferences is always set to that of the outermost versioned process group being imported even if the current process group being imported is versioned as well and has a different set of externalControllerServiceReferences
A solution may be to make sure that externalControllerServiceReferences corresponds to the innermost versioned process group being worked on by resolveInheritedControllerServices().
Another potential solution could be to make sure that outer versioned process groups' externalControllerServiceReferences is a superset of all the externalControllerServiceReferences from versioned process groups inside it.
A good restriction to have might be not to allow Controller Services with the same name to exist in the same scope.