XComp commented on a change in pull request #19191:
URL: https://github.com/apache/flink/pull/19191#discussion_r831251475
##########
File path:
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesCheckpointIDCounterTest.java
##########
@@ -50,6 +55,130 @@ public void testGetAndIncrement() throws Exception {
};
}
+ @Test
+ public void testShutdown() throws Exception {
+ new Context() {
+ {
+ runTest(
+ () -> {
+ leaderCallbackGrantLeadership();
+
+ final KubernetesCheckpointIDCounter
checkpointIDCounter =
+ new KubernetesCheckpointIDCounter(
+ flinkKubeClient,
LEADER_CONFIGMAP_NAME, LOCK_IDENTITY);
+ checkpointIDCounter.start();
+
+ checkpointIDCounter.setCount(100L);
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.get(Constants.CHECKPOINT_COUNTER_KEY),
+ is("100"));
+
+
checkpointIDCounter.shutdown(JobStatus.FINISHED).join();
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.containsKey(Constants.CHECKPOINT_COUNTER_KEY),
+ is(false));
+ });
+ }
+ };
+ }
+
+ @Test
+ public void testShutdownForLocallyTerminatedJobStatus() throws Exception {
+ new Context() {
+ {
+ runTest(
+ () -> {
+ leaderCallbackGrantLeadership();
+
+ final KubernetesCheckpointIDCounter
checkpointIDCounter =
+ new KubernetesCheckpointIDCounter(
+ flinkKubeClient,
LEADER_CONFIGMAP_NAME, LOCK_IDENTITY);
+ checkpointIDCounter.start();
+
+ checkpointIDCounter.setCount(100L);
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.get(Constants.CHECKPOINT_COUNTER_KEY),
+ is("100"));
+
+
checkpointIDCounter.shutdown(JobStatus.SUSPENDED).join();
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.containsKey(Constants.CHECKPOINT_COUNTER_KEY),
+ is(true));
+ });
+ }
+ };
+ }
+
+ @Test
+ public void testIdempotentShutdown() throws Exception {
+ new Context() {
+ {
+ runTest(
+ () -> {
+ leaderCallbackGrantLeadership();
+
+ final KubernetesCheckpointIDCounter
checkpointIDCounter =
+ new KubernetesCheckpointIDCounter(
+ flinkKubeClient,
LEADER_CONFIGMAP_NAME, LOCK_IDENTITY);
+ checkpointIDCounter.start();
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.containsKey(Constants.CHECKPOINT_COUNTER_KEY),
+ is(false));
+
+
checkpointIDCounter.shutdown(JobStatus.FINISHED).join();
+
+ assertThat(
+ getLeaderConfigMap()
+ .getData()
+
.containsKey(Constants.CHECKPOINT_COUNTER_KEY),
+ is(false));
+ });
+ }
+ };
+ }
+
+ @Test
+ public void testShutdownFailureDueToMissingConfigMap() throws Exception {
+ new Context() {
+ {
+ runTest(
+ () -> {
+ leaderCallbackGrantLeadership();
+
+ final KubernetesCheckpointIDCounter
checkpointIDCounter =
+ new KubernetesCheckpointIDCounter(
+ flinkKubeClient,
LEADER_CONFIGMAP_NAME, LOCK_IDENTITY);
+ checkpointIDCounter.start();
+
+ // deleting the ConfigMap from outside of the
CheckpointIDCounter while
Review comment:
retrying the deletion will cause an entry being removed from the
(existing) ConfigMap. This would not cause any errors. The ConfigMap itself is
removed in the
`Kubernetes(MultipleComponentLeaderElection)HaServices.internalCleanupJobData(JobID)`
after the `JobMaster` is closed. That's why, there's the
`JobManagerRunner`/`JobMaster` cleanup is prioritized over the other cleanups
in
[DispatcherResourceCleanerFactory:110](https://github.com/apache/flink/blob/c5352fc55972420ed5bf1afdfd97834540b1407a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/cleanup/DispatcherResourceCleanerFactory.java#L110)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]