Repository: incubator-slider
Updated Branches:
  refs/heads/releases/slider-0.60 99e220a45 -> 7af5a7889


SLIDER-625 remove broken usage of CredentialShell and fail fast if specified 
credentials have not been pre-initialized


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/7af5a788
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/7af5a788
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/7af5a788

Branch: refs/heads/releases/slider-0.60
Commit: 7af5a7889707857600f255316da03a16c846ca20
Parents: 99e220a
Author: Billie Rinaldi <[email protected]>
Authored: Fri Nov 7 17:51:21 2014 -0800
Committer: Billie Rinaldi <[email protected]>
Committed: Fri Nov 7 17:53:07 2014 -0800

----------------------------------------------------------------------
 .../org/apache/slider/client/SliderClient.java  | 25 +++++++-------------
 1 file changed, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7af5a788/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java 
b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index b9ed2b5..dd8b4db 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -36,7 +36,6 @@ import 
org.apache.hadoop.registry.client.types.RegistryPathStatus;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.alias.CredentialProvider;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
-import org.apache.hadoop.security.alias.CredentialShell;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
@@ -613,44 +612,36 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
         clustername, clusterDirectory);
     try {
       checkForCredentials(getConfig(), instanceDefinition.getAppConf());
-    } catch (Exception e) {
-      throw new IOException("problem setting credentials", e);
+    } catch (IOException e) {
+      sliderFileSystem.getFileSystem().delete(clusterDirectory, true);
+      throw e;
     }
     return startCluster(clustername, createArgs);
   }
 
   private void checkForCredentials(Configuration conf,
-      ConfTree tree) throws Exception {
+      ConfTree tree) throws IOException {
     if (tree.credentials == null || tree.credentials.size()==0) {
       log.info("No credentials requested");
       return;
     }
-    CredentialShell credentialShell = null;
+
     for (Entry<String, List<String>> cred : tree.credentials.entrySet()) {
       String provider = cred.getKey();
       List<String> aliases = cred.getValue();
       if (aliases == null || aliases.size()==0) {
         continue;
       }
-      if (credentialShell == null) {
-        credentialShell = new CredentialShell();
-        credentialShell.setConf(conf);
-      }
       Configuration c = new Configuration(conf);
       c.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, provider);
       CredentialProvider credentialProvider =
           CredentialProviderFactory.getProviders(c).get(0);
       Set<String> existingAliases = new 
HashSet<String>(credentialProvider.getAliases());
       for (String alias : aliases) {
-        if (existingAliases.contains(alias.toLowerCase(Locale.ENGLISH))) {
-          log.warn("Skipping creation of credentials for {}, " +
-              "alias already exists in {}", alias, provider);
-          continue;
+        if (!existingAliases.contains(alias.toLowerCase(Locale.ENGLISH))) {
+          throw new IOException("Specified credentials have not been " +
+              "initialized in provider " + provider + ": " + alias);
         }
-        String[] csarg = new String[]{
-            "create", alias, "-provider", provider};
-        log.info("Creating credentials for {} in {}", alias, provider);
-        credentialShell.run(csarg);
       }
     }
   }

Reply via email to