Skip to content
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

[Improve] [Flink-Kubernetes-V2] add observer untrack on Flink-Kubernetes-V2-Session #3216

Merged
merged 8 commits into from
Oct 8, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package org.apache.streampark.flink.client.impl

import org.apache.streampark.common.util.Logger
import org.apache.streampark.common.zio.ZIOExt.IOOps
import org.apache.streampark.common.zio.ZIOExt.{IOOps, OptionZIOOps}
import org.apache.streampark.flink.client.`trait`.KubernetesClientV2Trait
import org.apache.streampark.flink.client.bean._
import org.apache.streampark.flink.kubernetes.v2.model.FlinkSessionJobDef
import org.apache.streampark.flink.kubernetes.v2.observer.FlinkK8sObserver
import org.apache.streampark.flink.kubernetes.v2.operator.FlinkK8sOperator
import org.apache.streampark.flink.packer.pipeline.ShadedBuildResponse

Expand All @@ -34,6 +35,8 @@ import scala.util.{Failure, Success}

/** Flink K8s session mode app operation client via Flink K8s Operator */
object KubernetesSessionClientV2 extends KubernetesClientV2Trait with Logger {
private val observer = FlinkK8sObserver

@throws[Throwable]
override def doSubmit(
submitRequest: SubmitRequest,
Expand Down Expand Up @@ -125,6 +128,9 @@ object KubernetesSessionClientV2 extends KubernetesClientV2Trait with Logger {

FlinkK8sOperator.k8sCrOpr.deleteSessionJob(namespace, name).runIOAsTry match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the shutdown here is shutting down a flink cluster, the FlinkK8sOperator.delete() function should be called, which automatically untracks the flink cluster resources

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

case Success(_) =>
observer.trackedKeys
.find(_.id == shutDownRequest.id)
.someOrUnitZIO(key => observer.untrack(key))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is a ZIO value, so in fact it will not be executed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

logInfo(richMsg("Shutdown Flink cluster successfully."))
ShutDownResponse()
case Failure(err) =>
Expand Down