Use manual zkhandler creation in Benchmark job
Like the other Celery job this does not work properly with the ZKConnection decorator due to conflicting "self", so just connect manually exactly like the provisioner task does.
This commit is contained in:
parent
087c23859c
commit
47a522f8af
|
@ -24,7 +24,7 @@ import psycopg2.extras
|
||||||
|
|
||||||
from pvcapid.Daemon import config
|
from pvcapid.Daemon import config
|
||||||
|
|
||||||
from daemon_lib.zkhandler import ZKConnection
|
from daemon_lib.zkhandler import ZKHandler
|
||||||
|
|
||||||
import daemon_lib.common as pvc_common
|
import daemon_lib.common as pvc_common
|
||||||
import daemon_lib.ceph as pvc_ceph
|
import daemon_lib.ceph as pvc_ceph
|
||||||
|
@ -103,8 +103,7 @@ def list_benchmarks(job=None):
|
||||||
return {'message': 'No benchmark found.'}, 404
|
return {'message': 'No benchmark found.'}, 404
|
||||||
|
|
||||||
|
|
||||||
@ZKConnection(config)
|
def run_benchmark(self, pool):
|
||||||
def run_benchmark(self, zkhandler, pool):
|
|
||||||
# Runtime imports
|
# Runtime imports
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
@ -123,6 +122,13 @@ def run_benchmark(self, zkhandler, pool):
|
||||||
print('FATAL - failed to connect to Postgres')
|
print('FATAL - failed to connect to Postgres')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
try:
|
||||||
|
zkhandler = ZKHandler(config)
|
||||||
|
zkhandler.connect()
|
||||||
|
except Exception:
|
||||||
|
print('FATAL - failed to connect to Zookeeper')
|
||||||
|
raise Exception
|
||||||
|
|
||||||
print("Storing running status for job '{}' in database".format(cur_time))
|
print("Storing running status for job '{}' in database".format(cur_time))
|
||||||
try:
|
try:
|
||||||
query = "INSERT INTO storage_benchmarks (job, result) VALUES (%s, %s);"
|
query = "INSERT INTO storage_benchmarks (job, result) VALUES (%s, %s);"
|
||||||
|
@ -445,4 +451,7 @@ def run_benchmark(self, zkhandler, pool):
|
||||||
raise BenchmarkError("Failed to store test results: {}".format(e), cur_time=cur_time, db_conn=db_conn, db_cur=db_cur, zkhandler=zkhandler)
|
raise BenchmarkError("Failed to store test results: {}".format(e), cur_time=cur_time, db_conn=db_conn, db_cur=db_cur, zkhandler=zkhandler)
|
||||||
|
|
||||||
close_database(db_conn, db_cur)
|
close_database(db_conn, db_cur)
|
||||||
|
zkhandler.disconnect()
|
||||||
|
del zkhandler
|
||||||
|
|
||||||
return {'status': "Storage benchmark '{}' completed successfully.", 'current': 3, 'total': 3}
|
return {'status': "Storage benchmark '{}' completed successfully.", 'current': 3, 'total': 3}
|
||||||
|
|
Loading…
Reference in New Issue