-
Notifications
You must be signed in to change notification settings - Fork 233
Description
In the current version JOSDK assumes when registering a dependent resource that it's managed dependent resource type (e.g. a ConfigMap or ServiceMonitor) is available and hence required for the operator. In most cases this holds true but for certain resource types (e.g. the ServiceMonitor) the dependency could be less strict when they are not available. The usual scenario with a required dependent looks like this:
- The
ServiceMonitorCRD is not available in the cluster - My operator defined a
@Dependentmanaging theServiceMonitor - The operator expresses its requirement for the
ServiceMonitorCRD via theClusterServiceVersion.spec.customresourcedefinitions.requiredfield - If I install the operator with this requirement, the Prometheus operator will be installed, too.
So far so good, but how could I implement the following behavior:
- The ServiceMonitor CRD is not be available in the cluster
- My operator defined a
@Dependentmanaging theServiceMonitor - The operator does NOT define a requirement for the
ServiceMonitorCRD via theClusterServiceVersion.spec.customresourcedefinitions.requiredfield - Without the requirement, the Prometheus operator will NOT be installed.
- The operator defines an
activationConditionthat checks whetherServiceMonitorAPI is available in the cluster
6a. The operator does not fail but ignores that it is not able to reconcile theServiceMonitorbecause it is just optional.
6b. The user installs the ServiceMonitor manually because she wants to use it and because it is available now, the operator will reconcile theServiceMonitor(activationConditionholds true)
I see this type of optional dependencies in many official OpenShift operators, e.g. the ServiceMesh operator that interacts with Kiali. Kiali is not in the ClusterServiceVersion.spec.customresourcedefinitions.required. It must be installed before the ServiceMesh operator is installed.
A potential solution could be to introduce a new attribute optional:
@Dependent(type = ServiceMonitorDependentResource.class, optional = true)
This attribute would add an activationCondition behind the scenes that checks for the API of the CRD and it would lead to omission of the CRD in the ClusterServiceVersion.spec.customresourcedefinitions.required array.