Skip to content

feat: handle clustered resource on secondary to primary mapper init #2312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.slf4j.LoggerFactory;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.javaoperatorsdk.operator.OperatorException;
import io.javaoperatorsdk.operator.ReconcilerUtils;
Expand Down Expand Up @@ -38,11 +39,11 @@ public abstract class KubernetesDependentResource<R extends HasMetadata, P exten
private static final Logger log = LoggerFactory.getLogger(KubernetesDependentResource.class);
private final ResourceUpdaterMatcher<R> updaterMatcher;
private final boolean garbageCollected = this instanceof GarbageCollected;
private final boolean clustered;
private KubernetesDependentResourceConfig<R> kubernetesDependentResourceConfig;

private final boolean usingCustomResourceUpdateMatcher;

@SuppressWarnings("unchecked")
public KubernetesDependentResource(Class<R> resourceType) {
this(resourceType, null);
}
Expand All @@ -55,6 +56,7 @@ public KubernetesDependentResource(Class<R> resourceType, String name) {
updaterMatcher = usingCustomResourceUpdateMatcher
? (ResourceUpdaterMatcher<R>) this
: GenericResourceUpdaterMatcher.updaterMatcherFor(resourceType);
clustered = !Namespaced.class.isAssignableFrom(resourceType);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -93,7 +95,7 @@ private SecondaryToPrimaryMapper<R> getSecondaryToPrimaryMapper() {
if (this instanceof SecondaryToPrimaryMapper) {
return (SecondaryToPrimaryMapper<R>) this;
} else if (garbageCollected) {
return Mappers.fromOwnerReferences(false);
return Mappers.fromOwnerReferences(clustered);
} else if (useNonOwnerRefBasedSecondaryToPrimaryMapping()) {
return Mappers.fromDefaultAnnotations();
} else {
Expand Down
Loading