Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fnndsc master #110

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 53 additions & 17 deletions openshift/pfcon-openshift-template.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@
"containers": [{
"command": [
"/usr/local/bin/pfcon",
"--forever",
"--httpResponse",
"--swift-storage",
"--createDirsAsNeeded",
"--enableTokenAuth",
"--tokenPath=/etc/pfcon/auth/pfcon_config.cfg"
"--verbosity=5",
"--port=5005"
],
"image": "fnndsc/pfcon",
"image": "ghcr.io/sandip117/pfcon:flask",
"imagePullPolicy": "Always",
"name": "pfcon",
"ports": [{
Expand All @@ -69,36 +65,76 @@
}
},
"terminationMessagePath": "/dev/termination-log",
"volumeMounts": [
"volumeMounts": [{
"name": "kubecfg-volume",
"mountPath": "/tmp/.kube/",
"readOnly": true
},
{
"name": "gluster-vol1",
"mountPath": "/tmp"
},
{
"mountPath": "/etc/swift",
"name": "swift-credentials",
"readOnly": true
},
{
"name": "pfcon-config",
"mountPath": "/etc/pfcon/auth",
"readOnly": true
"mountPath": "/local",
"name": "local-volume"
}
],
"env": [{
"name": "KUBECFG_PATH",
"value": "/tmp/.kube/config"
},
{
"name": "OPENSHIFTMGR_PROJECT",
"value": "test-moc"
},
{
"name": "COMPUTE_SERVICE_URL",
"value": "http://pman-test-moc.k-apps.osh.massopen.cloud/api/v1/"
},
{
"name": "STORE_ENV",
"value": "swift"
},
{
"name":"APPLICATION_MODE",
"value":"local"
}
]

}],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"volumes": [
"volumes": [{
"name": "kubecfg-volume",
"secret": {
"secretName": "kubecfg"
}
},
{
"name": "gluster-vol1",
"persistentVolumeClaim": {
"claimName": "gluster1"
}
},
{
"name": "swift-credentials",
"secret": {
"defaultMode": 420,
"secretName": "swift-credentials"
}
},
{
"name": "pfcon-config",
"secret": {
"secretName": "pfcon-config"
{
"name": "local-volume",
"emptyDir": {}
}
}]
]

}
},
"test": false,
Expand Down
8 changes: 5 additions & 3 deletions pfcon/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

from logging.config import dictConfig
from environs import Env
import os


class Config:
Expand All @@ -17,7 +18,7 @@ def __init__(self):
env = Env()
env.read_env() # also read .env file, if it exists

self.STORE_ENV = env('STORE_ENV', 'mount')
self.STORE_ENV = env('STORE_ENV', 'mount') or os.environ.get('STORE_ENV')
if self.STORE_ENV == 'mount':
self.STORE_BASE = '/home/localuser/storeBase'

Expand Down Expand Up @@ -73,8 +74,9 @@ def __init__(self):
})

# EXTERNAL SERVICES
self.COMPUTE_SERVICE_URL = 'http://pman:5010/api/v1/'

self.COMPUTE_SERVICE_URL = os.environ.get('COMPUTE_SERVICE_URL') if os.environ.get('COMPUTE_SERVICE_URL') is not None \
else 'http://pman:5010/api/v1/'


class ProdConfig(Config):
"""
Expand Down
22 changes: 20 additions & 2 deletions pfcon/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .services import PmanService, ServiceException
from .mount_dir import MountDir

from .swift_store import SwiftStore

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -70,7 +70,13 @@ def post(self):
logger.error(f'Error while decompressing and storing job {job_id} data, '
f'detail: {str(e)}')
abort(400, message='data_file: Bad zip file')
logger.info(f'Successfully stored job {job_id} input data')

if self.store_env == 'swift':
os.makedirs(f'/tmp/key-{job_id}/outgoing',exist_ok=True)
swift = SwiftStore(app.config)
d_info = swift.storeData(job_id, "", request.files['data_file'])

logger.info(f'Successfully stored job {job_id} input data')

# process compute
compute_data = {
Expand Down Expand Up @@ -119,6 +125,10 @@ def get(self, job_id):
}

def delete(self, job_id):
if self.store_env == 'swift':
job_dir = "/tmp/key-"+job_id
swift = SwiftStore(app.config)
swift.deleteData(job_dir)
if self.store_env == 'mount':
storebase = app.config.get('STORE_BASE')
job_dir = os.path.join(storebase, 'key-' + job_id)
Expand Down Expand Up @@ -159,4 +169,12 @@ def get(self, job_id):
logger.info(f'Retrieving job {job_id} output data')
content = mdir.get_data(job_id, outgoing_dir)
logger.info(f'Successfully retrieved job {job_id} output data')

if self.store_env == 'swift':

swift = SwiftStore(app.config)
logger.info(f'Retrieving job {job_id} output data')

content = swift.getData(job_id, "")
logger.info(f'Successfully retrieved job {job_id} output data')
return Response(content, mimetype='application/zip')
Loading