Example #1
0
def run_task(data, filer_name, filer_version):
    task_name = data['executors'][0]['metadata']['labels']['taskmaster-name']
    pvc = None

    if data['volumes'] or data['inputs'] or data['outputs']:

        filer = Filer(task_name + '-filer', data, filer_name, filer_version,
                      args.pull_policy_always)
        if os.environ.get('TESK_FTP_USERNAME') is not None:
            filer.set_ftp(os.environ['TESK_FTP_USERNAME'],
                          os.environ['TESK_FTP_PASSWORD'])

        pvc = init_pvc(data, filer)

    for executor in data['executors']:
        run_executor(executor, args.namespace, pvc)

    # run executors
    logging.debug("Finished running executors")

    # upload files and delete pvc
    if data['volumes'] or data['inputs'] or data['outputs']:
        filerjob = Job(filer.get_spec('outputs', args.debug),
                       task_name + '-outputs-filer', args.namespace)

        global created_jobs
        created_jobs.append(filerjob)

        # filerjob.run_to_completion(poll_interval)
        status = filerjob.run_to_completion(poll_interval, check_cancelled,
                                            args.pod_timeout)
        if status != 'Complete':
            exit_cancelled('Got status ' + status)
        else:
            pvc.delete()
Example #2
0
    def test_mounts_file_disabled(self):

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        pprint(f.getVolumeMounts())

        self.assertEquals(f.getVolumeMounts(), [])
        self.assertEquals(f.getVolumes(), [])
Example #3
0
    def setUp(self):
        self.data = json.loads(
            open(
                os.path.join(os.path.dirname(__file__),
                             "resources/inputFile.json")).read())
        self.task_name = self.data['executors'][0]['metadata']['labels'][
            'taskmaster-name']
        taskmaster.args = Namespace(debug=False,
                                    file=None,
                                    filer_version='v0.1.9',
                                    json='json',
                                    namespace='default',
                                    poll_interval=5,
                                    state_file='/tmp/.teskstate',
                                    localKubeConfig=False,
                                    pull_policy_always=False,
                                    filer_name="eu.gcr.io/tes-wes/filer",
                                    pod_timeout=240)
        self.filer = Filer(self.task_name + '-filer', self.data,
                           taskmaster.args.filer_name,
                           taskmaster.args.filer_version,
                           taskmaster.args.pull_policy_always)
        self.pvc = PVC(self.task_name + '-pvc',
                       self.data['resources']['disk_gb'],
                       taskmaster.args.namespace)

        taskmaster.created_jobs = []
Example #4
0
    def test_env_vars(self):

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        self.assertEquals(f.getEnv(), [{
            'name': 'JSON_INPUT',
            'value': '{"a": 1}'
        }, {
            'name': 'HOST_BASE_PATH',
            'value': '/home/tfga/workspace/cwl-tes'
        }, {
            'name': 'CONTAINER_BASE_PATH',
            'value': '/transfer'
        }])
Example #5
0
    def test_image_pull_policy(self):

        f = Filer('name', {'a': 1})
        self.assertEquals(f.getImagePullPolicy(), 'IfNotPresent')

        f = Filer('name', {'a': 1}, pullPolicyAlways=True)
        self.assertEquals(f.getImagePullPolicy(), 'Always')
Example #6
0
    def test_mounts(self):
        '''
        kind: Pod
        apiVersion: v1
        metadata:
          name: tfga-pod
        spec:
          containers:
            - name: tfga-container
              image: eu.gcr.io/tes-wes/filer:testing
              volumeMounts:
                - mountPath: /transfer
                  name: transfer-volume
          volumes:
            - name: transfer-volume
              hostPath:
                path: /transferAtNode
              # persistentVolumeClaim:
              #  claimName: task-pv-claim
        '''

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        pprint(f.getVolumeMounts())

        self.assertEquals(f.getVolumeMounts(),
                          [{
                              "name": 'transfer-volume',
                              'mountPath': path.CONTAINER_BASE_PATH
                          }])

        self.assertEquals(f.getVolumes(), [{
            "name": 'transfer-volume',
            'persistentVolumeClaim': {
                'claimName': 'transfer-pvc'
            }
        }])