IsOperatorHandlerConsideringLock uses normal IsOperatorHandler checks and adds additional check for legacy resources that are missing a proper operator id annotation. In general two kind of operators race for reconcile these legacy resources. The local operator for this namespace and the default glo
(ctx context.Context, c ctrl.Reader, namespace string, object ctrl.Object)
| 158 | // The local operator for this namespace and the default global operator instance. Based on the existence of a namespace |
| 159 | // lock the current local operator has precedence. When no lock exists the default global operator should reconcile. |
| 160 | func IsOperatorHandlerConsideringLock(ctx context.Context, c ctrl.Reader, namespace string, object ctrl.Object) bool { |
| 161 | isHandler := IsOperatorHandler(object) |
| 162 | if !isHandler { |
| 163 | return false |
| 164 | } |
| 165 | |
| 166 | resourceID := camelv1.GetOperatorIDAnnotation(object) |
| 167 | // add additional check on resources missing an operator id |
| 168 | if resourceID == "" { |
| 169 | operatorNamespace := GetOperatorNamespace() |
| 170 | if operatorNamespace == namespace { |
| 171 | // Global operator is allowed on its own namespace |
| 172 | return true |
| 173 | } |
| 174 | |
| 175 | if locked, err := IsNamespaceLocked(ctx, c, namespace); err != nil || locked { |
| 176 | // namespace is locked so local operators do have precedence |
| 177 | return !IsCurrentOperatorGlobal() |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | return true |
| 182 | } |
| 183 | |
| 184 | // FilteringFuncs do preliminary checks to determine if certain events should be handled by the controller |
| 185 | // based on labels on the resources (e.g. camel.apache.org/operator.id) and the operator configuration, |
no test coverage detected