@@ -110,45 +110,54 @@ async def get_deployment_marker(kube_client, generated_data, marker: str):
110110
111111async def run_pod_with_args (kube_client : AsyncClient , namespace , image_name , pod_name , args ):
112112 pod = Pod (
113- metadata = ObjectMeta (name = pod_name + "-" + str (int (time .time ()* 1000 )), namespace = namespace ),
114- spec = PodSpec (restartPolicy = "Never" ,
115- containers = [Container (name = "cmd" , image = image_name , args = args ,
116- securityContext = SecurityContext (
117- seccompProfile = SeccompProfile (type = "RuntimeDefault" ),
118- capabilities = Capabilities (drop = ["ALL" ]),
119- readOnlyRootFilesystem = True ,
120- allowPrivilegeEscalation = False ,
121- runAsNonRoot = True ,
122- runAsUser = 3000 ,
123- runAsGroup = 3000 ,
124- ),
125- )
126- ])
127- )
113+ metadata = ObjectMeta (name = pod_name + "-" + str (int (time .time () * 1000 )), namespace = namespace ),
114+ spec = PodSpec (
115+ restartPolicy = "Never" ,
116+ containers = [
117+ Container (
118+ name = "cmd" ,
119+ image = image_name ,
120+ args = args ,
121+ securityContext = SecurityContext (
122+ seccompProfile = SeccompProfile (type = "RuntimeDefault" ),
123+ capabilities = Capabilities (drop = ["ALL" ]),
124+ readOnlyRootFilesystem = True ,
125+ allowPrivilegeEscalation = False ,
126+ runAsNonRoot = True ,
127+ runAsUser = 3000 ,
128+ runAsGroup = 3000 ,
129+ ),
130+ )
131+ ],
132+ ),
133+ )
128134 try :
129135 await kube_client .create (pod )
130136 start_time = time .time ()
131137 now = time .time ()
132138 completed = False
133139 while start_time + 30 > now and not completed :
134140 found_pod = await kube_client .get (Pod , name = pod .metadata .name , namespace = pod .metadata .namespace )
135- if (found_pod .status .containerStatuses
141+ if (
142+ found_pod .status .containerStatuses
136143 and found_pod .status .containerStatuses [0 ].lastState
137144 and found_pod .status .containerStatuses [0 ].lastState .terminated
138- and found_pod .status .containerStatuses [0 ].lastState .terminated .reason == "Completed" ):
145+ and found_pod .status .containerStatuses [0 ].lastState .terminated .reason == "Completed"
146+ ):
139147 completed = True
140148 else :
141149 now = time .time ()
142150 await asyncio .sleep (1 )
143151 else :
144152 if start_time + 30 > now :
145- raise RuntimeError (f"Pod { pod .metadata .name } did not start in time "
146- f"(failed after { time .time () - now } seconds), "
147- f"pod status: { found_pod .status } " )
153+ raise RuntimeError (
154+ f"Pod { pod .metadata .name } did not start in time "
155+ f"(failed after { time .time () - now } seconds), "
156+ f"pod status: { found_pod .status } "
157+ )
148158
149159 log_lines = ""
150- async for log_line in kube_client .log (pod .metadata .name , namespace = pod .metadata .namespace ,
151- container = "cmd" ):
160+ async for log_line in kube_client .log (pod .metadata .name , namespace = pod .metadata .namespace , container = "cmd" ):
152161 log_lines += log_line
153162 return log_lines
154163 finally :
0 commit comments