Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: csviri <[email protected]>
  • Loading branch information
csviri committed Mar 29, 2024
1 parent a1194b6 commit 7d4ecf4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/main/java/io/csviri/operator/resourceglue/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.csviri.operator.resourceglue.customresource.glue.DependentResourceSpec;
import io.csviri.operator.resourceglue.customresource.glue.Glue;
import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
Expand All @@ -14,6 +17,8 @@

public class Utils {

private static final Logger log = LoggerFactory.getLogger(Utils.class);

public static final String RESOURCE_NAME_DELIMITER = "#";

private Utils() {}
Expand All @@ -38,6 +43,7 @@ public static Map<String, GenericKubernetesResource> getActualResourcesByNameInW

glue.getSpec().getRelatedResources().forEach(r -> {
var gvk = new GroupVersionKind(r.getApiVersion(), r.getKind());
log.debug("Getting event source for gvk: {}", gvk);
var es =
(InformerEventSource<GenericKubernetesResource, Glue>) context
.eventSourceRetriever()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public UpdateControl<Glue> reconcile(Glue primary,

log.debug("Reconciling glue. name: {} namespace: {}",
primary.getMetadata().getName(), primary.getMetadata().getNamespace());
addFinalizersToParentResource(primary);
registerRelatedResourceInformers(context, primary);
if (ownersBeingDeleted(primary, context)) {
return UpdateControl.noUpdate();
Expand All @@ -56,6 +57,13 @@ public UpdateControl<Glue> reconcile(Glue primary,
return UpdateControl.noUpdate();
}

// todo issue, condition if resource exists (related resource exists)
// todo, also remove finalizer on cleanup
// add just
private void addFinalizersToParentResource(Glue primary) {

}

/**
* If a parent gets deleted, the glue is reconciled still, but we don't want that in that case.
* Glue us deleted / marked for deleted eventually by the garbage collector but want to make the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void templating() {

delete(cr);

await().untilAsserted(() -> {
await().timeout(Duration.ofMinutes(5)).untilAsserted(() -> {
var cm1 = get(ConfigMap.class, name);
var actualCR = get(TestCustomResource.class, name);
assertThat(cm1).isNull();
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/io/csviri/operator/resourceglue/GlueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ void simpleConcurrencyTest() {
}));

glueList.forEach(this::delete);
await().timeout(Duration.ofMinutes(5))
.untilAsserted(() -> IntStream.range(0, num).forEach(index -> {
var w = get(Glue.class, "testglue" + index);
assertThat(w).isNull();
}));
await().untilAsserted(() -> IntStream.range(0, num).forEach(index -> {
var w = get(Glue.class, "testglue" + index);
assertThat(w).isNull();
}));
}

@Test
Expand Down

0 comments on commit 7d4ecf4

Please sign in to comment.