Search in sources :

Example 1 with JobLogger

use of edu.iu.dsc.tws.rsched.schedulers.k8s.logger.JobLogger in project twister2 by DSC-SPIDAL.

the class KubernetesLauncher method launch.

/**
 * Launch the processes according to the resource plan.
 *
 * @return true if the request is granted
 */
@Override
public Twister2JobState launch(JobAPI.Job job) {
    Twister2JobState state = new Twister2JobState(false);
    if (!configParametersOK(job)) {
        return state;
    }
    String jobID = job.getJobId();
    String jobPackageFile = SchedulerContext.temporaryPackagesPath(config) + "/" + SchedulerContext.jobPackageFileName(config);
    File jobFile = new File(jobPackageFile);
    if (!jobFile.exists()) {
        LOG.log(Level.SEVERE, "Can not access job package file: " + jobPackageFile + "\n++++++++++++++++++ Aborting submission ++++++++++++++++++");
        return state;
    }
    long jobFileSize = jobFile.length();
    // check all relevant entities on Kubernetes master
    boolean allEntitiesOK = checkEntitiesForJob(job);
    if (!allEntitiesOK) {
        return state;
    }
    long jobSubmitTime = System.currentTimeMillis();
    String encodedNodeList = getNodeInfoList();
    RequestObjectBuilder.init(config, job.getJobId(), jobFileSize, jobSubmitTime, encodedNodeList);
    JobMasterRequestObject.init(config, job.getJobId());
    // initialize the service in Kubernetes master
    boolean servicesCreated = initServices(jobID);
    if (!servicesCreated) {
        clearupWhenSubmissionFails(jobID);
        return state;
    }
    // create the ConfigMap
    V1ConfigMap configMap = RequestObjectBuilder.createConfigMap(job);
    boolean cmCreated = controller.createConfigMap(configMap);
    if (cmCreated) {
        jobSubmissionStatus.setConfigMapCreated(true);
    } else {
        LOG.severe("Following ConfigMap could not be created: " + configMap.getMetadata().getName() + "\n++++++++++++++++++ Aborting submission ++++++++++++++++++");
        clearupWhenSubmissionFails(jobID);
        return state;
    }
    // if persistent volume is requested, create a persistent volume claim
    if (SchedulerContext.persistentVolumeRequested(config)) {
        // create pvc
        if (!CheckpointingContext.startingFromACheckpoint(config) || !CheckpointingContext.isNfsUsed(config)) {
            boolean volumesSetup = initPersistentVolumeClaim(job);
            if (!volumesSetup) {
                clearupWhenSubmissionFails(jobID);
                return state;
            }
        }
    }
    // initialize StatefulSets for this job
    boolean statefulSetInitialized = initStatefulSets(job);
    if (!statefulSetInitialized) {
        clearupWhenSubmissionFails(jobID);
        return state;
    }
    // start the Job Master locally if requested
    if (JobMasterContext.jobMasterRunsInClient(config)) {
        boolean jobMasterCompleted = startJobMasterOnClient(job);
        if (!jobMasterCompleted) {
            LOG.log(Level.SEVERE, "JobMaster can not be started. " + "\n++++++++++++++++++ Aborting submission ++++++++++++++++++");
            clearupWhenSubmissionFails(jobID);
            return state;
        }
    }
    if (KubernetesContext.logInClient(config)) {
        jobLogger = new JobLogger(namespace, job);
        jobLogger.start();
    }
    state.setRequestGranted(true);
    return state;
}
Also used : Twister2JobState(edu.iu.dsc.tws.api.scheduler.Twister2JobState) JobLogger(edu.iu.dsc.tws.rsched.schedulers.k8s.logger.JobLogger) File(java.io.File) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap)

Aggregations

Twister2JobState (edu.iu.dsc.tws.api.scheduler.Twister2JobState)1 JobLogger (edu.iu.dsc.tws.rsched.schedulers.k8s.logger.JobLogger)1 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 File (java.io.File)1