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
Show 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():
...
@@ -77,8 +77,11 @@ def initialize_kubernetes_api():
print
(
'
Connect to kubernetes api
'
)
print
(
'
Connect to kubernetes api
'
)
try
:
try
:
config
.
load_kube_config
()
# try using local config
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
# 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
()
config
.
load_incluster_config
()
coreApi
=
client
.
CoreV1Api
()
coreApi
=
client
.
CoreV1Api
()
...
@@ -120,8 +123,9 @@ def load_yaml(file_path):
...
@@ -120,8 +123,9 @@ def load_yaml(file_path):
f
=
open
(
path
.
join
(
path
.
dirname
(
__file__
),
file_path
))
f
=
open
(
path
.
join
(
path
.
dirname
(
__file__
),
file_path
))
with
f
:
with
f
:
return
yaml
.
safe_load
(
f
)
return
yaml
.
safe_load
(
f
)
except
:
except
Exception
as
e
:
print
(
'
Error opening file %s
'
%
file_path
)
logging
.
error
(
'
Error opening file %s
'
%
file_path
)
logging
.
error
(
e
)
def
load_yaml_files
():
def
load_yaml_files
():
...
@@ -198,7 +202,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -198,7 +202,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
Service
'
%s
'
created.
"
%
svc
.
metadata
.
name
)
print
(
"
Service
'
%s
'
created.
"
%
svc
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
except
client
.
rest
.
ApiException
as
e
:
svc
=
svc_yaml
svc
=
svc_yaml
print
(
"
Service creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
Service creation error: %s
"
%
e
.
reason
)
# Create custom object service monitor
# Create custom object service monitor
try
:
try
:
...
@@ -212,7 +216,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -212,7 +216,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
ServiceMonitor
'
%s
'
created.
"
%
svc_monitor
[
'
metadata
'
][
'
name
'
])
print
(
"
ServiceMonitor
'
%s
'
created.
"
%
svc_monitor
[
'
metadata
'
][
'
name
'
])
except
client
.
rest
.
ApiException
as
e
:
except
client
.
rest
.
ApiException
as
e
:
svc_monitor
=
svc_monitor_yaml
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
# Apply jmx config map for aggregation service
try
:
try
:
...
@@ -221,7 +225,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -221,7 +225,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
ConfigMap
'
%s
'
created.
"
%
jmx_cm
.
metadata
.
name
)
print
(
"
ConfigMap
'
%s
'
created.
"
%
jmx_cm
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
except
client
.
rest
.
ApiException
as
e
:
jmx_cm
=
jmx_yaml
jmx_cm
=
jmx_yaml
print
(
"
ConfigMap creation error: %s
"
%
e
.
reason
)
logging
.
error
(
"
ConfigMap creation error: %s
"
%
e
.
reason
)
# Create deployment
# Create deployment
deploy_yaml
[
'
spec
'
][
'
replicas
'
]
=
args
.
instances
deploy_yaml
[
'
spec
'
][
'
replicas
'
]
=
args
.
instances
...
@@ -241,7 +245,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -241,7 +245,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
print
(
"
Deployment
'
%s
'
created.
"
%
app_deploy
.
metadata
.
name
)
print
(
"
Deployment
'
%s
'
created.
"
%
app_deploy
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
except
client
.
rest
.
ApiException
as
e
:
app_deploy
=
deploy_yaml
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
return
svc
,
svc_monitor
,
jmx_cm
,
app_deploy
...
@@ -277,7 +281,7 @@ def delete_resource(obj, del_func):
...
@@ -277,7 +281,7 @@ def delete_resource(obj, del_func):
try
:
try
:
del_func
(
obj
[
'
metadata
'
][
'
name
'
],
'
default
'
)
del_func
(
obj
[
'
metadata
'
][
'
name
'
],
'
default
'
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
"
Error deleting resource
"
)
logging
.
error
(
"
Error deleting resource
"
)
logging
.
error
(
e
)
logging
.
error
(
e
)
return
return
print
(
'
Resource deleted
'
)
print
(
'
Resource deleted
'
)
...
@@ -366,6 +370,7 @@ def delete_topics(topics):
...
@@ -366,6 +370,7 @@ def delete_topics(topics):
break
break
return
return
def
reset_zookeeper
():
def
reset_zookeeper
():
"""
Delete ZooKeeper configurations used for workload generation.
"""
Delete ZooKeeper configurations used for workload generation.
"""
"""
...
@@ -378,7 +383,8 @@ def reset_zookeeper():
...
@@ -378,7 +383,8 @@ def reset_zookeeper():
'
--
'
,
'
--
'
,
'
bash
'
,
'
bash
'
,
'
-c
'
,
'
-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
=
[
check_zoo_data_command
=
[
...
@@ -392,22 +398,29 @@ def reset_zookeeper():
...
@@ -392,22 +398,29 @@ def reset_zookeeper():
# "| awk -F[\]\[] '{print $2}'"
# "| awk -F[\]\[] '{print $2}'"
]
]
output
=
subprocess
.
run
(
delete_zoo_data_command
,
capture_output
=
True
,
text
=
True
)
logging
.
info
(
output
.
stdout
)
# Wait for configuration deletion
# Wait for configuration deletion
while
True
:
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
)
logging
.
debug
(
output
)
if
'
workload-generation
'
in
output
.
stdout
:
if
'
workload-generation
'
in
output
.
stdout
:
print
(
'
ZooKeeper reset was not successful. Retrying in 5s.
'
)
print
(
'
ZooKeeper reset was not successful. Retrying in 5s.
'
)
time
.
sleep
(
5
)
time
.
sleep
(
5
)
else
:
else
:
logging
.
info
(
'
ZooKeeper reset was successful.
'
)
print
(
'
ZooKeeper reset was successful.
'
)
break
break
return
return
def
stop_lag_exporter
():
def
stop_lag_exporter
():
"""
"""
Stop the lag exporter in order to reset it and allow smooth execution for
Stop the lag exporter in order to reset it and allow smooth execution for
...
@@ -442,6 +455,7 @@ def stop_lag_exporter():
...
@@ -442,6 +455,7 @@ def stop_lag_exporter():
# def stop():
# def stop():
#
#
def
main
():
def
main
():
load_variables
()
load_variables
()
print
(
'
---------------------
'
)
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