reanahub / reana-workflow-engine-serial

REANA Workflow Engine Serial
http://reana-workflow-engine-serial.readthedocs.org
MIT License
0 stars 33 forks source link

job-submission: job_name too long #44

Closed diegodelemos closed 5 years ago

diegodelemos commented 5 years ago

Since we are not yet allowing to name each command of a workflow, we use the command itself to name the job. This causes an unhandled exception when name (aka command) is bigger than the specified maximum in REANA DB models.

Job spec inside r-w-e-serial:

>>> job_spec['job_name']
'echo "Running code/helloworld.py with sleeptime 2 and\n      using inputs/names.txt as input."\npython "code/helloworld.py" --sleeptime "2" \\\n                       --inputfile "inputs/names.txt" \\\n                       --outputfile "outputs/greetings.txt"\n'
>>> len(job_spec['job_name'])
256

Logs from job controller.

$ kubectl logs job-controller-7b654c68d9-wg2sv
sqlalchemy.exc.DataError: (psycopg2.DataError) value too long for type character varying(256)
 [SQL: 'INSERT INTO job (created, updated, id_, workflow_uuid, status, job_type, cvmfs_mounts, shared_file_system, docker_img, experiment, cmd, env_vars, restart_count, max_restart_count, deleted, logs, prettified_cmd, name) VALUES (%(created)s, %(updated)s, %(id_)s, %(workflow_uuid
)s, %(status)s, %(job_type)s, %(cvmfs_mounts)s, %(shared_file_system)s, %(docker_img)s, %(experiment)s, %(cmd)s, %(env_vars)s, %(restart_count)s, %(max_restart_count)s, %(deleted)s, %(logs)s, %(prettified_cmd)s, %(name)s)'] [parameters: {'created': datetime.datetime(2018, 9, 24, 8,
45, 4, 412872), 'updated': datetime.datetime(2018, 9, 24, 8, 45, 4, 412885), 'id_': UUID('ce485474-f01c-4dcd-98b6-649c974fb16a'), 'workflow_uuid': None, 'status': 'started', 'job_type': 'kubernetes', 'cvmfs_mounts': [], 'shared_file_system': True, 'docker_img': 'python:2.7', 'experi
ment': 'default', 'cmd': 'bash -c "cd /reana/users/00000000-0000-0000-0000-000000000000/workflows/fbbdbe1e-675c-477f-b493-606bf0c7f6f6 ; echo \\"Running code/helloworld.py wit ... (101 characters truncated) ... eeptime \\"2\\" \\\n                       --inputfile \\"inputs/names.t
xt\\" \\\n                       --outputfile \\"outputs/greetings.txt\\"\n "', 'env_vars': '{}', 'restart_count': 0, 'max_restart_count': 3, 'deleted': False, 'logs': None, 'prettified_cmd': 'echo "Running code/helloworld.py with sleeptime 2 and \\\n      using inputs/names.txt as
input."\npython "code/helloworld.py" --sleeptime "2" \\\n                       --inputfile "inputs/names.txt" \\\n                       --outputfile "outputs/greetings.txt"\n', 'name': 'echo "Running code/helloworld.py with sleeptime 2 and \\\n      using inputs/names.txt as input
."\npython "code/helloworld.py" --sleeptime "2" \\\n                       --inputfile "inputs/names.txt" \\\n                       --outputfile "outputs/greetings.txt"\n'}] (Background on this error at: http://sqlalche.me/e/9h9h)
tiborsimko commented 5 years ago

Quick fix:

diff --git a/reana_workflow_engine_serial/utils.py b/reana_workflow_engine_serial/utils.py
index ac91246..0e1d0c3 100644
--- a/reana_workflow_engine_serial/utils.py
+++ b/reana_workflow_engine_serial/utils.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 #
 # This file is part of REANA.
-# Copyright (C) 2018 CERN.
+# Copyright (C) 2018, 2019 CERN.
 #
 # REANA is free software; you can redistribute it and/or modify it
 # under the terms of the MIT License; see LICENSE file for more details.
@@ -55,7 +55,7 @@ def build_job_spec(image, command, workflow_workspace, mount_cvmfs):
                 workflow_workspace, escape_shell_arg(command)),
             "prettified_cmd": command,
             "workflow_workspace": workflow_workspace,
-            "job_name": command,
+            "job_name": command[:255],
             "cvmfs_mounts": []
     }
     if mount_cvmfs:
tiborsimko commented 5 years ago

Solved via https://github.com/reanahub/reana-db/pull/27