diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java index bf46d15..7d68b37 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java @@ -433,6 +433,7 @@ public int actionDestroy(String serviceName) throws YarnException, FileSystem fileSystem = fs.getFileSystem(); // remove from the appId cache cachedAppInfo.remove(serviceName); + boolean destroySucceed = true; if (fileSystem.exists(appDir)) { if (fileSystem.delete(appDir, true)) { LOG.info("Successfully deleted service dir for " + serviceName + ": " @@ -443,20 +444,32 @@ public int actionDestroy(String serviceName) throws YarnException, LOG.info(message); throw new YarnException(message); } + } else { + LOG.info("Service '" + serviceName + "' doesn't exist at hdfs path: " + + appDir); + destroySucceed = false; } + String registryPath = + ServiceRegistryUtils.registryPathForInstance(serviceName); try { - deleteZKNode(serviceName); - } catch (Exception e) { - throw new IOException("Could not delete zk node for " + serviceName, e); - } - String registryPath = ServiceRegistryUtils.registryPathForInstance(serviceName); - try { - getRegistryClient().delete(registryPath, true); + if (getRegistryClient().exists(registryPath)) { + getRegistryClient().delete(registryPath, true); + } else { + LOG.info( + "Service '" + serviceName + "' doesn't exist at ZK registry path: " + + registryPath); + destroySucceed = false; + } } catch (IOException e) { LOG.warn("Error deleting registry entry {}", registryPath, e); } - LOG.info("Destroyed cluster {}", serviceName); - return EXIT_SUCCESS; + if (destroySucceed) { + LOG.info("Successfully destroyed service {}", serviceName); + return EXIT_SUCCESS; + } else { + LOG.error("Error on destroy '" + serviceName + "': not found."); + return -1; + } } private synchronized RegistryOperations getRegistryClient() @@ -471,13 +484,18 @@ private synchronized RegistryOperations getRegistryClient() return registryClient; } - private void deleteZKNode(String clusterName) throws Exception { + private boolean deleteZKNode(String clusterName) throws Exception { CuratorFramework curatorFramework = getCuratorClient(); String user = RegistryUtils.currentUser(); String zkPath = ServiceRegistryUtils.mkClusterPath(user, clusterName); if (curatorFramework.checkExists().forPath(zkPath) != null) { curatorFramework.delete().deletingChildrenIfNeeded().forPath(zkPath); LOG.info("Deleted zookeeper path: " + zkPath); + return true; + } else { + LOG.info( + "Service '" + clusterName + "' doesn't exist at ZK path: " + zkPath); + return false; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/provider/AbstractClientProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/provider/AbstractClientProvider.java index fc8953c..26c332b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/provider/AbstractClientProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/provider/AbstractClientProvider.java @@ -101,8 +101,8 @@ public void validateConfigFiles(List configFiles, Path p = new Path(file.getSrcFile()); if (!fs.exists(p)) { throw new IllegalArgumentException( - "Src_file does not exist for config file: " + file - .getSrcFile()); + "Specified src_file does not exist on " + fs.getScheme() + ": " + + file.getSrcFile()); } }