Skip to content

Commit

Permalink
catch completion ex, retrow cause if it happens (#640)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Jul 24, 2023
1 parent 85037ae commit 477d37f
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import io.fabric8.kubernetes.client.Config
import io.fabric8.kubernetes.client.KubernetesClient
import io.fabric8.kubernetes.client.KubernetesClientException
import java.nio.file.Paths
import java.util.concurrent.CompletionException

interface IAllContexts {
/**
Expand Down Expand Up @@ -137,19 +138,21 @@ open class AllContexts(
newClient: ClientAdapter<out KubernetesClient>,
toWatch: Collection<ResourceKind<out HasMetadata>>?,
) : IActiveContext<out HasMetadata, out KubernetesClient>? {
synchronized(this) {
replaceClient(
newClient,
this.client.get()
)
this.current?.close()
newClient.config.save().join()
all.clear() // causes reload of all contexts when accessed afterwards
val newCurrent = this.current // gets new current from all
if (toWatch != null) {
newCurrent?.watchAll(toWatch)
try {
synchronized(this) {
replaceClient(newClient, this.client.get())
newClient.config.save().join()
current?.close()
all.clear() // causes reload of all contexts when accessed afterwards
val newCurrent = current // gets new current from all
if (toWatch != null) {
newCurrent?.watchAll(toWatch)
}
return newCurrent
}
return newCurrent
} catch (e: CompletionException) {
val cause = e.cause ?: throw e
throw cause
}
}

Expand Down

0 comments on commit 477d37f

Please sign in to comment.