This is an automated email from the ASF dual-hosted git repository.
nicknezis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push:
new 382fd15 Added ability to restart a topology on Kubernetes (#3740)
382fd15 is described below
commit 382fd15c343d2b4f36afd11796c09199b0d700f6
Author: Saad Ur Rahman <[email protected]>
AuthorDate: Fri Nov 19 21:25:02 2021 -0500
Added ability to restart a topology on Kubernetes (#3740)
---
deploy/kubernetes/helm/templates/tools.yaml | 6 +++++
.../heron/scheduler/kubernetes/V1Controller.java | 29 +++++++++++++++++++---
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/deploy/kubernetes/helm/templates/tools.yaml
b/deploy/kubernetes/helm/templates/tools.yaml
index 7cb572b..08b0707 100644
--- a/deploy/kubernetes/helm/templates/tools.yaml
+++ b/deploy/kubernetes/helm/templates/tools.yaml
@@ -299,6 +299,12 @@ rules:
- apiGroups:
- ""
resources:
+ - pods
+ verbs:
+ - deletecollection
+- apiGroups:
+ - ""
+ resources:
- services
verbs:
- create
diff --git
a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
index 761d615..305b5d2 100644
---
a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
+++
b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
@@ -156,12 +156,23 @@ public class V1Controller extends KubernetesController {
return true;
}
+ /**
+ * Restarts a topology by deleting the Pods associated with it using
<code>Selector Labels</code>.
+ * @param shardId Not used but required because of interface.
+ * @return Indicator of successful submission of restart request to
Kubernetes cluster.
+ */
@Override
boolean restart(int shardId) {
- final String message = "Restarting the whole topology is not supported
yet. "
- + "Please kill and resubmit the topology.";
- LOG.log(Level.SEVERE, message);
- return false;
+ try {
+ coreClient.deleteCollectionNamespacedPod(getNamespace(), null, null,
null, null,
+ 0, createTopologySelectorLabels(), null, null, null, null,
+ null, null, null);
+ LOG.log(Level.WARNING, String.format("Restarting topology '%s'...",
getTopologyName()));
+ } catch (ApiException e) {
+ LOG.log(Level.SEVERE, String.format("Failed to restart topology
'%s'...", getTopologyName()));
+ return false;
+ }
+ return true;
}
@Override
@@ -839,4 +850,14 @@ public class V1Controller extends KubernetesController {
throw new TopologySubmissionException(String.format("%s: %s", message,
e.getMessage()));
}
}
+
+ /**
+ * Generates the <code>Selector</code> match labels with which resources in
this topology can be found.
+ * @return A label of the form <code>app=heron,topology=topology-name</code>.
+ */
+ private String createTopologySelectorLabels() {
+ return String.format("%s=%s,%s=%s",
+ KubernetesConstants.LABEL_APP, KubernetesConstants.LABEL_APP_VALUE,
+ KubernetesConstants.LABEL_TOPOLOGY, getTopologyName());
+ }
}