Skip to content

Commit

Permalink
correctly synchronize accessing client when config changes (redhat-de…
Browse files Browse the repository at this point in the history
…veloper#640)

Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Jul 24, 2023
1 parent f62c569 commit f501828
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ open class AllContexts(
}

protected open fun onKubeConfigChanged(fileConfig: io.fabric8.kubernetes.api.model.Config) {
val client = client.get() ?: return
val clientConfig = client.config.configuration
if (ConfigHelper.areEqual(fileConfig, clientConfig)) {
return
synchronized(this) {
val client = client.get() ?: return
val clientConfig = client.config.configuration
if (ConfigHelper.areEqual(fileConfig, clientConfig)) {
return
}
this.client.reset() // create new client when accessed
client.close()
refresh()
}
client.close()
this.client.reset() // create new client when accessed
refresh()
}

/** for testing purposes */
Expand Down

0 comments on commit f501828

Please sign in to comment.