You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "gaborgsomogyi (via GitHub)" <gi...@apache.org> on 2023/01/26 07:55:32 UTC
[GitHub] [flink-kubernetes-operator] gaborgsomogyi opened a new pull request, #513: [FLINK-30781] Add completed checkpoint check to cluster health check
gaborgsomogyi opened a new pull request, #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513
## What is the purpose of the change
There are workloads which stuck in such a way that they're in RUNNING state most of the time but not able to proceed and make checkpoints. Such cases must be detected by the operator. In this PR I've added the possibility to ask the operator to watch the number of successful checkpoints. If the feature is enabled by `cluster.health-check.completed-checkpoints.enabled` and there are no successful checkpoint within the defined window in `cluster.health-check.completed-checkpoints.window` then the operator considers it as unhealthy deployment and re-creates it.
## Brief change log
* Added config `cluster.health-check.completed-checkpoints.enabled`
* Added config `cluster.health-check.completed-checkpoints.window`
* Added number of successful checkpoints watching
## Verifying this change
Changed/added automated tests + manually on Minikube (stateless job w/o checkpoint restarted all the time).
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changes to the `CustomResourceDescriptors`: no
- Core observer or reconciler logic that is regularly executed: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gyfora merged pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora merged PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090606233
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/deployment/ApplicationReconciler.java:
##########
@@ -145,6 +147,15 @@ public void deploy(
var relatedResource = ctx.getResource();
var status = relatedResource.getStatus();
var flinkService = ctx.getFlinkService();
+
+ if (spec.getJob().getState().equals(JobState.SUSPENDED)
+ || status.getReconciliationStatus()
+ .getState()
+ .equals(ReconciliationState.UPGRADING)) {
Review Comment:
Well, such case we're more on the safe side so not needed. Removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090406757
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/ClusterHealthEvaluator.java:
##########
@@ -75,72 +77,139 @@ public void evaluate(
var lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
if (lastValidClusterHealthInfo == null) {
LOG.debug("No last valid health info, skipping health check");
+ observedClusterHealthInfo.setNumRestartsEvaluationTimeStamp(
+ observedClusterHealthInfo.getTimeStamp());
+ observedClusterHealthInfo.setNumCompletedCheckpointsIncreasedTimeStamp(
+ observedClusterHealthInfo.getTimeStamp());
setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
} else if (observedClusterHealthInfo.getTimeStamp()
< lastValidClusterHealthInfo.getTimeStamp()) {
String msg =
"Observed health info timestamp is less than the last valid health info timestamp, this indicates a bug...";
LOG.error(msg);
throw new IllegalStateException(msg);
- } else if (observedClusterHealthInfo.getNumRestarts()
- < lastValidClusterHealthInfo.getNumRestarts()) {
- LOG.debug(
- "Observed health info number of restarts is less than the last valid health info number of restarts, skipping health check");
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
} else {
- boolean isHealthy = true;
-
LOG.debug("Valid health info exist, checking cluster health");
LOG.debug("Last valid health info: {}", lastValidClusterHealthInfo);
LOG.debug("Observed health info: {}", observedClusterHealthInfo);
- var timestampDiffMs =
- observedClusterHealthInfo.getTimeStamp()
- - lastValidClusterHealthInfo.getTimeStamp();
- LOG.debug(
- "Time difference between health infos: {}",
- Duration.ofMillis(timestampDiffMs));
-
- var restartCheckWindow =
- configuration.get(OPERATOR_CLUSTER_HEALTH_CHECK_RESTARTS_WINDOW);
- var restartCheckWindowMs = restartCheckWindow.toMillis();
- double countMultiplier = (double) restartCheckWindowMs / (double) timestampDiffMs;
- // If the 2 health info timestamp difference is within the window then no
- // scaling needed
- if (countMultiplier > 1) {
- countMultiplier = 1;
- }
- long numRestarts =
- (long)
- ((double)
- (observedClusterHealthInfo.getNumRestarts()
- - lastValidClusterHealthInfo
- .getNumRestarts())
- * countMultiplier);
- LOG.debug(
- "Calculated restart count for {} window: {}",
- restartCheckWindow,
- numRestarts);
-
- if (lastValidClusterHealthInfo.getTimeStamp()
- < clock.millis() - restartCheckWindowMs) {
- LOG.debug("Last valid health info timestamp is outside of the window");
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
- }
-
- var restartThreshold =
- configuration.get(OPERATOR_CLUSTER_HEALTH_CHECK_RESTARTS_THRESHOLD);
- if (numRestarts > restartThreshold) {
- LOG.info("Restart count hit threshold: {}", restartThreshold);
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
- isHealthy = false;
- }
-
- // Update the health flag
- lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
+ boolean isHealthy =
+ evaluateRestarts(
+ configuration,
+ clusterInfo,
+ lastValidClusterHealthInfo,
+ observedClusterHealthInfo);
+ isHealthy &=
Review Comment:
Changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#issuecomment-1404658254
cc @gyfora
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090405326
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/KubernetesOperatorConfigOptions.java:
##########
@@ -379,6 +379,24 @@ public static String operatorConfigKey(String key) {
"The threshold which is checked against job restart count within a configured window. "
+ "If the restart count is reaching the threshold then full cluster restart is initiated.");
+ @Documentation.Section(SECTION_DYNAMIC)
+ public static final ConfigOption<Boolean>
+ OPERATOR_CLUSTER_HEALTH_CHECK_CHECKPOINT_PROGRESS_ENABLED =
+ operatorConfig("cluster.health-check.checkpoint-progress.enabled")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "Whether to enable checkpoint progress health check for clusters.");
+
+ @Documentation.Section(SECTION_DYNAMIC)
+ public static final ConfigOption<Duration>
+ OPERATOR_CLUSTER_HEALTH_CHECK_CHECKPOINT_PROGRESS_WINDOW =
+ operatorConfig("cluster.health-check.checkpoint-progress.window")
+ .durationType()
+ .defaultValue(Duration.ofMinutes(5))
+ .withDescription(
+ "The duration of the time window where job completed checkpoint count measured. This must be bigger than checkpointing interval.");
Review Comment:
Changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090570504
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/deployment/ApplicationReconciler.java:
##########
@@ -145,6 +147,15 @@ public void deploy(
var relatedResource = ctx.getResource();
var status = relatedResource.getStatus();
var flinkService = ctx.getFlinkService();
+
+ if (spec.getJob().getState().equals(JobState.SUSPENDED)
+ || status.getReconciliationStatus()
+ .getState()
+ .equals(ReconciliationState.UPGRADING)) {
Review Comment:
Do we need any of these checks? If we are deploying a job then the previous health info should probably be cleared always
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090518894
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/ClusterHealthEvaluator.java:
##########
@@ -75,72 +77,139 @@ public void evaluate(
var lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
if (lastValidClusterHealthInfo == null) {
LOG.debug("No last valid health info, skipping health check");
Review Comment:
Added.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gaborgsomogyi (via GitHub)" <gi...@apache.org>.
gaborgsomogyi commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1087995977
##########
docs/layouts/shortcodes/generated/dynamic_section.html:
##########
@@ -8,6 +8,18 @@
</tr>
</thead>
<tbody>
+ <tr>
+ <td><h5>kubernetes.operator.cluster.health-check.completed-checkpoints.enabled</h5></td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>Whether to enable completed checkpoint health check for clusters.</td>
+ </tr>
+ <tr>
+ <td><h5>kubernetes.operator.cluster.health-check.completed-checkpoints.window</h5></td>
Review Comment:
Changed + fixed other issues in the doc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1087871390
##########
docs/layouts/shortcodes/generated/dynamic_section.html:
##########
@@ -8,6 +8,18 @@
</tr>
</thead>
<tbody>
+ <tr>
+ <td><h5>kubernetes.operator.cluster.health-check.completed-checkpoints.enabled</h5></td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>Whether to enable completed checkpoint health check for clusters.</td>
+ </tr>
+ <tr>
+ <td><h5>kubernetes.operator.cluster.health-check.completed-checkpoints.window</h5></td>
Review Comment:
maybe it would be better to call it `checkpoint-progress`, and make it more explicit in the description that we record unhealthy state if no checkpoints were taken at all in the check window
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #513: [FLINK-30781] Add completed checkpoint check to cluster health check
Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora commented on code in PR #513:
URL: https://github.com/apache/flink-kubernetes-operator/pull/513#discussion_r1090351779
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/KubernetesOperatorConfigOptions.java:
##########
@@ -379,6 +379,24 @@ public static String operatorConfigKey(String key) {
"The threshold which is checked against job restart count within a configured window. "
+ "If the restart count is reaching the threshold then full cluster restart is initiated.");
+ @Documentation.Section(SECTION_DYNAMIC)
+ public static final ConfigOption<Boolean>
+ OPERATOR_CLUSTER_HEALTH_CHECK_CHECKPOINT_PROGRESS_ENABLED =
+ operatorConfig("cluster.health-check.checkpoint-progress.enabled")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "Whether to enable checkpoint progress health check for clusters.");
+
+ @Documentation.Section(SECTION_DYNAMIC)
+ public static final ConfigOption<Duration>
+ OPERATOR_CLUSTER_HEALTH_CHECK_CHECKPOINT_PROGRESS_WINDOW =
+ operatorConfig("cluster.health-check.checkpoint-progress.window")
+ .durationType()
+ .defaultValue(Duration.ofMinutes(5))
+ .withDescription(
+ "The duration of the time window where job completed checkpoint count measured. This must be bigger than checkpointing interval.");
Review Comment:
This description should be something like:
```
If no checkpoints are completed within the defined time window, the job is considered unhealthy. This must be bigger than checkpointing interval.
```
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/ClusterHealthEvaluator.java:
##########
@@ -75,72 +77,139 @@ public void evaluate(
var lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
if (lastValidClusterHealthInfo == null) {
LOG.debug("No last valid health info, skipping health check");
Review Comment:
I think we should clear all health info (restarts, checkpoint progress) during an upgrade/suspend, so we guarantee that it is reinitialized after the jm starts after the upgrade.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/ClusterHealthEvaluator.java:
##########
@@ -75,72 +77,139 @@ public void evaluate(
var lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
if (lastValidClusterHealthInfo == null) {
LOG.debug("No last valid health info, skipping health check");
+ observedClusterHealthInfo.setNumRestartsEvaluationTimeStamp(
+ observedClusterHealthInfo.getTimeStamp());
+ observedClusterHealthInfo.setNumCompletedCheckpointsIncreasedTimeStamp(
+ observedClusterHealthInfo.getTimeStamp());
setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
} else if (observedClusterHealthInfo.getTimeStamp()
< lastValidClusterHealthInfo.getTimeStamp()) {
String msg =
"Observed health info timestamp is less than the last valid health info timestamp, this indicates a bug...";
LOG.error(msg);
throw new IllegalStateException(msg);
- } else if (observedClusterHealthInfo.getNumRestarts()
- < lastValidClusterHealthInfo.getNumRestarts()) {
- LOG.debug(
- "Observed health info number of restarts is less than the last valid health info number of restarts, skipping health check");
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
} else {
- boolean isHealthy = true;
-
LOG.debug("Valid health info exist, checking cluster health");
LOG.debug("Last valid health info: {}", lastValidClusterHealthInfo);
LOG.debug("Observed health info: {}", observedClusterHealthInfo);
- var timestampDiffMs =
- observedClusterHealthInfo.getTimeStamp()
- - lastValidClusterHealthInfo.getTimeStamp();
- LOG.debug(
- "Time difference between health infos: {}",
- Duration.ofMillis(timestampDiffMs));
-
- var restartCheckWindow =
- configuration.get(OPERATOR_CLUSTER_HEALTH_CHECK_RESTARTS_WINDOW);
- var restartCheckWindowMs = restartCheckWindow.toMillis();
- double countMultiplier = (double) restartCheckWindowMs / (double) timestampDiffMs;
- // If the 2 health info timestamp difference is within the window then no
- // scaling needed
- if (countMultiplier > 1) {
- countMultiplier = 1;
- }
- long numRestarts =
- (long)
- ((double)
- (observedClusterHealthInfo.getNumRestarts()
- - lastValidClusterHealthInfo
- .getNumRestarts())
- * countMultiplier);
- LOG.debug(
- "Calculated restart count for {} window: {}",
- restartCheckWindow,
- numRestarts);
-
- if (lastValidClusterHealthInfo.getTimeStamp()
- < clock.millis() - restartCheckWindowMs) {
- LOG.debug("Last valid health info timestamp is outside of the window");
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
- }
-
- var restartThreshold =
- configuration.get(OPERATOR_CLUSTER_HEALTH_CHECK_RESTARTS_THRESHOLD);
- if (numRestarts > restartThreshold) {
- LOG.info("Restart count hit threshold: {}", restartThreshold);
- setLastValidClusterHealthInfo(clusterInfo, observedClusterHealthInfo);
- isHealthy = false;
- }
-
- // Update the health flag
- lastValidClusterHealthInfo = getLastValidClusterHealthInfo(clusterInfo);
+ boolean isHealthy =
+ evaluateRestarts(
+ configuration,
+ clusterInfo,
+ lastValidClusterHealthInfo,
+ observedClusterHealthInfo);
+ isHealthy &=
Review Comment:
let's use
```
isHealthy = evaluteRestarts(...) && evaluateCheckpoints(...)
```
for clarity
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org