Skip to content

Commit 5085bc2

Browse files
committed
docs and test fixes
Signed-off-by: Attila Mészáros <csviri@gmail.com>
1 parent 362d1d2 commit 5085bc2

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

docs/content/en/docs/workflows/_index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ reconciliation process.
4848
with the dependent's resource type is not present on the cluster.
4949
See related [integration test](https://github.com/operator-framework/java-operator-sdk/blob/ba5e33527bf9e3ea0bd33025ccb35e677f9d44b4/operator-framework/src/test/java/io/javaoperatorsdk/operator/CRDPresentActivationConditionIT.java).
5050

51-
Activation condition is semi-experimental at the moment, and it has its limitations.
52-
For example event sources cannot be shared between multiple managed dependent resources which use activation condition.
53-
The intention is to further improve and explore the possibilities with this approach.
51+
To have multiple resources of same type with an activation condition is a bit tricky, since you
52+
don't want to have multiple `InformerEvetnSource` for the same type, you have to explicitly
53+
name the informer for the Dependent Resource (`@KubernetesDependent(informerConfig = @InformerConfig(name = "configMapInformer"))`)
54+
for all resource of same type with activation condition. This will make sure that only one is registered.
55+
See details at [low level api](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceRetriever.java#L20-L52).
5456

5557
## Defining Workflows
5658

operator-framework/src/test/java/io/javaoperatorsdk/operator/MultipleDependentWithActivationIT.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class MultipleDependentWithActivationIT {
1616

1717
public static final String INITIAL_VALUE = "initial_value";
18+
public static final String CHANGED_VALUE = "changed_value";
1819
public static final String TEST_RESOURCE_NAME = "test1";
1920

2021
@RegisterExtension
@@ -27,6 +28,21 @@ public class MultipleDependentWithActivationIT {
2728
void bothDependentsWithActivationAreHandled() {
2829
var resource = extension.create(testResource());
2930

31+
await().untilAsserted(() -> {
32+
var cm1 =
33+
extension.get(ConfigMap.class, TEST_RESOURCE_NAME + ConfigMapDependentResource1.SUFFIX);
34+
var cm2 =
35+
extension.get(ConfigMap.class, TEST_RESOURCE_NAME + ConfigMapDependentResource2.SUFFIX);
36+
var secret = extension.get(Secret.class, TEST_RESOURCE_NAME);
37+
assertThat(secret).isNotNull();
38+
assertThat(cm1).isNull();
39+
assertThat(cm2).isNull();
40+
});
41+
42+
ActivationCondition.MET = true;
43+
resource.getSpec().setValue(CHANGED_VALUE);
44+
extension.replace(resource);
45+
3046
await().untilAsserted(() -> {
3147
var cm1 =
3248
extension.get(ConfigMap.class, TEST_RESOURCE_NAME + ConfigMapDependentResource1.SUFFIX);
@@ -38,9 +54,9 @@ void bothDependentsWithActivationAreHandled() {
3854
assertThat(cm1).isNotNull();
3955
assertThat(cm2).isNotNull();
4056
assertThat(cm1.getData()).containsEntry(ConfigMapDependentResource1.DATA_KEY,
41-
INITIAL_VALUE + ConfigMapDependentResource1.SUFFIX);
57+
CHANGED_VALUE + ConfigMapDependentResource1.SUFFIX);
4258
assertThat(cm2.getData()).containsEntry(ConfigMapDependentResource2.DATA_KEY,
43-
INITIAL_VALUE + ConfigMapDependentResource2.SUFFIX);
59+
CHANGED_VALUE + ConfigMapDependentResource2.SUFFIX);
4460
});
4561

4662
}

operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/multipledependentwithactivation/ActivationCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class ActivationCondition
99
implements Condition<Route, MultipleDependentActivationCustomResource> {
1010

11-
public static volatile boolean MET = true;
11+
public static volatile boolean MET = false;
1212

1313
@Override
1414
public boolean isMet(

0 commit comments

Comments
 (0)