drycc run give pod 20 minutes to execute, exceeding 20 minutes will raise a timeout exception
jianxiaoguo opened this issue · comments
lijianguo commented
todo list:
- should not raise timeout exception
- drycc run type measure
- drycc run type set limits
- there are two modes: synchronous and asynchronous
duanhongyi commented
Please refer to the web procfile for initial restrictions
duanhongyi commented
design
drycc run
to asynchronous execution, use job.drycc run
returns pod_name, add timeout parameter.drycc ps:logs
can view pod logs
> drycc run -t 3600 echo 111
appname-run-a91321-adf141
> drycc ps:logs appname-run-a91321-adf141
111
job structure
{
"apiVersion":"batch/v1",
"kind":"Job",
"metadata":{
"name":"appname-run"
},
"spec":{
"template":{
"spec":{
"containers":[
{
"name":"appname-run",
"image":"127.0.0.1:5555/appname/appname:v3",
"command":[
"echo",
"111"
]
}
],
"restartPolicy":"Never"
}
},
"backoffLimit":0,
"activeDeadlineSeconds":3600,
"ttlSecondsAfterFinished":86400
}
}
duanhongyi commented
K8s pod logs code snippet:
import asyncio
from kubernetes import config
from kubernetes.client import Configuration
from kubernetes.client.api import core_v1_api
from asgiref.sync import sync_to_async, async_to_sync
async def send(line):
print(line)
@sync_to_async
def exec_commands(api_instance):
kwargs = {"tail_lines": 10, "follow": True, "_preload_content": False, "container": ""}
stream = api_instance.read_namespaced_pod_log(
'drycc-timeseries-main-0', 'drycc', **kwargs
).stream()
for line in stream:
async_to_sync(send)(line=line)
def main():
config.load_kube_config()
try:
c = Configuration().get_default_copy()
except AttributeError:
c = Configuration()
c.assert_hostname = False
Configuration.set_default(c)
core_v1 = core_v1_api.CoreV1Api()
loop = asyncio.get_event_loop()
loop.run_until_complete(exec_commands(core_v1))
if __name__ == '__main__':
main()
duanhongyi commented
complete