Skip to content

travis-ci/gcloud-cleanup

Repository files navigation

gcloud-cleanup

Clean That Cloud!

gcloud-cleanup takes care of cleaning up resources from the Google Compute Platform.

Status

Actively running in production.

How does it fit into the rest of the system

  • Deployment: Heroku, one instance per google cloud project
  • Google Cloud: We talk to the Google Compute Platform via its API
  • Job-board (github): We talk to job-board via HTTP to get information about which images are known.
  • Worker (github): gcloud-cleanup shares a redis instance with worker for API call rate limiting

What does it really do

Instance cleaning

gcloud-cleanup finds instances matching name filters that have existed for longer than a certain cutoff time and deletes them.

This ensures that instances that failed to terminate are cleaned up.

Relevant configuration:

  • GCLOUD_CLEANUP_INSTANCE_FILTERS correspond to name filters, default name eq ^testing-gce.*.
  • GCLOUD_CLEANUP_INSTANCE_MAX_AGE corresponds to cutoff time, default 3h.

Image cleaning

gcloud-cleanup queries Job-board for all known images matching name filters with infra=gce, then queries Google Cloud for all known images matching name filters, and deletes any images in the Google Cloud set that are not also in the Job-board set.

This ensures that images unknown to Job-board are cleaned up.

Relevant configuration:

  • GCLOUD_CLEANUP_IMAGE_FILTERS corresponds to name filters, default name eq ^travis-ci.*.

Rate limiting

GCE is not happy if we send them a gazillion API requests. In order to prevent us from being rate limited, we throttle the amount of requests we make.

NOTE: the ./ratelimit subpacakage is a vendored copy from travis-ci/worker.