Skip to content

Commit

Permalink
feat(shulker-proxy-agent): proper support of cluster reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylvln committed Aug 24, 2024
1 parent 8c6502b commit 9fb9e64
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions gradle/detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ style:
ignoreOverridden: true
ReturnCount:
active: false
ForbiddenComment:
active: false

potential-bugs:
UnsafeCallOnNullableType:
active: false
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ImplKubernetesGatewayAdapter(proxyNamespace: String, proxyName: String) :
.withName(Configuration.PROXY_FLEET_NAME)
.get()

if (service.spec.type !== "LoadBalancer") {
if (service.spec.type != "LoadBalancer") {
return Optional.empty()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProxyLifecycleService(private val agent: ShulkerProxyAgentCommon) {
}

private val ttlTask: ProxyInterface.ScheduledTask
private var drainingFuture: CompletableFuture<Void>? = null
private var drainingFuture: CompletableFuture<Unit>? = null

init {
this.agent.kubernetesGateway.watchProxyEvents { action, proxy ->
Expand All @@ -40,15 +40,15 @@ class ProxyLifecycleService(private val agent: ShulkerProxyAgentCommon) {
this.ttlTask.cancel()
}

fun drain(): CompletableFuture<Void> {
fun drain(): CompletableFuture<Unit> {
if (this.drainingFuture != null) {
return this.drainingFuture!!
}

this.drainingFuture = CompletableFuture<Void>()
this.drainingFuture = CompletableFuture<Unit>()
this.agent.fileSystem.createDrainLock()

// FIXME: Rather than hardcoding a task, wait for Kubernetes to
// TODO: Rather than hardcoding a task, wait for Kubernetes to
// exclude the proxy from the Service.
this.agent.proxyInterface.scheduleDelayedTask(
@Suppress("MagicNumber") 30L,
Expand All @@ -59,7 +59,7 @@ class ProxyLifecycleService(private val agent: ShulkerProxyAgentCommon) {

this.agent.logger.info("Proxy is now draining")

return this.drainingFuture!!.thenAccept {
return this.drainingFuture!!.thenApply {
this.onExcludedFromKubernetes()
}
}
Expand Down

0 comments on commit 9fb9e64

Please sign in to comment.