-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.drawio
199 lines (199 loc) · 20.4 KB
/
design.drawio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<mxfile host="65bd71144e">
<diagram id="xYpieU3OsDlBosfl1Ia8" name="Page-1">
<mxGraphModel dx="1292" dy="217" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="13" style="edgeStyle=none;html=1;entryX=0;entryY=0.42;entryDx=0;entryDy=0;entryPerimeter=0;fontSize=13;" parent="1" source="11" target="12" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="11" value="<h1>Request Body</h1><p>1. language</p><p>2. entrypoint</p><p>3. files</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-830" y="20" width="190" height="150" as="geometry"/>
</mxCell>
<mxCell id="15" style="edgeStyle=none;html=1;fontSize=13;" parent="1" source="12" target="14" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="12" value="" style="aspect=fixed;perimeter=ellipsePerimeter;html=1;align=center;shadow=0;dashed=0;spacingTop=3;image;image=img/lib/active_directory/generic_server.svg;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-460" y="120" width="120" height="214.29" as="geometry"/>
</mxCell>
<mxCell id="14" value="<h1>Response body</h1><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-210" y="70" width="190" height="120" as="geometry"/>
</mxCell>
<mxCell id="16" value="<h1>Principles</h1><p>1. Security</p><p>2. Isolation</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-800" y="360" width="190" height="120" as="geometry"/>
</mxCell>
<mxCell id="17" value="<h1>Security</h1><p>1. Code Racer executions should not have network access</p><p>2. Code Racer executions should have a timeout of 15s. After 15s, the execution should be forcibly terminated</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-590" y="450" width="230" height="170" as="geometry"/>
</mxCell>
<mxCell id="18" value="<h1>Isolation</h1><p>Code Execution has some level of execution.</p><p>Each code execution task is be scheduled on one of 5 pools in a round robin/random fashion</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;fontSize=13;" parent="1" vertex="1">
<mxGeometry x="-800" y="640" width="190" height="180" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="eVpEn63QmF_tsTFyUnMM" name="Runtime manager">
<mxGraphModel dx="1112" dy="565" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="ty_xhHiwv_qMUtKukG_b-3" value="" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-1" target="ty_xhHiwv_qMUtKukG_b-2" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-1" value="Start" style="ellipse;shape=doubleEllipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="370" y="70" width="100" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-6" value="" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-2" target="ty_xhHiwv_qMUtKukG_b-5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-2" value="load manifest.yaml" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1">
<mxGeometry x="340" y="210" width="160" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-4" value="<h1>manifest.yml</h1><p>spec:</p><p>&nbsp; runtimes:</p><p>&nbsp; &nbsp; - language: python</p><p>&nbsp; &nbsp; &nbsp; image: python:3-alpine3.17</p><p>&nbsp; &nbsp; &nbsp; instances: 5</p><p>&nbsp; &nbsp; &nbsp; aliases:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; - python</p><p>&nbsp; &nbsp; &nbsp; &nbsp; - py</p><p>&nbsp; &nbsp; - language: node</p><p>&nbsp; &nbsp; &nbsp; image: node:18-alpine3.17</p><p>&nbsp; &nbsp; &nbsp; instances: 5</p><p>&nbsp; &nbsp; &nbsp; aliases:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; - nodejs</p><p>&nbsp; &nbsp; &nbsp; &nbsp; - javascript</p><p>&nbsp; &nbsp; &nbsp; &nbsp; - js</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="870" y="115" width="190" height="470" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-8" value="" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-5" target="ty_xhHiwv_qMUtKukG_b-7" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-5" value="Get runtime information. Eg, python" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="360" y="350" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-10" value="" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-7" target="ty_xhHiwv_qMUtKukG_b-9" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-7" value="Check the number of instances currently running" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="360" y="490" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-12" value="yes" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-9" target="ty_xhHiwv_qMUtKukG_b-11" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-16" value="No" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-9" target="ty_xhHiwv_qMUtKukG_b-15" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-9" value="Is the number of instances <br>running &gt; number specified in manifest?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="355" y="610" width="135" height="140" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-20" value="" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-11" target="ty_xhHiwv_qMUtKukG_b-19" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-11" value="Kill excess instances" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="362.5" y="820" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-18" value="yes" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-15" target="ty_xhHiwv_qMUtKukG_b-17" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-15" value="Is the number of instances running &lt; number specified in manifest?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="90" y="610" width="170" height="140" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-21" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-17" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="423" y="937.1428571428571" as="targetPoint"/>
<Array as="points">
<mxPoint x="170" y="940"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-17" value="Add more instances" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="115" y="810" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-23" style="edgeStyle=none;html=1;" parent="1" source="ty_xhHiwv_qMUtKukG_b-19" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="420" y="160" as="targetPoint"/>
<Array as="points">
<mxPoint x="710" y="1030"/>
<mxPoint x="720" y="160"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-19" value="Pause for 3 minutes" style="shape=ellipse;html=1;dashed=0;whitespace=wrap;aspect=fixed;strokeWidth=5;perimeter=ellipsePerimeter;" parent="1" vertex="1">
<mxGeometry x="372.5" y="980" width="100" height="100" as="geometry"/>
</mxCell>
<mxCell id="ty_xhHiwv_qMUtKukG_b-22" value="While there are more runtimes" style="edgeStyle=segmentEdgeStyle;endArrow=classic;html=1;curved=0;rounded=0;endSize=8;startSize=8;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="420" y="930" as="sourcePoint"/>
<mxPoint x="420" y="300" as="targetPoint"/>
<Array as="points">
<mxPoint x="620" y="930"/>
<mxPoint x="620" y="300"/>
</Array>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="G5SbLVb5rS5KRPmOLXK9" name="Code Execution">
<mxGraphModel dx="590" dy="449" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="ByjgU5PebDFaZexhVYaR-2" value="<h1>Request body</h1><p>{</p><p>&nbsp; &nbsp; "language": "python",</p><p>&nbsp; &nbsp; "entrypoint": "main.py",</p><p>&nbsp; &nbsp; "files": [</p><p>&nbsp; &nbsp; &nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": "main.py",</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "content": "print('hello world')"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; },</p><p>&nbsp; &nbsp; &nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": "__init__.py",</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "content": ""</p><p>&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; ]</p><p>}</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="20" y="20" width="280" height="440" as="geometry"/>
</mxCell>
<mxCell id="VDtfk-eA55_RWqB2SgVV-1" value="<h1>Algorithm</h1><p>1. User makes a request to the server with the request body</p><p>2. Validate user input</p><p>&nbsp; &nbsp; a. request must have the name of the language, entrypoint and files</p><p>&nbsp; &nbsp; b. the file must not start with "."</p><p>&nbsp; &nbsp; c. the entry point must be in the files</p><p>&nbsp; &nbsp; d. the entire file sent must be a maximum of 10mb</p><p>3. Get the runtime specified for that language</p><p>4. Get the available instances for that runtime</p><p>5. if the scheduling algorithm is "random"</p><p>&nbsp; &nbsp; a. at random, pick any instance for said runtime.</p><p>&nbsp; &nbsp; b. create a unique id for code execution</p><p>&nbsp; &nbsp; c. create all the files/folders from the request into [mounted-folder]/[id]</p><p>&nbsp; &nbsp; d. execute the code</p><p>6. if the scheduling algorithm is "round robin":</p><p>&nbsp; &nbsp; Haven't figuired out that yet :)</p><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="360" y="20" width="330" height="480" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="80" y="530" width="290" height="60" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-2" value="Code execution for python" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="145" y="550" width="160" height="30" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-3" value="files" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="130" y="640" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-4" value="python [entrypoint]" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="260" y="665" width="140" height="30" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-5" value="node [entrypoint]" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="260" y="700" width="130" height="30" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-7" value="<h1>Directory Structure</h1><p>c146affa-c760-46ad-b331-257e99f1c6ef</p><p>&nbsp; - settings</p><p>&nbsp; &nbsp; &nbsp;- __init__.py</p><p>&nbsp; - main.py</p><p>&nbsp; - __init__.py</p><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="80" y="770" width="300" height="190" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-10" value="" style="endArrow=classic;html=1;entryX=0.733;entryY=0.316;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" target="hICBj92820vfxaeRLd9u-7" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="500" y="830" as="sourcePoint"/>
<mxPoint x="520" y="830" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-11" value="execution id" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="510" y="810" width="90" height="30" as="geometry"/>
</mxCell>
<mxCell id="hICBj92820vfxaeRLd9u-12" value="<h1>run script template</h1><p>cd [execution id]</p><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="410" y="880" width="270" height="120" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="7f6_y2DXu1Kp2oh9O4EI" name="Deployment">
<mxGraphModel dx="842" dy="424" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="uIqimO3FQTD6EHcdROwg-6" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="uIqimO3FQTD6EHcdROwg-1" target="uIqimO3FQTD6EHcdROwg-5">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-1" value="Code Racer Repo" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="90" y="70" width="160" height="80" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-4" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="uIqimO3FQTD6EHcdROwg-2" target="uIqimO3FQTD6EHcdROwg-3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-2" value="Code Racer Infra Repo" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="400" y="80" width="160" height="70" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-8" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="uIqimO3FQTD6EHcdROwg-3" target="uIqimO3FQTD6EHcdROwg-7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-3" value="Pull image from docker hub" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="400" y="230" width="160" height="70" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-5" value="Push image to docker hub" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="90" y="230" width="160" height="80" as="geometry"/>
</mxCell>
<mxCell id="uIqimO3FQTD6EHcdROwg-7" value="Deploy image to AWS" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="400" y="380" width="160" height="70" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>