Search in sources :

Example 1 with HdfsGroups

use of io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups in project hopsworks by logicalclocks.

the class PermissionsCleaner method fixDataset.

private void fixDataset(Dataset dataset) throws IOException {
    String datasetGroup = hdfsUsersController.getHdfsGroupName(dataset.getProject(), dataset);
    String datasetAclGroup = hdfsUsersController.getHdfsAclGroupName(dataset.getProject(), dataset);
    DistributedFileSystemOps dfso = null;
    try {
        dfso = dfsService.getDfsOps();
        HdfsGroups hdfsDatasetGroup = getOrCreateGroup(datasetGroup, dfso);
        HdfsGroups hdfsDatasetAclGroup = getOrCreateGroup(datasetAclGroup, dfso);
        fixPermission(dataset, hdfsDatasetGroup, hdfsDatasetAclGroup, dfso);
    } finally {
        dfsService.closeDfsClient(dfso);
    }
}
Also used : DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) HdfsGroups(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups)

Example 2 with HdfsGroups

use of io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups in project hopsworks by logicalclocks.

the class PermissionsCleaner method getOrCreateGroup.

private HdfsGroups getOrCreateGroup(String group, DistributedFileSystemOps dfso) throws IOException {
    HdfsGroups hdfsGroup = hdfsGroupsFacade.findByName(group);
    if (hdfsGroup == null) {
        dfso.addGroup(group);
        hdfsGroup = hdfsGroupsFacade.findByName(group);
        LOGGER.log(Level.WARNING, "Found and fixed a missing group: group={0}", group);
    }
    return hdfsGroup;
}
Also used : HdfsGroups(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups)

Example 3 with HdfsGroups

use of io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups in project hopsworks by logicalclocks.

the class ProjectController method cleanup.

public void cleanup(Project project, String sessionId, List<Future<?>> projectCreationFutures, boolean decreaseCreatedProj, Users owner) throws GenericException {
    if (project == null) {
        return;
    }
    int nbTry = 0;
    while (nbTry < 2) {
        YarnClientWrapper yarnClientWrapper = ycs.getYarnClientSuper(settings.getConfiguration());
        YarnClient client = yarnClientWrapper.getYarnClient();
        try {
            // remove from project_team so that nobody can see the project anymore
            updateProjectTeamRole(project, ProjectRoleTypes.UNDER_REMOVAL);
            /*
         * get all running yarn application owned by anny of the project members
         * we will check later if this application have been stoped and their log aggregation have been finished
         * it would be better to check all application (even the ones that have finished running)
         * but the log aggregation status is not recovered when the resource manager restart. As a result
         * we can't know if the status in "NOT_START" because we should wait for it or because the
         * resourcemanager restarted.
         */
            Collection<ProjectTeam> team = project.getProjectTeamCollection();
            Set<String> hdfsUsers = new HashSet<>();
            for (ProjectTeam pt : team) {
                String hdfsUsername = hdfsUsersController.getHdfsUserName(project, pt.getUser());
                hdfsUsers.add(hdfsUsername);
            }
            List<ApplicationReport> projectsApps = getYarnApplications(hdfsUsers, client);
            // try and close all the jupyter jobs
            removeJupyter(project);
            removeAnacondaEnv(project);
            removeAlertConfigs(project);
            // kill jobs
            killYarnJobs(project);
            waitForJobLogs(projectsApps, client);
            List<HdfsUsers> usersToClean = getUsersToClean(project);
            List<HdfsGroups> groupsToClean = getGroupsToClean(project);
            removeProjectInt(project, usersToClean, groupsToClean, projectCreationFutures, decreaseCreatedProj, owner);
            removeCertificatesFromMaterializer(project);
            // Delete online featurestore database
            onlineFeaturestoreController.removeOnlineFeatureStore(project);
            break;
        } catch (Exception ex) {
            nbTry++;
            if (nbTry < 2) {
                try {
                    Thread.sleep(nbTry * 1000);
                } catch (InterruptedException ex1) {
                    LOGGER.log(Level.SEVERE, null, ex1);
                }
            } else {
                throw new GenericException(RESTCodes.GenericErrorCode.UNKNOWN_ERROR, Level.SEVERE, null, ex.getMessage(), ex);
            }
        } finally {
            ycs.closeYarnClient(yarnClientWrapper);
        }
    }
}
Also used : GenericException(io.hops.hopsworks.exceptions.GenericException) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) TensorBoardException(io.hops.hopsworks.exceptions.TensorBoardException) DatasetException(io.hops.hopsworks.exceptions.DatasetException) EJBException(javax.ejb.EJBException) AlertException(io.hops.hopsworks.exceptions.AlertException) PythonException(io.hops.hopsworks.exceptions.PythonException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) RESTException(io.hops.hopsworks.restutils.RESTException) SQLException(java.sql.SQLException) ElasticException(io.hops.hopsworks.exceptions.ElasticException) AlertManagerConfigUpdateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException) IOException(java.io.IOException) ServiceException(io.hops.hopsworks.exceptions.ServiceException) UserException(io.hops.hopsworks.exceptions.UserException) ExecutionException(java.util.concurrent.ExecutionException) ServingException(io.hops.hopsworks.exceptions.ServingException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) CryptoPasswordNotFoundException(io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException) ProjectException(io.hops.hopsworks.exceptions.ProjectException) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerConfigReadException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) JobException(io.hops.hopsworks.exceptions.JobException) GenericException(io.hops.hopsworks.exceptions.GenericException) AlertManagerConfigCtrlCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException) KafkaException(io.hops.hopsworks.exceptions.KafkaException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ProvenanceException(io.hops.hopsworks.exceptions.ProvenanceException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) SchemaException(io.hops.hopsworks.exceptions.SchemaException) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) HdfsGroups(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups) YarnClientWrapper(io.hops.hopsworks.common.yarn.YarnClientWrapper) HashSet(java.util.HashSet)

