drone / proposal

Drone Project Design Documents
13 stars 4 forks source link

Add step/pipeline timeout #33

Closed andrii-kasparevych closed 1 year ago

andrii-kasparevych commented 1 year ago

Some of the pipeline steps can get hanging for whatever reason (e.g. an agent gets killed w/o server noticing) or one might want to e.g. limit the tests execution time and fail if someone adds a test that runs for too long. A nice solution for that would be to add a timeout field that you could specify on the pipeline or step level, e.g.

---
kind: pipeline
type: docker
name: default
timeout: 1h

steps:
- name: backend
  image: golang
  commands:
  - go build
  - go test
  timeout: 15m

- name: frontend
  image: node
  commands:
  - npm install
  - npm run test
...
bradrydzewski commented 1 year ago

@andrii-kasparevych the default timeout is 60 minutes and can be updated in the repository settings screen. However it is important to note that the timeout is enforced by the runner (agent). Therefore, if you terminate the runner while pipelines are running, the timeout cannot be enforced which can result in the stuck pipelines. This can be avoided by gracefully stopping your runners.

With that being said, the Drone server also has a routine that runs every 24 hours to kill stuck pipelines. You can change the frequency of this routine via environment variable [1]. However we would still recommend graceful runner termination as a permanent fix.

[1] https://docs.drone.io/server/reference/drone-cleanup-interval/