-
Notifications
You must be signed in to change notification settings - Fork 220
feature: controller reconciliation max delay #871
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
Changes from 5 commits
7699d5c
4b3a8be
4ccf368
442e7d8
2e8ceb5
608aa9f
3f1e796
bdcd99a
eb86d66
0b6532c
11b7f5e
053bd2c
b2338c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,9 +160,7 @@ larger than the `.observedGeneration` field on status. In order to have this fea | |
. | ||
|
||
If these conditions are fulfilled and generation awareness not turned off, the observed generation is automatically set | ||
by the framework after the `reconcile` method is called. There is just one exception, when the reconciler returns | ||
with `UpdateControl.updateResource`, in this case the status is not updated, just the custom resource - however, this | ||
update will lead to a new reconciliation. Note that the observed generation is updated also | ||
by the framework after the `reconcile` method is called. Note that the observed generation is updated also | ||
when `UpdateControl.noUpdate()` is returned from the reconciler. See this feature working in | ||
the [WebPage example](https://github.com/java-operator-sdk/java-operator-sdk/blob/b91221bb54af19761a617bf18eef381e8ceb3b4c/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStatus.java#L5) | ||
. | ||
|
@@ -198,8 +196,9 @@ in status) to handle generation filtering in memory. Thus, if an event is receiv | |
resource is compared with the resource in the cache. | ||
|
||
Note that the **first approach has significant benefits** in the situation when the operator is restarted and there is | ||
no cached resource anymore. In case two this leads to a reconciliation of every resource, event if the resource is not | ||
changed while the operator was not running. | ||
no cached resource anymore. In case two this leads to a reconciliation of every resource in all cases, | ||
event if the resource is not changed while the operator was not running. However, in case informers are used | ||
the reconciliation from startup will happen anyway, since events will be propagated by the informer. | ||
|
||
## Support for Well Known (non-custom) Kubernetes Resources | ||
|
||
|
@@ -223,6 +222,27 @@ public class DeploymentReconciler | |
} | ||
``` | ||
|
||
## Max Interval Between Reconciliations | ||
|
||
In case informers are all in place and reconciler is implemented correctly the reconciliation is triggered when needed, | ||
metacosm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
and reconciliation happening as expected. However, it's a [common practice](https://github.com/java-operator-sdk/java-operator-sdk/issues/848#issuecomment-1016419966) having a failsafe periodic trigger in place, | ||
just to make sure the resources are reconciled after certain time. This functionality is in place by default, there | ||
is quite high interval (currently 10 hours) while the reconciliation is triggered. See how to override this using | ||
the standard annotation: | ||
|
||
```java | ||
@ControllerConfiguration(finalizerName = NO_FINALIZER, reconciliationMaxInterval = 2L, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated. |
||
reconciliationMaxIntervalTimeUnit = TimeUnit.HOURS) | ||
``` | ||
|
||
The event is not propagated in a fixed rate, rather it's scheduled after each reconciliation. So the | ||
next reconciliation will after at most within the specified interval after last reconciliation. | ||
|
||
This feature can be turned off by setting `reconciliationMaxInterval` to [`Constants.NO_RECONCILIATION_MAX_INTERVAL`](https://github.com/java-operator-sdk/java-operator-sdk/blob/442e7d8718e992a36880e42bd0a5c01affaec9df/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Constants.java#L8-L8) | ||
or any non-positive number. | ||
|
||
The automatic retries are not affected by this feature, in case of an error no schedule is set by this feature. | ||
|
||
## Automatic Retries on Error | ||
|
||
When an exception is thrown from a controller, the framework will schedule an automatic retry of the reconciliation. The | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import java.lang.reflect.ParameterizedType; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.ReconcilerUtils; | ||
|
@@ -114,4 +115,12 @@ default boolean useFinalizer() { | |
default ResourceEventFilter<R> getEventFilter() { | ||
return ResourceEventFilters.passthrough(); | ||
} | ||
|
||
default long reconciliationMaxInterval() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be better to introduce a separate annotation if we split the duration and its unit to make the name simpler and make it more coherent because it doesn't make sense to provide one without the other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little worried that it would unnecessary complicate things; also there is always a default value. Also both start with same prefix, I don't think this will be confusing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative is to have the time as a string, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it would complicate things and it would make things cleaner to group related things in a single part. Otherwise, you could have annotated reconcilers with just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just to see it clear. The reason to separate this into a new annotation because there are two related fields? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the best would be to ask the users. @andreaTP @lburgazzoli what do you think, should be this a separate annotation or not? see also the issue: Thank you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The namespace control is done that way. Pretty much all the annotation fields have default values so we already turn things on without the annotation being present. This would be the exact same thing here: the child annotation would just allow people to change the default value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, I'm not saying we should have a completely separate annotation, just a composite child annotation for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ahhh, ok that is a completely different story! Sure that makes sense! Sorry.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only understood that I hadn't been clear enough with what I was saying with your last comment :) |
||
return 10L; | ||
} | ||
|
||
default TimeUnit reconciliationMaxIntervalTimeUnit() { | ||
return TimeUnit.HOURS; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.