Example 4 with HdfsGroups

use of io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups in project hopsworks by logicalclocks.

the class DistributedFsService method getDfsOpsForTesting.

public DistributedFileSystemOps getDfsOpsForTesting(String username) {
    if (username == null || username.isEmpty()) {
        throw new NullPointerException("username not set.");
    }
    // Get hdfs groups
    Collection<HdfsGroups> groups = hdfsUsersFacade.findByName(username).getHdfsGroupsCollection();
    String[] userGroups = new String[groups.size()];
    Iterator<HdfsGroups> iter = groups.iterator();
    int i = 0;
    while (iter.hasNext()) {
        userGroups[i] = iter.next().getName();
        i++;
    }
    UserGroupInformation ugi;
    try {
        ugi = UserGroupInformation.createProxyUserForTesting(username, UserGroupInformation.getLoginUser(), userGroups);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
        return null;
    }
    if (settings.getHopsRpcTls()) {
        // Runtime exceptions are not useful
        try {
            bhcs.materializeCertsForNonSuperUser(username);
            Configuration newConf = new Configuration(conf);
            bhcs.configureTlsForProjectSpecificUser(username, transientDir, newConf);
            return new DistributedFileSystemOps(ugi, newConf);
        } catch (CryptoPasswordNotFoundException ex) {
            logger.log(Level.SEVERE, ex.getMessage(), ex);
            bhcs.removeNonSuperUserCertificate(username);
            return null;
        }
    }
    return new DistributedFileSystemOps(ugi, conf);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CryptoPasswordNotFoundException(io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException) HdfsGroups(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 5 with HdfsGroups

use of io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups in project hopsworks by logicalclocks.

the class HdfsUsersController method removeFromGroup.

private void removeFromGroup(String hdfsUserName, String group, DistributedFileSystemOps dfso) throws IOException {
    HdfsGroups hdfsGroup = hdfsGroupsFacade.findByName(group);
    HdfsUsers hdfsUser = hdfsUsersFacade.findByName(hdfsUserName);
    removeFromGroup(hdfsUser, hdfsGroup, dfso);
// user not in group
}
Also used : HdfsGroups(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)

Aggregations

HdfsGroups (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsGroups)9 CryptoPasswordNotFoundException (io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException)3 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)3 IOException (java.io.IOException)3 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)2 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)2 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)2 AlertManagerConfigCtrlCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException)2 AlertManagerConfigReadException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException)2 AlertManagerConfigUpdateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException)2 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)2 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)2 YarnClientWrapper (io.hops.hopsworks.common.yarn.YarnClientWrapper)2 AlertException (io.hops.hopsworks.exceptions.AlertException)2 DatasetException (io.hops.hopsworks.exceptions.DatasetException)2 ElasticException (io.hops.hopsworks.exceptions.ElasticException)2 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)2 GenericException (io.hops.hopsworks.exceptions.GenericException)2 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)2 JobException (io.hops.hopsworks.exceptions.JobException)2