Skip to content

Commit 9e6bd2f

Browse files
committed
Added docs for deploy info file generation
Signed-off-by: aryans1204 <arshar1204@gmail.com>
1 parent 50da097 commit 9e6bd2f

File tree

7 files changed

+110
-4
lines changed

7 files changed

+110
-4
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
workloads/container/vSwarm_deploy_metadata.tar.gz filter=lfs diff=lfs merge=lfs -text

.github/workflows/e2e_loader.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Untar vSwarm YAMLs
6060
if: ${{ always() }}
6161
run: |
62-
tar -xzvf workloads/container/yamls.tar.gz -C workloads/container/
62+
tar -xzvf workloads/container/vSwarm_deploy_metadata.tar.gz -C workloads/container/
6363
- name: Run vSwarm loader
6464
run: go run cmd/loader.go --config pkg/config/test_vswarm_config.json
6565

docs/generate_deploy_info_docs.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
# Deploy Info JSON
22

3-
## The `deploy_info.json` file in the `yamls.tar.gz` is used to identify the relative file paths for the Knative YAML manifests for deploying vSwarm functions. It is generated using `generate_deploy_info.py` Python script, also present under `yamls.tar.gz`, which outputs a JSON that embeds the yaml-location and pre-deployment commands for every vSwarm function.
3+
## The `deploy_info.json` file in the `yamls.tar.gz` is used to identify the relative file paths for the Knative YAML manifests for deploying vSwarm functions. It is generated using `generate_deploy_info.py` Python script, also present under `yamls.tar.gz`, which outputs a JSON that embeds the yaml-location and pre-deployment commands for every vSwarm function. zit also contains the path of YAML files needed as part of the predeployment commands to run certain vSwarm benchmakrs, for example the `online-shop-database` which requires to be deployed before running `cartservice` benchmark.
44

55
## While the `deploy_info.json` file ships with the `yamls.tar.gz`, In order to regenerate the `deploy_info.json` run:
66
```console
7-
tar -xzvf workloads/container/yamls.tar.gz -C workloads/container
7+
tar -xzvf workloads/container/vSwarm_deploy_metadata.tar.gz -C workloads/container
88
cd workloads/container/yamls/
99
python3 generate_deploy_info.py
10+
```
11+
12+
The `deploy_info.json` has the following schema:
13+
```console
14+
{
15+
vswarm-function-name:
16+
{
17+
YamlLocation: /path/to/yaml
18+
PredeploymentPath: [/path/to/predeployment/yaml]
19+
}
20+
}
1021
```

docs/loader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ git lfs checkout
123123
This retrieves the `yamls.tar.gz` from Git LFS. Then, untar this tarball by running the following command from the root of this directory:
124124

125125
```bash
126-
$ tar -xzvf workloads/container/yamls.tar.gz -C workloads/container/
126+
$ tar -xzvf workloads/container/vSwarm_deploy_metadata.tar.gz -C workloads/container/
127127
```
128128

129129
## Single execution
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Write a python script to run go through each directory and generate the yaml files by running the python script inside each directory
2+
3+
import os
4+
import subprocess
5+
6+
# Get the current working directory
7+
yaml_dir = os.getcwd()+"/yamls"
8+
9+
# Get the list of directories
10+
directories = [d for d in os.listdir(yaml_dir) if os.path.isdir(d)]
11+
12+
# Go through each directory and run the python script
13+
for directory in directories:
14+
os.chdir(directory)
15+
# Run the python script
16+
subprocess.run(['python3', 'generate-yamls.py'])
17+
print(f"Generated yaml files for {directory}")
18+
os.chdir(current_dir)
19+
20+
print("Generated all yaml files")
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Write a script to generate the deploy info for each yaml file based on the directory and write to a json calleds deploy_info.json
2+
3+
# Example
4+
# "aes-python-20000-20200": {
5+
# "yaml-location": "./yamls/aes-python/kn-aes-python-20000-20200.yaml",
6+
# "predeployment-commands": []
7+
# },
8+
#
9+
import os
10+
import glob
11+
import json
12+
13+
# Get the current working directory
14+
current_dir = os.getcwd()+"/yamls"
15+
16+
# Get the list of directories
17+
directories = [d for d in os.listdir(current_dir) if os.path.isdir(d)]
18+
19+
predeployment_required = ["hotel-app", "image-rotate-python", "image-rotate-go", "video-processing", "video-analytics-standalone", "online-shop"]
20+
21+
deploy_info = {}
22+
for directory in directories:
23+
os.chdir(directory)
24+
# Get the list of yaml files
25+
yaml_files = glob.glob("*.yaml")
26+
function_name = {}
27+
for yaml_file in yaml_files:
28+
function_name[yaml_file] = yaml_file.replace(".yaml", "")
29+
function_name[yaml_file] = function_name[yaml_file].replace("kn-", "")
30+
for yaml_file in yaml_files:
31+
if directory in predeployment_required:
32+
if directory == "hotel-app":
33+
deploy_info[directory + '-' + function_name[yaml_file]] = {
34+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
35+
"PredeploymentPath": [f"workloads/container/yamls/hotel-app/database.yaml"]
36+
}
37+
elif directory == "online-shop":
38+
deploy_info[function_name[yaml_file]] = {
39+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
40+
"PredeploymentPath": [f"workloads/container/yamls/online-shop/database.yaml"]
41+
}
42+
elif directory == "image-rotate-go" or directory == "image-rotate-python":
43+
deploy_info[function_name[yaml_file]] = {
44+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
45+
"PredeploymentPath": [f"workloads/container/yamls/{directory}/image-rotate-database.yaml"]
46+
}
47+
elif directory == "video-processing":
48+
deploy_info[function_name[yaml_file]] = {
49+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
50+
"PredeploymentPath": [f"workloads/container/yamls/{directory}/video-processing-database.yaml"]
51+
}
52+
elif directory == "video-analytics-standalone":
53+
deploy_info[function_name[yaml_file]] = {
54+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
55+
"PredeploymentPath": [f"workloads/container/yamls/{directory}/video-analytics-standalone-database.yaml"]
56+
}
57+
else:
58+
deploy_info[function_name[yaml_file]] = {
59+
"YamlLocation": f"workloads/container/yamls/{directory}/{yaml_file}",
60+
"PredeploymentPath": []
61+
}
62+
63+
64+
os.chdir(current_dir)
65+
66+
# Write the deploy info to a json file
67+
deploy_keys = sorted(deploy_info)
68+
sorted_deploy_info = {}
69+
for key in deploy_keys:
70+
sorted_deploy_info[key] = deploy_info[key]
71+
with open("deploy_info.json", "w") as f:
72+
f.write(json.dumps(sorted_deploy_info, indent=4))
73+
print("Generated deploy info json file")
74+
File renamed without changes.

0 commit comments

Comments
 (0)