Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
d4547b3a
Commit
d4547b3a
authored
4 years ago
by
Björn Vonheiden
Browse files
Options
Downloads
Patches
Plain Diff
Add logging to run uc py
parent
ed51b544
No related branches found
No related tags found
2 merge requests
!42
Integerate theodolite and run uc python scripts
,
!24
run UC as python implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
execution/run_uc.py
+28
-14
28 additions, 14 deletions
execution/run_uc.py
with
28 additions
and
14 deletions
execution/run_uc.py
+
28
−
14
View file @
d4547b3a
...
...
@@ -77,8 +77,11 @@ def initialize_kubernetes_api():
print
(
'
Connect to kubernetes api
'
)
try
:
config
.
load_kube_config
()
# try using local config
except
config
.
config_exception
.
ConfigException
:
except
config
.
config_exception
.
ConfigException
as
e
:
# load config from pod, if local config is not available
logging
.
debug
(
'
Failed loading local Kubernetes configuration,
'
+
'
try from cluster
'
)
logging
.
debug
(
e
)
config
.
load_incluster_config
()
coreApi
=
client
.
CoreV1Api
()
...
...
@@ -120,8 +123,9 @@ def load_yaml(file_path):
f
=
open
(
path
.
join
(
path
.
dirname
(
__file__
),
file_path
))
with
f
:
return
yaml
.
safe_load
(
f
)
except
:
print
(
'
Error opening file %s
'
%
file_path
)
except
Exception
as
e
:
logging
.
error
(
'
Error opening file %s
'
%
file_path
)
logging
.
error
(
e
)
def
load_yaml_files
():
...
...
@@ -198,7 +202,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
Service
'
%s
'
created.
"
%
svc
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
svc
=
svc_yaml
print
(
"
Service creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
Service creation error: %s
"
%
e
.
reason
)
# Create custom object service monitor
try
:
...
...
@@ -212,7 +216,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
ServiceMonitor
'
%s
'
created.
"
%
svc_monitor
[
'
metadata
'
][
'
name
'
])
except
client
.
rest
.
ApiException
as
e
:
svc_monitor
=
svc_monitor_yaml
print
(
"
ServiceMonitor creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
ServiceMonitor creation error: %s
"
%
e
.
reason
)
# Apply jmx config map for aggregation service
try
:
...
...
@@ -221,7 +225,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
ConfigMap
'
%s
'
created.
"
%
jmx_cm
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
jmx_cm
=
jmx_yaml
print
(
"
ConfigMap creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
ConfigMap creation error: %s
"
%
e
.
reason
)
# Create deployment
deploy_yaml
[
'
spec
'
][
'
replicas
'
]
=
args
.
instances
...
...
@@ -241,7 +245,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
Deployment
'
%s
'
created.
"
%
app_deploy
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
app_deploy
=
deploy_yaml
print
(
"
Deployment creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
Deployment creation error: %s
"
%
e
.
reason
)
return
svc
,
svc_monitor
,
jmx_cm
,
app_deploy
...
...
@@ -277,7 +281,7 @@ def delete_resource(obj, del_func):
try
:
del_func
(
obj
[
'
metadata
'
][
'
name
'
],
'
default
'
)
except
Exception
as
e
:
print
(
"
Error deleting resource
"
)
logging
.
error
(
"
Error deleting resource
"
)
logging
.
error
(
e
)
return
print
(
'
Resource deleted
'
)
...
...
@@ -366,6 +370,7 @@ def delete_topics(topics):
break
return
def
reset_zookeeper
():
"""
Delete ZooKeeper configurations used for workload generation.
"""
...
...
@@ -378,7 +383,8 @@ def reset_zookeeper():
'
--
'
,
'
bash
'
,
'
-c
'
,
'
zookeeper-shell my-confluent-cp-zookeeper:2181 deleteall /workload-generation
'
'
zookeeper-shell my-confluent-cp-zookeeper:2181 deleteall
'
+
'
/workload-generation
'
]
check_zoo_data_command
=
[
...
...
@@ -392,22 +398,29 @@ def reset_zookeeper():
# "| awk -F[\]\[] '{print $2}'"
]
output
=
subprocess
.
run
(
delete_zoo_data_command
,
capture_output
=
True
,
text
=
True
)
logging
.
info
(
output
.
stdout
)
# Wait for configuration deletion
while
True
:
output
=
subprocess
.
run
(
check_zoo_data_command
,
capture_output
=
True
,
text
=
True
)
# Delete Zookeeper configuration data
output
=
subprocess
.
run
(
delete_zoo_data_command
,
capture_output
=
True
,
text
=
True
)
logging
.
debug
(
output
.
stdout
)
# Check data is deleted
output
=
subprocess
.
run
(
check_zoo_data_command
,
capture_output
=
True
,
text
=
True
)
logging
.
debug
(
output
)
if
'
workload-generation
'
in
output
.
stdout
:
print
(
'
ZooKeeper reset was not successful. Retrying in 5s.
'
)
time
.
sleep
(
5
)
else
:
logging
.
info
(
'
ZooKeeper reset was successful.
'
)
print
(
'
ZooKeeper reset was successful.
'
)
break
return
def
stop_lag_exporter
():
"""
Stop the lag exporter in order to reset it and allow smooth execution for
...
...
@@ -442,6 +455,7 @@ def stop_lag_exporter():
# def stop():
#
def
main
():
load_variables
()
print
(
'
---------------------
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment