Skip to content

Commit 72fb838

Browse files
committed
rename to blocklist, added javadocs
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent a0548b2 commit 72fb838

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,22 @@ default boolean previousAnnotationForDependentResourcesEventFiltering() {
452452
return true;
453453
}
454454

455-
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlacklist() {
455+
/**
456+
* For dependent resources framework can add an annotation to filter our events that are results
457+
* of changes made by the framework. There are, however, few resources that do not follow the K8S
458+
* API convention that changes in metadata do not increase the "metadata.generation". For these
459+
* resources, the generation is increased by adding the annotation and their controller increases
460+
* the observedGeneration in the status. This results in a new event, that if not handled
461+
* correctly with the resource matcher yet again results in an update and a previous version
462+
* annotation change, thus results in an infinite loop.
463+
*
464+
* <p>As a workaround, we automatically skip adding previous annotation for those well-known
465+
* resources. Note that if you are sure that the matcher works (most of the cases does) for your
466+
* case, you can remove the resource from the blocklist.
467+
*
468+
* @return blocklist of resource classes where the previous version annotation won't be used.
469+
*/
470+
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
456471
return List.of(Deployment.class, StatefulSet.class, ReplicaSet.class);
457472
}
458473

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ConfigurationServiceOverrider {
4141
private Boolean parseResourceVersions;
4242
private Boolean useSSAToPatchPrimaryResource;
4343
private Boolean cloneSecondaryResourcesWhenGettingFromCache;
44-
private List<Class<? extends HasMetadata>> previousAnnotationUsageBlacklist;
44+
private List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist;
4545

4646
@SuppressWarnings("rawtypes")
4747
private DependentResourceFactory dependentResourceFactory;
@@ -190,9 +190,9 @@ public ConfigurationServiceOverrider withCloneSecondaryResourcesWhenGettingFromC
190190
return this;
191191
}
192192

193-
public ConfigurationServiceOverrider previousAnnotationUsageBlacklist(
193+
public ConfigurationServiceOverrider previousAnnotationUsageBlocklist(
194194
List<Class<? extends HasMetadata>> previousAnnotationUsageBlacklist) {
195-
this.previousAnnotationUsageBlacklist = previousAnnotationUsageBlacklist;
195+
this.previousAnnotationUsageBlocklist = previousAnnotationUsageBlacklist;
196196
return this;
197197
}
198198

@@ -338,10 +338,10 @@ public boolean cloneSecondaryResourcesWhenGettingFromCache() {
338338
}
339339

340340
@Override
341-
public List<Class<? extends HasMetadata>> previousAnnotationUsageBlacklist() {
341+
public List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
342342
return overriddenValueOrDefault(
343-
previousAnnotationUsageBlacklist,
344-
ConfigurationService::previousAnnotationUsageBlacklist);
343+
previousAnnotationUsageBlocklist,
344+
ConfigurationService::previousAnnotationUsageBlocklist);
345345
}
346346
};
347347
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private boolean usePreviousAnnotation(Context<P> context) {
170170
&& !context
171171
.getControllerConfiguration()
172172
.getConfigurationService()
173-
.previousAnnotationUsageBlacklist()
173+
.previousAnnotationUsageBlocklist()
174174
.contains(this.resourceType());
175175
}
176176
return usePreviousAnnotationForEventFiltering;

0 commit comments

Comments
 (0)