Skip to content

Commit

Permalink
DPNG-15268-tap_user_permission_propagation: (#17)
Browse files Browse the repository at this point in the history
* fix for tap user permissions not propagation when creating hdfs instance
  • Loading branch information
pgrabusz committed Feb 20, 2017
1 parent 1e20979 commit 88a31e6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>hdfs-broker</artifactId>
<version>0.12.7</version>
<version>0.12.8</version>

<parent>
<groupId>org.trustedanalytics</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
public interface HdfsDirectoryProvisioningOperations {
String provisionDirectory(String instanceId, String orgId) throws ServiceBrokerException;
void addHiveUserGroupAcl(String path, String orgId) throws ServiceBrokerException;
void addTapUserAcl(String path, String orgId) throws ServiceBrokerException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,31 @@ public String provisionDirectory(String instanceId, String orgId) throws Service
hdfsClient.createDir(path);
hdfsClient.setPermission(path, FS_PERMISSION);
addHiveUserGroupAcl(path, orgId);
addTapUserAcl(path, orgId);
return path;
} catch (IOException e) {
throw new ServiceBrokerException("Unable to provision directory for: " + instanceId, e);
}
}

@Override
public void addTapUserAcl(String path, String orgId) throws ServiceBrokerException {
try {
AclEntry.Builder builder = new AclEntry.Builder()
.setType(AclEntryType.USER)
.setPermission(FsAction.ALL)
.setName("tap");

AclEntry tapDefaultUserAcl = builder.setScope(AclEntryScope.DEFAULT).build();
AclEntry tapUserAcl = builder.setScope(AclEntryScope.ACCESS).build();

setAclRecursively(path, tapUserAcl);
setAclRecursively(path, tapDefaultUserAcl);
} catch (IOException e) {
throw new ServiceBrokerException("Unable to add system users groups ACL for path: " + path, e);
}
}

@Override
public void addHiveUserGroupAcl(String path, String orgId) throws ServiceBrokerException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void provision_templateWithOrgAndInstanceVariables_replaceVariablesWithVa
new Path(getDirectoryPathToProvision(serviceInstance)));
verify(hdfsClient).setPermission(getDirectoryPathToProvision(serviceInstance), FS_PERMISSION);

verify(encryptedHdfsClient, times(2)).listFiles("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), true);
verify(encryptedHdfsClient, times(4)).listFiles("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), true);

verifyNoMoreInteractions(hdfsClient, encryptedHdfsClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void provision_templateWithOrgAndInstanceVariables_replaceVariablesWithVa
verify(encryptedHdfsClient).addAclEntry("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), TestUtil.hiveUserAcl());
verify(encryptedHdfsClient).addAclEntry("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), TestUtil.hiveDefaultUserAcl());

verify(encryptedHdfsClient, times(2)).listFiles("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), true);
verify(encryptedHdfsClient, times(4)).listFiles("/org/"+ serviceInstance.getOrganizationGuid()+"/brokers/userspace/"+serviceInstance.getServiceInstanceId(), true);

verifyNoMoreInteractions(hdfsClient, encryptedHdfsClient);
}
Expand Down

0 comments on commit 88a31e6

Please sign in to comment.