Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ndimiduk committed Jan 20, 2023
1 parent 15b8800 commit 47af1fa
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.kubernetes.client.openapi.models.V1ObjectMeta;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.openapi.models.V1PodStatus;
import io.kubernetes.client.util.ClientBuilder;
import java.io.IOException;
import java.util.Collections;
Expand All @@ -48,23 +49,24 @@
* overrun each other but generally succeed.
*/
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
public class KubernetesClusterManager extends Configured implements ClusterManager {
private static final Logger LOG = LoggerFactory.getLogger(KubernetesClusterManager.class);
public class PodKillingK8sClusterManager extends Configured implements ClusterManager {
private static final Logger LOG = LoggerFactory.getLogger(PodKillingK8sClusterManager.class);

private static final String NAMESPACE_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".namespace";
PodKillingK8sClusterManager.class.getCanonicalName() + ".namespace";
private static final String DEFAULT_NAMESPACE = "default";
private static final String ZOOKEEPER_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".zookeeper_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".zookeeper_role";
private static final String NAMENODE_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".namenode_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".namenode_role";
private static final String JOURNALNODE_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".journalnode_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".journalnode_role";
private static final String DATANODE_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".datanode_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".datanode_role";
private static final String MASTER_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".master_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".master_role";
private static final String REGIONSERVER_ROLE_SELECTOR_CONF_KEY =
KubernetesClusterManager.class.getCanonicalName() + ".regionserver_role";
PodKillingK8sClusterManager.class.getCanonicalName() + ".regionserver_role";
private static final Set<ServiceType> SUPPORTED_SERVICE_TYPES = buildSupportedServiceTypesSet();

private CoreV1Api api;
Expand Down Expand Up @@ -96,11 +98,11 @@ public void setConf(Configuration configuration) {
return;
}
super.setConf(configuration);
this.namespace = configuration.get(NAMESPACE_CONF_KEY);
namespace = configuration.get(NAMESPACE_CONF_KEY, DEFAULT_NAMESPACE);
LOG.info(
"Configuration={}, namespace={}, hbase.rootdir={}, hbase.zookeeper.quorum={}, "
+ "hbase.client.zookeeper.quorum={}",
configuration, this.namespace, configuration.get("hbase.rootdir"),
configuration, namespace, configuration.get("hbase.rootdir"),
configuration.get("hbase.zookeeper.quorum"),
configuration.get("hbase.client.zookeeper.quorum"));
final CoreV1Api coreV1Api;
Expand All @@ -111,7 +113,7 @@ public void setConf(Configuration configuration) {
} catch (IOException ioe) {
throw new RuntimeException("Failed Kubernetes ApiClient construction", ioe);
}
this.api = coreV1Api;
api = coreV1Api;
}

@Override
Expand Down Expand Up @@ -195,7 +197,13 @@ private boolean isRunning(String roleSelector, String hostname) throws IOExcepti
LOG.warn("Listing of namespace '{}' contains entry with empty pod name.", namespace);
continue;
}
if (hostname.startsWith(podName)) {
final String status =
Optional.of(item).map(V1Pod::getStatus).map(V1PodStatus::getPhase).orElse(null);
if (status == null) {
LOG.warn("Status of pod {}.{} not returned by the API.", namespace, podName);
return false;
}
if (hostname.startsWith(podName) && "running".equalsIgnoreCase(status)) {
return true;
}
}
Expand Down

0 comments on commit 47af1fa

Please sign in to comment.