zentol commented on a change in pull request #13190:
URL: https://github.com/apache/flink/pull/13190#discussion_r472942385
##########
File path:
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
##########
@@ -96,40 +97,42 @@ private int run(String[] args) throws FlinkException,
CliArgsException {
kubernetesClusterClientFactory.createClusterDescriptor(configuration);
try {
- final ClusterClient<String> clusterClient;
- String clusterId =
kubernetesClusterClientFactory.getClusterId(configuration);
+ final String clusterId =
kubernetesClusterClientFactory.getClusterId(configuration);
final boolean detached =
!configuration.get(DeploymentOptions.ATTACHED);
- final FlinkKubeClient kubeClient =
KubeClientFactory.fromConfiguration(configuration);
+
+ boolean connectToExistingCluster = false;
+ try (final FlinkKubeClient kubeClient =
KubeClientFactory.fromConfiguration(configuration)) {
+ connectToExistingCluster =
kubeClient.getRestService(clusterId).isPresent();
+ } catch (Exception e) {
+ LOG.info("Could not properly shutdown cluster
client.", e);
+ }
// Retrieve or create a session cluster.
- if (clusterId != null &&
kubeClient.getRestService(clusterId).isPresent()) {
- clusterClient =
kubernetesClusterDescriptor.retrieve(clusterId).getClusterClient();
+ if (connectToExistingCluster) {
+ kubernetesClusterDescriptor.retrieve(clusterId);
} else {
- clusterClient = kubernetesClusterDescriptor
+ kubernetesClusterDescriptor
.deploySessionCluster(
-
kubernetesClusterClientFactory.getClusterSpecification(configuration))
- .getClusterClient();
- clusterId = clusterClient.getClusterId();
+
kubernetesClusterClientFactory.getClusterSpecification(configuration));
}
- try {
- if (!detached) {
- Tuple2<Boolean, Boolean> continueRepl =
new Tuple2<>(true, false);
- try (BufferedReader in = new
BufferedReader(new InputStreamReader(System.in))) {
- while (continueRepl.f0) {
- continueRepl =
repStep(in);
- }
- } catch (Exception e) {
- LOG.warn("Exception while
running the interactive command line interface.", e);
+ if (!detached) {
+ Tuple2<Boolean, Boolean> continueRepl = new
Tuple2<>(true, false);
+ try (BufferedReader in = new BufferedReader(new
InputStreamReader(System.in))) {
+ while (continueRepl.f0) {
+ continueRepl = repStep(in);
}
- if (continueRepl.f1) {
+ } catch (Exception e) {
+ LOG.warn("Exception while running the
interactive command line interface.", e);
+ }
+
+ if (continueRepl.f1) {
+ try {
Review comment:
these changes are now purely about better exception messages, and I
would exclude them from the final PR, or move them into a hotfix commit.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]